Ensure content-sizing resize is run on UI thread#181686
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses a threading issue by ensuring that the content-sizing resize operation is executed on the UI thread. This is achieved by posting the MaybeResizeSurfaceView call to the platform task runner. Additionally, it introduces a new metadata flag, io.flutter.embedding.android.EnableContentSizing, to make content sizing an opt-in feature, which is now disabled by default. The changes appear correct and effectively resolve the described issue. I have a couple of minor suggestions to improve code clarity and correctness.
9 tasks
gmackall
approved these changes
Jan 30, 2026
gmackall
left a comment
Member
There was a problem hiding this comment.
LGTM, I think this makes more sense than the previous approach
mboetger
added a commit
to mboetger/samples
that referenced
this pull request
Jan 30, 2026
flutteractionsbot
pushed a commit
to flutteractionsbot/flutter
that referenced
this pull request
Jan 30, 2026
While testing with a different add-to-app flutter/samples#2787, an exception is sometimes thrown when the resize is attempted because the callback comes from a different thread. It is expected that the raster thread calls this but with previous [testing](https://github.com/mboetger/test-add-to-app/tree/content-sizing) never caused this exception. This PR ensures the resize happens on the UI thread. It also a flag to ensure content sizing is disabled. Fixes: flutter#181573 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing.
5 tasks
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jan 31, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jan 31, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 1, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 1, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 1, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 2, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 2, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 2, 2026
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 2, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Feb 2, 2026
flutter/flutter@1d9d6a9...9eafba4 2026-02-01 [email protected] Roll Skia from a8ceddc2bca0 to 4ee9eb659ae0 (1 revision) (flutter/flutter#181773) 2026-02-01 [email protected] Roll Skia from a5a535bc21a3 to a8ceddc2bca0 (1 revision) (flutter/flutter#181772) 2026-02-01 [email protected] Roll Dart SDK from cde322c518b9 to 84abc8d58ec8 (1 revision) (flutter/flutter#181767) 2026-02-01 [email protected] Roll Dart SDK from c72b3f527a07 to cde322c518b9 (1 revision) (flutter/flutter#181763) 2026-01-31 [email protected] Roll Dart SDK from 43de79f08887 to c72b3f527a07 (1 revision) (flutter/flutter#181762) 2026-01-31 [email protected] Roll Fuchsia Linux SDK from 27OsrsrKcrr2pOaqY... to nI52U4LJMrBv8G1M9... (flutter/flutter#181760) 2026-01-31 [email protected] Roll Dart SDK from a0aac59705e5 to 43de79f08887 (1 revision) (flutter/flutter#181758) 2026-01-31 [email protected] Roll Skia from b704afbcd8e7 to a5a535bc21a3 (1 revision) (flutter/flutter#181757) 2026-01-31 [email protected] Roll Dart SDK from d6f77f9098e1 to a0aac59705e5 (1 revision) (flutter/flutter#181756) 2026-01-31 [email protected] Roll Skia from 6f9511ce11ba to b704afbcd8e7 (4 revisions) (flutter/flutter#181753) 2026-01-31 [email protected] Roll Dart SDK from 0cf997832948 to d6f77f9098e1 (2 revisions) (flutter/flutter#181749) 2026-01-31 [email protected] Roll Skia from 33c00c0f3b8b to 6f9511ce11ba (1 revision) (flutter/flutter#181744) 2026-01-31 [email protected] Roll Dart SDK from be3ffc51d407 to 0cf997832948 (1 revision) (flutter/flutter#181740) 2026-01-30 [email protected] Roll Skia from b62d43b59dd6 to 33c00c0f3b8b (1 revision) (flutter/flutter#181735) 2026-01-30 [email protected] [Impeller] Fix type conversion warnings seen on Windows when Impeller GL API wrappers log arguments with function types (flutter/flutter#181734) 2026-01-30 [email protected] Update New Android API Docs (flutter/flutter#180604) 2026-01-30 [email protected] Roll Fuchsia Linux SDK from isy1ARvK-3bsvtfc-... to 27OsrsrKcrr2pOaqY... (flutter/flutter#181733) 2026-01-30 [email protected] Fix P3-to-sRGB color conversion to operate in linear light (flutter/flutter#181720) 2026-01-30 [email protected] chore: deflake Linux_mokey flutter_engine_group_performance (flutter/flutter#181624) 2026-01-30 [email protected] Roll Dart SDK from 2703fd9733ce to be3ffc51d407 (1 revision) (flutter/flutter#181729) 2026-01-30 [email protected] Ensure content-sizing resize is run on UI thread (flutter/flutter#181686) 2026-01-30 [email protected] [ Tool ] Cleanup `ResidentCompiler` initialization logic (flutter/flutter#181421) 2026-01-30 [email protected] [native assets] Split debug info into `.dsym` files (flutter/flutter#181533) 2026-01-30 [email protected] Roll Skia from 4745eb2fe837 to b62d43b59dd6 (1 revision) (flutter/flutter#181727) 2026-01-30 [email protected] add ccache support for custom toolchain (flutter/flutter#180737) 2026-01-30 [email protected] update GLFW to latest and use EGL context creation on linux (flutter/flutter#181259) 2026-01-30 [email protected] add stacktrace support when requested for host builds (flutter/flutter#181264) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit Bot
pushed a commit
that referenced
this pull request
Feb 3, 2026
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. Cherry-pick of #181686 ### Issue Link: What is the link to the issue this cherry-pick is addressing? #181573 ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Crash Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping of production apps (the app crashes on launch). App crashes This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick. Apps running this code will crash: https://buganizer.corp.google.com/issues/478788744 ### Changelog Description: Explain this cherry pick: * Makes sure the JNI method is called on Android's UI thread. * The JNI method would be called by the raster's thread and cause a crash. * That includes which platforms are impacted. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples. Android Apps < Replace with changelog description here > [flutter/181573] When resize JNI method is called on Android, apps will crash. ### Workaround: Is there a workaround for this issue? No. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Run the sample app flutter/samples#2787 and check it does not crash.
LongCatIsLooong
pushed a commit
to LongCatIsLooong/flutter
that referenced
this pull request
Feb 6, 2026
While testing with a different add-to-app flutter/samples#2787, an exception is sometimes thrown when the resize is attempted because the callback comes from a different thread. It is expected that the raster thread calls this but with previous [testing](https://github.com/mboetger/test-add-to-app/tree/content-sizing) never caused this exception. This PR ensures the resize happens on the UI thread. It also a flag to ensure content sizing is disabled. Fixes: flutter#181573 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing.
flutter-zl
pushed a commit
to flutter-zl/flutter
that referenced
this pull request
Feb 10, 2026
While testing with a different add-to-app flutter/samples#2787, an exception is sometimes thrown when the resize is attempted because the callback comes from a different thread. It is expected that the raster thread calls this but with previous [testing](https://github.com/mboetger/test-add-to-app/tree/content-sizing) never caused this exception. This PR ensures the resize happens on the UI thread. It also a flag to ensure content sizing is disabled. Fixes: flutter#181573 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing.
rickhohler
pushed a commit
to rickhohler/flutter
that referenced
this pull request
Feb 19, 2026
While testing with a different add-to-app flutter/samples#2787, an exception is sometimes thrown when the resize is attempted because the callback comes from a different thread. It is expected that the raster thread calls this but with previous [testing](https://github.com/mboetger/test-add-to-app/tree/content-sizing) never caused this exception. This PR ensures the resize happens on the UI thread. It also a flag to ensure content sizing is disabled. Fixes: flutter#181573 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing.
Xbectordash
pushed a commit
to Xbectordash/abhi_flutter_fork
that referenced
this pull request
May 13, 2026
…1732) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. Cherry-pick of flutter#181686 What is the link to the issue this cherry-pick is addressing? flutter#181573 What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Crash Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping of production apps (the app crashes on launch). App crashes This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick. Apps running this code will crash: https://buganizer.corp.google.com/issues/478788744 Explain this cherry pick: * Makes sure the JNI method is called on Android's UI thread. * The JNI method would be called by the raster's thread and cause a crash. * That includes which platforms are impacted. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples. Android Apps < Replace with changelog description here > [flutter/181573] When resize JNI method is called on Android, apps will crash. Is there a workaround for this issue? No. What is the risk level of this cherry-pick? Are you confident that your fix is well-tested by automated tests? What are the steps to validate that this fix works? Run the sample app flutter/samples#2787 and check it does not crash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While testing with a different add-to-app flutter/samples#2787, an exception is sometimes thrown when the resize is attempted because the callback comes from a different thread. It is expected that the raster thread calls this but with previous testing never caused this exception.
This PR ensures the resize happens on the UI thread. It also a flag to ensure content sizing is disabled.
Fixes: #181573
Pre-launch Checklist
///).