Skip to content

Conversation

@mboetger
Copy link
Contributor

This is a sample add-to-app Android project based off the existing add-to-app Android sample project. This one makes minor changes to show how content-sizing can be achieved.

Adding a content resizing sample for Android to support
flutter/flutter#179753

Pre-launch Checklist

  • I read the [Flutter Style Guide] recently, and have followed its advice.
  • I signed the [CLA].
  • I read the [Contributors Guide].
  • I have added sample code updates to the [changelog].
  • I updated/added relevant documentation (doc comments with ///).

github-merge-queue bot pushed a commit to flutter/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: #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.
@mboetger mboetger added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 30, 2026
@auto-submit auto-submit bot merged commit 023e072 into flutter:main Jan 30, 2026
6 checks passed
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.
auto-submit bot pushed a commit to flutter/flutter 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.
sfshaza2 added a commit to flutter/website that referenced this pull request Feb 3, 2026
Add Android Content Sizing Documentation.  

This PR assumes flutter/samples#2787 has landed.

## Presubmit checklist

- [X] If you are unwilling, or unable, to sign the CLA, even for a
_tiny_, one-word PR, please file an issue instead of a PR.
- [X] If this PR is not meant to land until a future stable release,
mark it as draft with an explanation.
- [X] This PR follows the [Google Developer Documentation Style
Guidelines](https://developers.google.com/style)—for example, it doesn't
use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first-person
pronouns).
- [X] This PR uses [semantic line
breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks)
  of 80 characters or fewer.

---------

Co-authored-by: Shams Zakhour <44418985+sfshaza2@users.noreply.github.com>
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants