Repository navigation
Layout on the iOS profile and release mode happens with zero max size first and then the actual max size. #149974
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jun 10, 2024 Thanks for the report. I was able to replicate the reported behavior only on iOS.
stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.22.2, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.22.2 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (33 hours ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.23.0-13.0.pre.149, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.23.0-13.0.pre.149 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision ae47edab7a (68 minutes ago), 2024-06-07 01:34:14 -0400 • Engine revision 087feab992 • Dart version 3.5.0 (build 3.5.0-234.0.dev) • DevTools version 2.36.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/dhs/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13C100 • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 65.1.4 • Dart plugin version 213.7228 [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (3 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 15.3.1 19D52 • macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category.Reacted by Kostia Sokolovskyi- addedplatform-iosiOS applications specificallyiOS applications specificallyhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-iosOwned by iOS platform teamOwned by iOS platform teamfound in release: 3.22Found to occur in 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.a: layoutSystemChrome and Framework's Layout IssuesSystemChrome and Framework's Layout Issuesand removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jun 10, 2024 Hello, thank you for creating this issue! This is a performance optimization that's working as intended. This is platform-specific, which is why you'll see different behaviors on different platforms. Desktop platforms also have this "zero size" first frame.
That first frame with an empty size allows Flutter and your app to initialize themselves before we know the size of the view. This makes the second frame (which is the first frame driven by a vsync) as fast as possible.
Please let us know if you have any other questions or concerns!
Reacted by Kostia Sokolovskyi- addedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jun 13, 2024 @loic-sharma thanks a lot for your response and explanation!
I was not able to find this info in the Flutter docs and decided that this might be something not expected.
Do we have this performance optimization described in the docs?- removedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jun 16, 2024 @ksokolovskyi Hey there, here are some interesting docs you might find useful:
-
flutter/packages/flutter/lib/src/scheduler/binding.dart
Lines 994 to 1016 in b98d485
/// ## Design discussion /// /// The Flutter engine prompts the framework to generate frames when it /// receives a request from the operating system (known for historical reasons /// as a vsync). However, this may not happen for several milliseconds after /// the app starts (or after a hot reload). To make use of the time between /// when the widget tree is first configured and when the engine requests an /// update, the framework schedules a _warm-up frame_. /// /// A warm-up frame may never actually render (as the engine did not request /// it and therefore does not have a valid context in which to paint), but it /// will cause the framework to go through the steps of building, laying out, /// and painting, which can together take several milliseconds. Thus, when the /// engine requests a real frame, much of the work will already have been /// completed, and the framework can generate the frame with minimal /// additional effort. /// /// Warm-up frames are scheduled by [runApp] on startup, and by /// [RendererBinding.performReassemble] during a hot reload. /// /// Warm-up frames are also scheduled when the framework is unblocked by a /// call to [RendererBinding.allowFirstFrame] (corresponding to a call to /// [RendererBinding.deferFirstFrame] that blocked the rendering). -
https://api.flutter.dev/flutter/dart-ui/PlatformDispatcher/scheduleWarmUpFrame.html
-
https://api.flutter.dev/flutter/dart-ui/FlutterView/physicalSize.html
At startup, the size of the view may not be known before Dart code runs. If this value is observed early in the application lifecycle, it may report Size.zero.
I've also sent a pull request to further clarify this situation: #150464
Please let us know if you have more questions!
-
Hi @loic-sharma, thanks a lot for the links you shared and for the PR!
Reacted by Loïc Sharma- added a commit that references this issue
on Jun 25, 2024 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Jul 9, 2024
Steps to reproduce
Expected results
Layout happens once with the actual max size.
Actual results
Layout happens twice: zero max size first and then the actual max size.
Code sample
Code sample 1
Code sample 2
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
iOS debug logs
iOS profile logs
iOS release logs
Android debug logs
Android release logs
macOS debug logs
macOS release logs
Flutter Doctor output
Doctor output