-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[ios] Reland Dynamic Content Resizing #179153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 relands dynamic content resizing for iOS, introducing an isAutoResizable flag on FlutterViewController. This allows an embedded Flutter view to size itself based on its content. The implementation uses custom layout constraints and asynchronous frame submission to prevent deadlocks that were an issue in a previous attempt. The changes include new integration and UI tests to validate this functionality. My review identifies a critical crash risk, a potential retain cycle, and several opportunities to improve code maintainability and style.
| CGFloat scale = self.window.windowScene.screen.scale; | ||
| CGSize scaledSize = CGSizeMake(size.width / scale, size.height / scale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing self.window.windowScene.screen.scale can cause a crash if self.window is nil, which can happen if the view is not yet part of a window hierarchy. You should add a check to ensure self.window is not nil before accessing its properties.
| CGFloat scale = self.window.windowScene.screen.scale; | |
| CGSize scaledSize = CGSizeMake(size.width / scale, size.height / scale); | |
| UIWindow* window = self.window; | |
| if (!window) { | |
| return; | |
| } | |
| CGFloat scale = window.windowScene.screen.scale; | |
| CGSize scaledSize = CGSizeMake(size.width / scale, size.height / scale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why didnt you have these thoughts in the original pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a valid concern. I don't like returning nothing though. Can we instead use self.traitCollection.displayScale to get the scale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbf this is a void function - maybe an error msg abt the view not being part of a window yet instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't like that because when you "set" something it should set it or provide some way to know programmatically that it wasn't set.
Do you not like the idea of getting self.traitCollection.displayScale or if self.window ? self.window.windowScene.screen.scale : self.traitCollection.displayScale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, gotcha.
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm
Outdated
Show resolved
Hide resolved
dev/integration_tests/ios_host_app/Host/DynamicResizingViewController.m
Outdated
Show resolved
Hide resolved
dev/integration_tests/ios_host_app/Host/DynamicResizingViewController.m
Outdated
Show resolved
Hide resolved
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm
Show resolved
Hide resolved
gaaclarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, i think the bot had a few good comments. I've noted where it had a point and I have one cleanup note that should happen now that we are using RunNowOrPostTask.
| if (self.flutterView == nil || (self.compositionOrder.empty() && !self.hadPlatformViews)) { | ||
| // No platform views to render but the FlutterView may need to be resized. | ||
| if (self.flutterView != nil) { | ||
| if (self.platformTaskRunner->RunsTasksOnCurrentThread()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is no longer necessary, RunNowOrPostTask is doing this for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to push the commit methinks =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oopssss
gaaclarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! round 2, fight!
|
autosubmit label was removed for flutter/flutter/179153, because - The status or check suite Mac mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/179153, because - The status or check suite Windows tool_tests_commands has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@5545bb3...e274574 2025-12-03 [email protected] Roll Skia from 20829e37dfb8 to db4c79d41513 (1 revision) (flutter/flutter#179401) 2025-12-03 [email protected] Roll Skia from adc7ea94cada to 20829e37dfb8 (6 revisions) (flutter/flutter#179385) 2025-12-03 [email protected] Refactor GetShaderClipDepth for clarity (flutter/flutter#179110) 2025-12-03 [email protected] Roll Skia from 3b339a83959b to adc7ea94cada (1 revision) (flutter/flutter#179376) 2025-12-03 [email protected] Roll Dart SDK from eb743a1d4ade to 0bb365d7ac74 (7 revisions) (flutter/flutter#179372) 2025-12-03 [email protected] feat: Add `mainAxisExtent` parameter to `GridView` constructors (flutter/flutter#176927) 2025-12-03 [email protected] Roll Skia from eb01fff20df8 to 3b339a83959b (4 revisions) (flutter/flutter#179371) 2025-12-02 [email protected] Fix crash when text editing value changes between scrolls (flutter/flutter#179163) 2025-12-02 [email protected] Roll Skia from 6bd3b06b1e08 to eb01fff20df8 (3 revisions) (flutter/flutter#179362) 2025-12-02 [email protected] Adds Impellerc flatbuffer format versioning. (flutter/flutter#175470) 2025-12-02 [email protected] Adds format argument to Picture.toImageSync (flutter/flutter#178691) 2025-12-02 [email protected] Delete disabled workflow and add missing permissions key to workflow (flutter/flutter#178911) 2025-12-02 [email protected] [web] Fix some gn warnings (flutter/flutter#178313) 2025-12-02 [email protected] Roll Skia from 45337c4e919d to 6bd3b06b1e08 (4 revisions) (flutter/flutter#179353) 2025-12-02 [email protected] [ios] Reland Dynamic Content Resizing (flutter/flutter#179153) 2025-12-02 [email protected] [web] Fix onTextScaleFactorChanged not getting called. (flutter/flutter#178862) 2025-12-02 [email protected] Roll Packages from c8be05d to 148dcd2 (9 revisions) (flutter/flutter#179343) 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] 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
This is a reland of flutter#177410 The previous pr was hitting deadlocks with tests that use screenshots. This reland fixes it by submitting frames asynchronously instead of synchronously. This PR fixes flutter#169147 This is the iOS implementation of flutter#149033 In Add-to-App scenarios, a common desired use case is to have the embedded FlutterView be able to size itself based on it's content. Up till now, the size had to be manually specified, which can be tedious and inaccurate. This PR adds a new flag, `isAutoResizable`, which enables the ability for the embedded flutter view to dynamically set it's own size based off it's content. Note that this feature will *NOT* work if the the embedded app is wrapped in flexible or unsized widgets, such as Scaffold. The FlutterView will just not display at all. To use the new flag, just set it like ``` flutterViewController.autoResizable = true; ``` or in Swift ``` flutterViewController.isAutoResizable = true ``` ## 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.
This is a reland of #177410
The previous pr was hitting deadlocks with tests that use screenshots. This reland fixes it by submitting frames asynchronously instead of synchronously.
This PR fixes #169147
This is the iOS implementation of #149033
In Add-to-App scenarios, a common desired use case is to have the embedded FlutterView be able to size itself based on it's content. Up till now, the size had to be manually specified, which can be tedious and inaccurate.
This PR adds a new flag,
isAutoResizable, which enables the ability for the embedded flutter view to dynamically set it's own size based off it's content. Note that this feature will NOT work if the the embedded app is wrapped in flexible or unsized widgets, such as Scaffold. The FlutterView will just not display at all.To use the new flag, just set it like
or in Swift
Pre-launch Checklist
///).