Add fl_view_new_sized_to_content()#182924
Conversation
These views set their size to what the frames provided by Flutter. Window metrics events are not sent to Flutter.
There was a problem hiding this comment.
Code Review
This pull request introduces a new view type, fl_view_new_sized_to_content, which allows a Flutter view to control its own size. The changes involve modifications to the compositor to support querying frame sizes and conditionally waiting for frames, updates to FlView to handle the new sizing logic, and the addition of the new view constructor. Overall, the changes are logical, but I've identified a critical issue with an uninitialized variable, a high-severity bug in the software compositor's rendering loop, and opportunities for code refactoring and test improvement.
I am having trouble creating individual review comments. Click here to see my feedback.
engine/src/flutter/shell/platform/linux/fl_view.cc (83)
The new sized_to_content member is not initialized in fl_view_init. This can lead to undefined behavior for views created with fl_view_new or fl_view_new_for_engine, as the member will contain a garbage value. Please initialize it to FALSE in fl_view_init to ensure predictable behavior.
engine/src/flutter/shell/platform/linux/fl_compositor_software.cc (102)
This wait loop is susceptible to a potential deadlock. The width and height are calculated before the loop. Since fl_task_runner_wait() processes GTK events, the window can be resized while waiting. If a resize occurs, this loop will continue to wait for the old dimensions, which may never be produced by the engine.
The fl_compositor_opengl_render function correctly handles this by re-calculating the window dimensions inside its wait loop. This implementation should be updated to match that logic to ensure correctness and prevent deadlocks.
engine/src/flutter/shell/platform/linux/fl_view_test.cc (234-254)
This test case only verifies that a sized_to_content view can be created and destroyed. It doesn't test the core functionality, which is that the view resizes itself based on the Flutter frame size. Per the repository style guide, code should be tested.
To make this test more effective, it should be expanded to:
- Create and realize the view within a top-level window.
- Simulate a frame being presented by Flutter (e.g., by calling
redraw_cbafter setting up a mock compositor that returns a specific frame size). - Verify that
gtk_widget_set_size_requestis called on the view's render area with the expected dimensions.
References
- The style guide states that 'Code should be tested'. The current test for
SizedToContentis minimal and does not adequately test the new functionality. (link)
|
Responding to the review from Gemini:
|
mattkae
left a comment
There was a problem hiding this comment.
Two minor things, but I will let you disagree if need be
These views set their size to what the frames provided by Flutter. Window metrics events are not sent to Flutter.
Roll Flutter from b31548feb941 to 1141b2bdce66 (56 revisions) flutter/flutter@b31548f...1141b2b 2026-02-27 [email protected] flutter#182361 Fix delegate copy on plugins init (flutter/flutter#182362) 2026-02-27 [email protected] Roll Dart SDK from 8b036b3e63cb to 1cdb7dfd913e (1 revision) (flutter/flutter#183004) 2026-02-27 [email protected] Manual roll Dart SDK to 3.12.0-192.0.dev (flutter/flutter#182883) 2026-02-27 [email protected] Roll Skia from e2062707b0c0 to ed220c490eea (1 revision) (flutter/flutter#182992) 2026-02-27 [email protected] Roll Skia from e5aa1ab5c59c to e2062707b0c0 (3 revisions) (flutter/flutter#182989) 2026-02-27 [email protected] Linux build hooks: Read compiler config from CMakeCache.txt (flutter/flutter#181004) 2026-02-27 [email protected] Roll ICU from a86a32e67b8d to 7971660ba630 (3 revisions) (flutter/flutter#182986) 2026-02-27 [email protected] Roll Skia from 49c2de95384e to e5aa1ab5c59c (2 revisions) (flutter/flutter#182980) 2026-02-27 [email protected] [Impeller] Remove shared rendering data from TextFrame (flutter/flutter#182886) 2026-02-27 [email protected] Add fl_view_new_sized_to_content() (flutter/flutter#182924) 2026-02-27 [email protected] [Shortcuts] Improve focus node debug labels (flutter/flutter#181834) 2026-02-27 [email protected] Add a cli flag for toggling HCPP use, and enable it (flutter/flutter#182516) 2026-02-27 [email protected] `SizedBox.square()` (flutter/flutter#182731) 2026-02-27 [email protected] [web] Fix stack corruption in Skwasm and harden withStackScope API (flutter/flutter#182912) 2026-02-26 [email protected] Roll zlib to 7eda07b1e067 (flutter/flutter#182692) 2026-02-26 [email protected] [ CI ] Don't crash analysis when ktlint isn't on PATH (flutter/flutter#181854) 2026-02-26 [email protected] Add calls to await `flutterDriver.waitUntilFirstFrameRasterized()` for all `android_engine_test` screenshot tests (flutter/flutter#182961) 2026-02-26 [email protected] Roll Skia from f44d7db68805 to 49c2de95384e (30 revisions) (flutter/flutter#182957) 2026-02-26 [email protected] Support sending window constraints in metrics events (flutter/flutter#182921) 2026-02-26 [email protected] Reland: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter/flutter#182891) 2026-02-26 [email protected] Remove some instances of useMaterial3: true (flutter/flutter#182944) 2026-02-26 [email protected] [Impeller] Use bilinear filtering for non-uniform scaled text (flutter/flutter#182224) 2026-02-26 [email protected] Add a ResidentCompilerFactory to create ResidentCompiler instances. (flutter/flutter#182930) 2026-02-26 [email protected] Add a getter in run.dart to access use-application-binary flag. (flutter/flutter#182931) 2026-02-26 [email protected] [web] Roll Firefox to 148 (flutter/flutter#182859) 2026-02-26 [email protected] Roll Packages from acd9adb to e1d0169 (8 revisions) (flutter/flutter#182946) 2026-02-26 [email protected] Roll Fuchsia Linux SDK from XI0Ax7fbtYE4XKYAQ... to G1GwOdVt5bM7GjMSY... (flutter/flutter#182942) 2026-02-26 [email protected] Add test for WindowPositioner.toString (flutter/flutter#182906) 2026-02-26 [email protected] Remove unused function prototype (flutter/flutter#182915) 2026-02-26 [email protected] Resolve inconsistency with SchedulerBinding.scheduleTask usage recomm… (flutter/flutter#182531) 2026-02-26 [email protected] Fix false positives for hit test misses in flutter_test (flutter/flutter#180856) 2026-02-26 [email protected] Replace an instance of flutter/engine with flutter/flutter (flutter/flutter#182655) 2026-02-26 [email protected] Use null-aware elements in widgets/routes.dart (flutter/flutter#181242) 2026-02-26 [email protected] Fix typos in method names across multiple files (flutter/flutter#182584) 2026-02-26 [email protected] Fix RawAutocomplete crash when options are hidden (flutter/flutter#182785) 2026-02-26 [email protected] Describe implications of tree-status and Google Testing for PRs (flutter/flutter#182916) 2026-02-26 [email protected] Make sure that a StretchingOverscrollIndicator doesn't crash when it … (flutter/flutter#182499) 2026-02-26 [email protected] framework: Use a super-parameter in several missed cases (flutter/flutter#182580) 2026-02-25 [email protected] `WidgetStatesConstraint` as a mixin (flutter/flutter#181704) 2026-02-25 [email protected] Paint the paragraph as a single image (flutter/flutter#181206) 2026-02-25 [email protected] Remove `ExtendSelectionByPageIntent` (flutter/flutter#182642) 2026-02-25 [email protected] feat: add few required properties to test widgets app (flutter/flutter#182805) 2026-02-25 [email protected] Updates MenuAnchor to respect software keyboard (flutter/flutter#180975) 2026-02-25 [email protected] Roll ImGui to v1.92.6-docking (flutter/flutter#182799) 2026-02-25 [email protected] Roll GoogleTest to e9907112b472 (flutter/flutter#182795) 2026-02-25 [email protected] Make positionInlineChildren assert much clearer (flutter/flutter#182093) ...
These views set their size to what the frames provided by Flutter. Window metrics events are not sent to Flutter.
…r#11137) Roll Flutter from b31548feb941 to 1141b2bdce66 (56 revisions) flutter/flutter@b31548f...1141b2b 2026-02-27 [email protected] flutter#182361 Fix delegate copy on plugins init (flutter/flutter#182362) 2026-02-27 [email protected] Roll Dart SDK from 8b036b3e63cb to 1cdb7dfd913e (1 revision) (flutter/flutter#183004) 2026-02-27 [email protected] Manual roll Dart SDK to 3.12.0-192.0.dev (flutter/flutter#182883) 2026-02-27 [email protected] Roll Skia from e2062707b0c0 to ed220c490eea (1 revision) (flutter/flutter#182992) 2026-02-27 [email protected] Roll Skia from e5aa1ab5c59c to e2062707b0c0 (3 revisions) (flutter/flutter#182989) 2026-02-27 [email protected] Linux build hooks: Read compiler config from CMakeCache.txt (flutter/flutter#181004) 2026-02-27 [email protected] Roll ICU from a86a32e67b8d to 7971660ba630 (3 revisions) (flutter/flutter#182986) 2026-02-27 [email protected] Roll Skia from 49c2de95384e to e5aa1ab5c59c (2 revisions) (flutter/flutter#182980) 2026-02-27 [email protected] [Impeller] Remove shared rendering data from TextFrame (flutter/flutter#182886) 2026-02-27 [email protected] Add fl_view_new_sized_to_content() (flutter/flutter#182924) 2026-02-27 [email protected] [Shortcuts] Improve focus node debug labels (flutter/flutter#181834) 2026-02-27 [email protected] Add a cli flag for toggling HCPP use, and enable it (flutter/flutter#182516) 2026-02-27 [email protected] `SizedBox.square()` (flutter/flutter#182731) 2026-02-27 [email protected] [web] Fix stack corruption in Skwasm and harden withStackScope API (flutter/flutter#182912) 2026-02-26 [email protected] Roll zlib to 7eda07b1e067 (flutter/flutter#182692) 2026-02-26 [email protected] [ CI ] Don't crash analysis when ktlint isn't on PATH (flutter/flutter#181854) 2026-02-26 [email protected] Add calls to await `flutterDriver.waitUntilFirstFrameRasterized()` for all `android_engine_test` screenshot tests (flutter/flutter#182961) 2026-02-26 [email protected] Roll Skia from f44d7db68805 to 49c2de95384e (30 revisions) (flutter/flutter#182957) 2026-02-26 [email protected] Support sending window constraints in metrics events (flutter/flutter#182921) 2026-02-26 [email protected] Reland: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter/flutter#182891) 2026-02-26 [email protected] Remove some instances of useMaterial3: true (flutter/flutter#182944) 2026-02-26 [email protected] [Impeller] Use bilinear filtering for non-uniform scaled text (flutter/flutter#182224) 2026-02-26 [email protected] Add a ResidentCompilerFactory to create ResidentCompiler instances. (flutter/flutter#182930) 2026-02-26 [email protected] Add a getter in run.dart to access use-application-binary flag. (flutter/flutter#182931) 2026-02-26 [email protected] [web] Roll Firefox to 148 (flutter/flutter#182859) 2026-02-26 [email protected] Roll Packages from acd9adb to e1d0169 (8 revisions) (flutter/flutter#182946) 2026-02-26 [email protected] Roll Fuchsia Linux SDK from XI0Ax7fbtYE4XKYAQ... to G1GwOdVt5bM7GjMSY... (flutter/flutter#182942) 2026-02-26 [email protected] Add test for WindowPositioner.toString (flutter/flutter#182906) 2026-02-26 [email protected] Remove unused function prototype (flutter/flutter#182915) 2026-02-26 [email protected] Resolve inconsistency with SchedulerBinding.scheduleTask usage recomm… (flutter/flutter#182531) 2026-02-26 [email protected] Fix false positives for hit test misses in flutter_test (flutter/flutter#180856) 2026-02-26 [email protected] Replace an instance of flutter/engine with flutter/flutter (flutter/flutter#182655) 2026-02-26 [email protected] Use null-aware elements in widgets/routes.dart (flutter/flutter#181242) 2026-02-26 [email protected] Fix typos in method names across multiple files (flutter/flutter#182584) 2026-02-26 [email protected] Fix RawAutocomplete crash when options are hidden (flutter/flutter#182785) 2026-02-26 [email protected] Describe implications of tree-status and Google Testing for PRs (flutter/flutter#182916) 2026-02-26 [email protected] Make sure that a StretchingOverscrollIndicator doesn't crash when it … (flutter/flutter#182499) 2026-02-26 [email protected] framework: Use a super-parameter in several missed cases (flutter/flutter#182580) 2026-02-25 [email protected] `WidgetStatesConstraint` as a mixin (flutter/flutter#181704) 2026-02-25 [email protected] Paint the paragraph as a single image (flutter/flutter#181206) 2026-02-25 [email protected] Remove `ExtendSelectionByPageIntent` (flutter/flutter#182642) 2026-02-25 [email protected] feat: add few required properties to test widgets app (flutter/flutter#182805) 2026-02-25 [email protected] Updates MenuAnchor to respect software keyboard (flutter/flutter#180975) 2026-02-25 [email protected] Roll ImGui to v1.92.6-docking (flutter/flutter#182799) 2026-02-25 [email protected] Roll GoogleTest to e9907112b472 (flutter/flutter#182795) 2026-02-25 [email protected] Make positionInlineChildren assert much clearer (flutter/flutter#182093) ...
These views set their size to what the frames provided by Flutter. Window metrics events are not sent to Flutter.
…r#11137) Roll Flutter from b31548feb941 to 1141b2bdce66 (56 revisions) flutter/flutter@b31548f...1141b2b 2026-02-27 [email protected] flutter#182361 Fix delegate copy on plugins init (flutter/flutter#182362) 2026-02-27 [email protected] Roll Dart SDK from 8b036b3e63cb to 1cdb7dfd913e (1 revision) (flutter/flutter#183004) 2026-02-27 [email protected] Manual roll Dart SDK to 3.12.0-192.0.dev (flutter/flutter#182883) 2026-02-27 [email protected] Roll Skia from e2062707b0c0 to ed220c490eea (1 revision) (flutter/flutter#182992) 2026-02-27 [email protected] Roll Skia from e5aa1ab5c59c to e2062707b0c0 (3 revisions) (flutter/flutter#182989) 2026-02-27 [email protected] Linux build hooks: Read compiler config from CMakeCache.txt (flutter/flutter#181004) 2026-02-27 [email protected] Roll ICU from a86a32e67b8d to 7971660ba630 (3 revisions) (flutter/flutter#182986) 2026-02-27 [email protected] Roll Skia from 49c2de95384e to e5aa1ab5c59c (2 revisions) (flutter/flutter#182980) 2026-02-27 [email protected] [Impeller] Remove shared rendering data from TextFrame (flutter/flutter#182886) 2026-02-27 [email protected] Add fl_view_new_sized_to_content() (flutter/flutter#182924) 2026-02-27 [email protected] [Shortcuts] Improve focus node debug labels (flutter/flutter#181834) 2026-02-27 [email protected] Add a cli flag for toggling HCPP use, and enable it (flutter/flutter#182516) 2026-02-27 [email protected] `SizedBox.square()` (flutter/flutter#182731) 2026-02-27 [email protected] [web] Fix stack corruption in Skwasm and harden withStackScope API (flutter/flutter#182912) 2026-02-26 [email protected] Roll zlib to 7eda07b1e067 (flutter/flutter#182692) 2026-02-26 [email protected] [ CI ] Don't crash analysis when ktlint isn't on PATH (flutter/flutter#181854) 2026-02-26 [email protected] Add calls to await `flutterDriver.waitUntilFirstFrameRasterized()` for all `android_engine_test` screenshot tests (flutter/flutter#182961) 2026-02-26 [email protected] Roll Skia from f44d7db68805 to 49c2de95384e (30 revisions) (flutter/flutter#182957) 2026-02-26 [email protected] Support sending window constraints in metrics events (flutter/flutter#182921) 2026-02-26 [email protected] Reland: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter/flutter#182891) 2026-02-26 [email protected] Remove some instances of useMaterial3: true (flutter/flutter#182944) 2026-02-26 [email protected] [Impeller] Use bilinear filtering for non-uniform scaled text (flutter/flutter#182224) 2026-02-26 [email protected] Add a ResidentCompilerFactory to create ResidentCompiler instances. (flutter/flutter#182930) 2026-02-26 [email protected] Add a getter in run.dart to access use-application-binary flag. (flutter/flutter#182931) 2026-02-26 [email protected] [web] Roll Firefox to 148 (flutter/flutter#182859) 2026-02-26 [email protected] Roll Packages from acd9adb to e1d0169 (8 revisions) (flutter/flutter#182946) 2026-02-26 [email protected] Roll Fuchsia Linux SDK from XI0Ax7fbtYE4XKYAQ... to G1GwOdVt5bM7GjMSY... (flutter/flutter#182942) 2026-02-26 [email protected] Add test for WindowPositioner.toString (flutter/flutter#182906) 2026-02-26 [email protected] Remove unused function prototype (flutter/flutter#182915) 2026-02-26 [email protected] Resolve inconsistency with SchedulerBinding.scheduleTask usage recomm… (flutter/flutter#182531) 2026-02-26 [email protected] Fix false positives for hit test misses in flutter_test (flutter/flutter#180856) 2026-02-26 [email protected] Replace an instance of flutter/engine with flutter/flutter (flutter/flutter#182655) 2026-02-26 [email protected] Use null-aware elements in widgets/routes.dart (flutter/flutter#181242) 2026-02-26 [email protected] Fix typos in method names across multiple files (flutter/flutter#182584) 2026-02-26 [email protected] Fix RawAutocomplete crash when options are hidden (flutter/flutter#182785) 2026-02-26 [email protected] Describe implications of tree-status and Google Testing for PRs (flutter/flutter#182916) 2026-02-26 [email protected] Make sure that a StretchingOverscrollIndicator doesn't crash when it … (flutter/flutter#182499) 2026-02-26 [email protected] framework: Use a super-parameter in several missed cases (flutter/flutter#182580) 2026-02-25 [email protected] `WidgetStatesConstraint` as a mixin (flutter/flutter#181704) 2026-02-25 [email protected] Paint the paragraph as a single image (flutter/flutter#181206) 2026-02-25 [email protected] Remove `ExtendSelectionByPageIntent` (flutter/flutter#182642) 2026-02-25 [email protected] feat: add few required properties to test widgets app (flutter/flutter#182805) 2026-02-25 [email protected] Updates MenuAnchor to respect software keyboard (flutter/flutter#180975) 2026-02-25 [email protected] Roll ImGui to v1.92.6-docking (flutter/flutter#182799) 2026-02-25 [email protected] Roll GoogleTest to e9907112b472 (flutter/flutter#182795) 2026-02-25 [email protected] Make positionInlineChildren assert much clearer (flutter/flutter#182093) ...
These views set their size to what the frames provided by Flutter. Window metrics events are not sent to Flutter.