Repository navigation
iOS: Discard pending platform view disposals on reset - #197026
Merged
Merged
Conversation
Member
Author
|
/gemini review |
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates FlutterPlatformViewsController.mm to clear viewsToDispose during a reset, which prevents incorrect disposal of recreated platform views with the same ID after a hot restart. It also adds a unit test in FlutterPlatformViewsTest.mm to verify this behavior. The review feedback identifies a variable shadowing issue in the new test where the block parameter result shadows an outer variable of the same name.
Previously, `reset` removed every platform view during a hot restart but left `viewsToDispose` as it was. Calling `dispose` on the method channel adds the view's ID to `viewsToDispose`. That view then gets disposed in `presentFrame:` in the next frame where that view isn't included. If a view was pending disposal when the hot restart happened, and the app then created a view with the same ID, `presentFrame:` then incorrectly disposed the new view in the next frame where it wasn't included. To fix this, we now clear `viewsToDispose` in `reset`. Issue: flutter#112232
cbracken
force-pushed
the
pv-refactor-8
branch
from
November 20, 2026 04:26
5ae37a0 to
daeb5c6
Compare
LouiseHsu
approved these changes
Nov 20, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Nov 21, 2026
flutter/flutter@b34b017...5423f94 2026-11-21 [email protected] Make an Impeller render target from a Vulkan backing store (flutter/flutter#193003) 2026-11-21 [email protected] Persist the vulkan shader cache on teardown (flutter/flutter#197017) 2026-11-21 [email protected] [flutter_tools] Preserve rolling log buffer for Chromium crash diagnostics (flutter/flutter#196037) 2026-11-21 [email protected] Roll Skia from 8845aecd8c53 to 39e0ad394168 (2 revisions) (flutter/flutter#197094) 2026-11-21 [email protected] Adds redirect for listen package in api.flutter.dev (flutter/flutter#197068) 2026-11-21 [email protected] Roll Dart SDK from c6857d58f0ec to fc86f5a42779 (1 revision) (flutter/flutter#197086) 2026-11-20 [email protected] iOS: Discard pending platform view disposals on reset (flutter/flutter#197026) 2026-11-20 [email protected] Tolerate a missing flutter/service_worker handler in the web first-frame notification (flutter/flutter#196329) 2026-11-20 [email protected] Roll Skia from 9aafbb357743 to 8845aecd8c53 (2 revisions) (flutter/flutter#197080) 2026-11-20 [email protected] Prevent crash in tessellator with extreme radii (flutter/flutter#196648) 2026-11-20 [email protected] Windows: in the flutter tool, always close the file handle in _download even when an HTTP request fails so that it is not left open and becomes undeletable (flutter/flutter#197061) 2026-11-20 [email protected] Roll Skia from b61640825c5b to 9aafbb357743 (7 revisions) (flutter/flutter#197066) 2026-11-20 [email protected] Swap dependabot reviewers (flutter/flutter#196995) 2026-11-20 [email protected] [iOS] Hide UIScrollEdgeEffect on FlutterSemanticsScrollView and scroll-to-top UIScrollView on iOS 26+ (flutter/flutter#195356) 2026-11-20 [email protected] [devicelab] Enable Vulkan GPU tracing by default on Android Impeller PerfTests (flutter/flutter#196822) 2026-11-20 [email protected] Roll Dart SDK from 3b5f45d812f8 to c6857d58f0ec (1 revision) (flutter/flutter#197063) 2026-11-20 [email protected] [flutter_tools] Delete flutter.version.json when switching channels (flutter/flutter#196943) 2026-11-20 [email protected] Update desktop TESTOWNERS (flutter/flutter#196930) 2026-11-20 [email protected] [web] Release CanvasKit WebGL contexts and surfaces when a view is removed (flutter/flutter#196816) 2026-11-20 [email protected] [Linux] Hide libunwind symbols in libflutter_linux_gtk.so (flutter/flutter#196451) 2026-11-20 [email protected] Roll Skia from a1edf5c2ea5c to b61640825c5b (1 revision) (flutter/flutter#197058) 2026-11-20 [email protected] [flutter_tools] Update --web-content-hash serving tip to cover assets and canvaskit (flutter/flutter#196908) 2026-11-20 [email protected] Send a semantics update when only the identifier changes (flutter/flutter#196460) 2026-11-20 [email protected] Roll Packages from 81b7c44 to 898818d (11 revisions) (flutter/flutter#197056) 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.
Previously,
resetremoved every platform view during a hot restart but leftviewsToDisposeas it was.Calling
disposeon the method channel adds the view's ID toviewsToDispose. That view then gets disposed inpresentFrame:in the next frame where that view isn't included.If a view was pending disposal when the hot restart happened, and the app then created a view with the same ID,
presentFrame:then incorrectly disposed the new view in the next frame where it wasn't included.To fix this, we now clear
viewsToDisposeinreset.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.