Skip to content

Made FlutterWindowControllerSizeTest.SizedToContentNotResizable more robust - #195845

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
gaaclarke:FlutterWindowControllerSizeTest.SizedToContentNotResizable-robust
Nov 5, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
gaaclarke:FlutterWindowControllerSizeTest.SizedToContentNotResizable-robust

Conversation

@gaaclarke

Copy link
Copy Markdown
Member

Made FlutterWindowControllerSizeTest.SizedToContentNotResizable more robust to timing failures where onBeginFrame is called before the window is created.

This test used to flake because the onBeginFrame callback was being called before the window was created so the frame was getting sent to the wrong view. The testing logic is also made more robust by hooking into the notification center events instead of assuming that only one update will happen per run of the event loop. The actual fix is in the dart testing code flutter_desktop_test.dart.

I've tested this locally where I could reproduce the flake 1/300 times, now the tests runs 1000/1000.

fixes #194780

gemini output:

Details

I've found the real cause, fixed it, and staged the fix. It's different from my first diagnosis: the test wasn't missing a size change, the first frame was going to the wrong view.

Cause: the Dart fixture testRenderSizedToContent draws into PlatformDispatcher.instance.views.last and assumes its first frame lands in the test's window.

  • Sometimes a frame starts before the test's CreateRegularWindow call has run. At that moment views.last is the implicit view (id 0), which has no window in this test.
  • The 300×300 frame goes to view 0. Creating its render surface fails (Could not create the embedder backing store), so it's dropped.
  • The frame counter has already moved past 0, so the new window only ever gets the 200×200 frame. The test then waits for 300×300 until its 30 s timeout, which matches the CI log.

The temporary logging confirmed this directly: the failing 300×300 frame was for view id 0, and the test created view 1 a few ms later.

Staged changes (2 files):

  1. Fix, in flutter_desktop_test.dart: onBeginFrame now skips any frame where views.last is the implicit view, then renders into the test's window. A later frame is triggered when the window's view is added, so nothing hangs.
  2. Test hardening, in FlutterWindowControllerTest.mm: the resize-notification version from before. On failure it now also lists every size the window went through; that list is what pointed to the real cause here.

The temporary logging in FlutterCompositor.mm, FlutterViewEngineProvider.mm and FlutterWindowController.mm is reverted. The git checkout I used for that printed a hook notice suggesting gclient sync -D; I didn't run it.

Verification:

Run Result
Test hardening only, before the fixture fix 2 failures in 600 runs, both from the frame going to view 0
Both changes, FlutterWindowControllerSizeTest.* × 1000 1000/1000 passed
All FlutterWindowController* tests 16/16 passed

clang-format, dart format and dart analyze --fatal-infos are all clean.

SizedToContentResizable still sends its first frame to view 0 sometimes (14 of 1000 runs). It passes anyway because that fixture draws 300×300 on every frame, so a later frame fixes it. I can add the same implicit-view skip there for consistency if you'd like.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

robust to timing failures where onBeginFrame is called before the window
is created.
@gaaclarke
gaaclarke requested a review from a team as a code owner November 2, 2026 23:10
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Nov 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 updates window resizing tests to record every content size the window is resized to via notifications, preventing missed intermediate sizes during rapid frame commits, and skips initial frames in the Dart test fixture before the test window is created. The review feedback suggests refactoring the Objective-C++ test to use NSMutableArray and NSValue instead of std::vector to be more idiomatic and allow the removal of C++ headers.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically a: desktop Running on desktop team-macos Owned by the macOS platform team labels Nov 2, 2026
var frameCount = 0;
PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
final FlutterView view = PlatformDispatcher.instance.views.last;
// A frame may begin before the test has created its window, in which case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds like a race with the previous test. Can we instead clean up for the previous test's tearDown?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, it's a race condition in the test itself. I'm able to reproduce by running this one test on repeat. Also each FlutterEngineTest::SetUp creates a new FlutterEngine.

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 5, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 5, 2026
Merged via the queue into flutter:master with commit da33f2f Nov 5, 2026
28 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 5, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 6, 2026
Roll Flutter from 3623d2d34543 to 09175cdeac89 (61 revisions)

flutter/flutter@3623d2d...09175cd

