Repository navigation
iOS: Don't clear raster thread state in platform views reset - #197025
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the reset method in FlutterPlatformViewsController to only modify platform views on the platform thread, leaving the clearing of raster-thread-only state (such as composition order, slices, and layer pools) to the start of the next frame. A new unit test was added to verify that reset correctly removes platform views not present in the frame currently being built. Feedback on the new test suggests renaming a shadowed block parameter result to avoid compiler warnings and replacing [UIScreen mainScreen].scale with a constant scale to ensure the test is hermetic and avoids deprecation warnings.
`reset` runs on the platform thread during hot restart, but it also read and cleared all the state managed by the raster thread, including: * composition order * slices * composition params * visited views It recycled the layer pool, which is also raster-thread managed state. Since that's all raster thread state, `reset` raced with any frame being built at the time. But more importantly, `beginFrameWithSize:devicePixelRatio:` already clears the frame state at the start of every frame, and `submitFrame:` recycles the layer pool. `reset` now only removes the platform views, all of them rather than only those in the composition order, since reading the composition order (which is raster thread managed state) is also racy, and all of them should be removed regardless. I added a test to simulate a race condition for a platform view that's onscreen but not in the frame being built on the raster thread. Issue: flutter#112232
cbracken
force-pushed
the
pv-refactor-7
branch
from
November 20, 2026 02:43
4b29600 to
c6d9871
Compare
LouiseHsu
approved these changes
Nov 23, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Nov 24, 2026
flutter/flutter@98744d3...b75c5b3 2026-11-24 [email protected] Roll Skia from 89e364b13f05 to 2140958ee284 (3 revisions) (flutter/flutter#197287) 2026-11-24 [email protected] Roll Skia from f82f3efc0461 to 89e364b13f05 (6 revisions) (flutter/flutter#197284) 2026-11-24 [email protected] Roll Dart SDK from 10aef26c73f5 to 87f515c52de9 (1 revision) (flutter/flutter#197279) 2026-11-24 [email protected] iOS: Drive platform view tests through IOSExternalViewEmbedder (flutter/flutter#197263) 2026-11-24 [email protected] Fix null check crash in flushSemantics from a stale ancestor geometry cache (flutter/flutter#192724) 2026-11-24 [email protected] [Impeller] Fix Windows build with MSVC 14.52: std::modf is [[nodiscard]] (flutter/flutter#193413) 2026-11-24 [email protected] [web] Preserve fill rules from path operations (flutter/flutter#195971) 2026-11-24 [email protected] Regenerate tool_test_durations.json (flutter/flutter#197261) 2026-11-24 [email protected] Roll Skia from 694af434cadd to f82f3efc0461 (4 revisions) (flutter/flutter#197258) 2026-11-24 [email protected] Increase number of 'Linux tool_integration_tests' subshards (flutter/flutter#197262) 2026-11-24 [email protected] Run tool_integration_tests app tests in one subshard instead of all of them (flutter/flutter#197264) 2026-11-24 [email protected] [flutter_tools] Pass featureFlags in localizations_test.dart (flutter/flutter#197269) 2026-11-23 [email protected] Fix Orca flat review in Linux accessibility (flutter/flutter#196338) 2026-11-23 [email protected] [flutter tools] Pass --client-id=flutter-analyze to the analysis server (flutter/flutter#197227) 2026-11-23 [email protected] [Flutter GPU] Expose the maximum render target size (flutter/flutter#196640) 2026-11-23 [email protected] iOS: Don't clear raster thread state in platform views reset (flutter/flutter#197025) 2026-11-23 [email protected] iOS: Composite platform views from layers in tests (flutter/flutter#197021) 2026-11-23 [email protected] [flutter_tools] Harden extension diagnostics models and RPC failure handling (flutter/flutter#196233) 2026-11-23 [email protected] [flutter_tools] Support standalone UI packages in gen-l10n (flutter/flutter#194500) 2026-11-23 [email protected] [flutter_tools] Consolidate ToolDependencies.bootstrap builders and require extension managers (flutter/flutter#196388) 2026-11-23 [email protected] Roll Skia from 31b19bdc8195 to 694af434cadd (2 revisions) (flutter/flutter#197239) 2026-11-23 [email protected] Roll Dart SDK from df632229552e to 10aef26c73f5 (1 revision) (flutter/flutter#197234) 2026-11-23 [email protected] [macOS] Fix back buffer cache returning a wrong-size surface (Impeller null deref in Canvas::SetupRenderPass) (flutter/flutter#192522) 2026-11-23 [email protected] Add Settings::frame_built_callback for UI frame build timings (flutter/flutter#197213) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resetruns on the platform thread during hot restart, but it also read and cleared all the state managed by the raster thread, including:It recycled the layer pool, which is also raster-thread managed state.
Since that's all raster thread state,
resetraced with any frame being built at the time. But more importantly,beginFrameWithSize:devicePixelRatio:already clears the frame state at the start of every frame, andsubmitFrame:recycles the layer pool.resetnow only removes the platform views, all of them rather than only those in the composition order, since reading the composition order (which is raster thread managed state) is also racy, and all of them should be removed regardless.I added a test to simulate a race condition for a platform view that's onscreen but not in the frame being built on the raster thread.
Issue: #112232
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-assistbot 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.