Skip to content

[fix] target device selector updates#8891

Merged
pq merged 2 commits into
flutter:mainfrom
pq:fix_toolbarUpdates
Apr 8, 2026
Merged

[fix] target device selector updates#8891
pq merged 2 commits into
flutter:mainfrom
pq:fix_toolbarUpdates

Conversation

@pq
Copy link
Copy Markdown
Collaborator

@pq pq commented Apr 8, 2026

In #8853, users are reporting an exception in Android Studio thanks to excessive toolbar updates. This is caused by the Flutter plugin triggering frequent global toolbar updates via a call to ActivityTracker.getInstance().inc() whenever the device or emulator lists change.

The Fix. To reduce update frequency, this change makes the updates targeted, removing the (global)ActivityTracker.getInstance().inc() calls from DeviceSelectorAction.updateActions() and DeviceService.refreshDeviceDaemon(), invoking a newly extracted updateComponent method in DeviceSelectorAction instead. This ensures that the Flutter device selector UI still updates immediately when devices are connected or disconnected, but without forcing a global re-query of all actions on the toolbar.

Verification. Verified manually and io.flutter.actions.DeviceSelectorActionTest still passes.

Fixes #8853


Review the contribution guidelines below:

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've included the required information in the description above.
  • My up-to-date information is in the AUTHORS file.
  • I've updated CHANGELOG.md if appropriate.
Contribution guidelines:
  • See
    our contributor guide and
    the Flutter organization contributor guide
    for general expectations for PRs.
  • Larger or significant changes should be discussed in an issue before creating a PR.
  • Dart contributions to our repos should follow the Dart style guide and use
    dart format.
  • Java and Kotlin contributions should strive to follow Java and Kotlin best
    practices (discussion).

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the device selection logic by extracting UI update logic into a dedicated updateComponent method and removing manual ActivityTracker increments. The review identified critical threading violations where UI-related operations in updateComponent are executed on a background thread instead of the Event Dispatch Thread (EDT). Additionally, a redundant call to updateComponent was found that should be removed to avoid unnecessary processing.

Comment thread src/io/flutter/actions/DeviceSelectorAction.java
Comment thread src/io/flutter/actions/DeviceSelectorAction.java
Comment thread src/io/flutter/actions/DeviceSelectorAction.java
@pq pq changed the title [fix] excessive system toolbar updates [fix] target device selector updates Apr 8, 2026
Comment thread src/io/flutter/actions/DeviceSelectorAction.java
@pq pq requested a review from jwren April 8, 2026 16:08
@pq pq merged commit 27965c3 into flutter:main Apr 8, 2026
8 checks passed
@pq pq deleted the fix_toolbarUpdates branch April 8, 2026 16:34
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.

Toolbar creates new components every update: GoogleLoginAction button changes on each update

2 participants