2026-11-06 [email protected] Roll Skia from ae35b7b2221f to 793b8ac73d4b (3 revisions) (flutter/flutter#196091)
2026-11-06 [email protected] [web] Rasterize scenes at the size passed to `FlutterView.render` (flutter/flutter#196052)
2026-11-06 [email protected] Roll Skia from 4aa043a81e0c to ae35b7b2221f (1 revision) (flutter/flutter#196086)
2026-11-06 [email protected] Roll Fuchsia Linux SDK from Fqe3UlLwAohsPbsCS... to KIc0XZbhLmvDpTluZ... (flutter/flutter#196085)
2026-11-06 [email protected] Allow a zero scale change in InteractiveViewer (flutter/flutter#194949)
2026-11-06 [email protected] Roll Skia from dd5c2553a856 to 4aa043a81e0c (2 revisions) (flutter/flutter#196079)
2026-11-06 [email protected] [web] Keep ImageFilter.blur bounds in equality and description (flutter/flutter#196013)
2026-11-06 [email protected] iOS: Remove unused PlatformViewIOS setup from FlutterPlatformViewsTest (flutter/flutter#196033)
2026-11-06 [email protected] Serialize LoggerTests that mutate the shared Logger (flutter/flutter#196028)
2026-11-06 [email protected] Use reverseDuration for the AnimatedCrossFade size animation (flutter/flutter#194860)
2026-11-05 [email protected] Roll Skia from a5aacd103e68 to dd5c2553a856 (8 revisions) (flutter/flutter#196073)
2026-11-05 [email protected] Fix ListWheelScrollView null check error when it reads itemIndex before content dimensions are set (flutter/flutter#194859)
2026-11-05 [email protected] Allow zero cross axis extent in SliverGridDelegateWithMaxCrossAxisExtent (flutter/flutter#194858)
2026-11-05 [email protected] Revert: Allow color delta tolerance in in-memory fuzzy image comparator (flutter/flutter#196067)
2026-11-05 [email protected] Revert: Mitigate snapshot race in 3D transform test by reducing loop density (flutter/flutter#196066)
2026-11-05 [email protected] Delegate createStream in ResizeImage and ScrollAwareImageProvider (flutter/flutter#194756)
2026-11-05 [email protected] [iOS] Introduce FlutterShell and move thread host and profiler (flutter/flutter#195388)
2026-11-05 [email protected] [web] Support FragmentShader.getImageSampler on CanvasKit and Skwasm (flutter/flutter#195854)
2026-11-05 [email protected] Deprecates setFloat API (flutter/flutter#195505)
2026-11-05 [email protected] [flutter_tools] Remove public GlobalToolContext and globals from runner (flutter/flutter#195561)
2026-11-05 [email protected] Defer TLHC PlatformViewWrapper frame post and avoid initial 1x1 buffer resize (flutter/flutter#195861)
2026-11-05 [email protected] Roll Skia from b5abed66da86 to a5aacd103e68 (17 revisions) (flutter/flutter#196054)
2026-11-05 [email protected] Made `FlutterWindowControllerSizeTest.SizedToContentNotResizable` more robust (flutter/flutter#195845)
2026-11-05 [email protected] Update docs for contributor ladder (flutter/flutter#196011)
2026-11-05 [email protected] [Impeller] Use the transfer stage for the Vulkan readback barrier (flutter/flutter#194991)
2026-11-05 [email protected] Remove Mac mac_unopt builder (flutter/flutter#196027)
2026-11-05 [email protected] Updated Instructions for Determining Gradle Version for `gradle_dists` in CIPD (flutter/flutter#193310)
2026-11-05 [email protected] Move ios_app_with_extensions_test into the tool integration shard (flutter/flutter#195609)
2026-11-05 [email protected] [web] Respect Uint8List view bounds when detecting animated WebP/GIF (flutter/flutter#196010)
2026-11-05 [email protected] Add platform_views_layout to build_tests so iOS/Android build breaks are caught in presubmit (flutter/flutter#192985)
2026-11-05 [email protected] [flutter_tools] Detect macOS TCC permission crashes and provide diagnostic guidance (flutter/flutter#192432)
2026-11-05 [email protected] Roll Packages from 670b30e to 0478162 (15 revisions) (flutter/flutter#196047)
2026-11-05 [email protected] [web] Support Skwasm rendering without bitmap capture (flutter/flutter#195103)
2026-11-05 [email protected] [flutter_tools] Reland fix for local CanvasKit asset paths on Windows (flutter/flutter#195770)
2026-11-05 [email protected] Roll Skia from f96be51af95d to b5abed66da86 (14 revisions) (flutter/flutter#196017)
2026-11-05 [email protected] Split chrome web engine test drone (flutter/flutter#195873)
2026-11-05 [email protected] Roll Dart SDK from c9153304136a to 6623b84628f3 (1 revision) (flutter/flutter#196026)
2026-11-05 [email protected] Roll ICU from 4fe960221710 to a0ea93436c52 (6 revisions) (flutter/flutter#196025)
2026-11-05 [email protected] Add more guidance in README and AGENTS for contributing to flutter_tools (flutter/flutter#195998)
2026-11-05 [email protected] Roll Fuchsia Linux SDK from p0HDXLISPIElJfSz7... to Fqe3UlLwAohsPbsCS... (flutter/flutter#196019)
2026-11-05 [email protected] Roll Dart SDK from e362a23e9738 to c9153304136a (18 revisions) (flutter/flutter#196014)
2026-11-05 [email protected] [Impeller] Fix dilation input bounds when clipping saveLayers (flutter/flutter#195652)
2026-11-05 [email protected] Add `variantOf` to the M3E migration checklist (flutter/flutter#195099)
2026-11-05 [email protected] [flutter_tools] Eliminate globals from remaining subsystem files (flutter/flutter#195555)
2026-11-05 [email protected] Fix gap flipping when dragging variable height reorderable items (flutter/flutter#194478)
2026-11-05 [email protected] [A11y] Send un-merged SemanticsNodes in the same update that first references them (flutter/flutter#195829)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically team-macos Owned by the macOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mac mac_unopt FlutterWindowControllerSizeTest.SizedToContentNotResizable flakey

2 participants