Skip to content

Select isolate exposing ext.flutter.driver during connection - #911

Closed
OksanaTka wants to merge 2 commits into
appium:mainfrom
OksanaTka:fix/flutter-isolate-selection
Closed

Select isolate exposing ext.flutter.driver during connection#911
OksanaTka wants to merge 2 commits into
appium:mainfrom
OksanaTka:fix/flutter-isolate-selection

Conversation

@OksanaTka

Copy link
Copy Markdown

Problem

On Android, a data-only FCM message can start a headless Flutter engine to run a firebase_messaging background handler before the application's UI engine starts.

This can result in two root isolates named main:

  • A background isolate that does not expose ext.flutter.driver.
  • A UI isolate that exposes ext.flutter.driver.

During automatic discovery, connectSocket currently selects the first isolate whose name contains main and polls only that isolate.

If the background isolate appears first, connection fails with:

"ext.flutter.driver" is not found in "extensionRPCs"
Cannot connect to the Dart Observatory URL

This is related to the two-main-isolate behavior reported in #756.

Fix

For automatic isolate discovery, this change:

  1. Refreshes the VM isolate list on each retry.
  2. Inspects the available isolates using getIsolate.
  3. Selects an isolate only when its extensionRPCs contains ext.flutter.driver.
  4. Continues polling with a refreshed isolate list if the UI isolate has not registered the extension yet.
  5. Preserves explicit appium:isolateId behavior by validating only the configured isolate.

Manual verification

I verified the change with an Android terminated-app notification flow:

  1. A data-only FCM message started a background Flutter engine.
  2. Tapping the notification started the UI Flutter engine.
  3. The Dart VM reported two isolates named main.
  4. The updated logic selected the isolate exposing ext.flutter.driver.
  5. flutter:connectObservatoryWsUrl succeeded.
  6. Existing Flutter ValueKey finders and interactions succeeded.

Validation

  • npm run build
  • npm run lint
  • npm run format:check
  • Existing Android and iOS GitHub Actions checks

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant