Repository navigation
[web] Retain queued scene pictures via ContainerLayer render pinning - #196748
auto-submit[bot] merged 13 commits into
Conversation
…r queue with explicit checks
There was a problem hiding this comment.
Code Review
This pull request introduces a reference counting mechanism for layers in the Flutter web engine to manage the lifecycle of engine layers and prevent premature disposal of child layers. Key changes include adding retain/release methods to ContainerLayer, updating LayerScene and LayerSceneBuilder to manage layer lifecycles via a stack, and modifying the Renderer to retain scenes while they are queued or being rasterized. Additionally, comprehensive tests were added to render_queue_test.dart to verify the correctness of the new reference counting logic and ensure idempotent disposal behavior. No review comments were provided for this pull request.
…93696-web-skwasmrenderer-2
|
autosubmit label was removed for flutter/flutter/196748, because - The status or check suite Tree_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…93696-web-skwasmrenderer-2
|
autosubmit label was removed for flutter/flutter/196748, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions) flutter/flutter@b75c5b3...06f1c24 2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375) 2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371) 2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369) 2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364) 2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270) 2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219) 2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714) 2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965) 2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267) 2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363) 2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748) 2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596) 2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071) 2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351) 2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310) 2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266) 2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944) 2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918) 2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815) 2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229) 2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482) 2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300) 2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302) 2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004) 2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334) 2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333) 2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095) 2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355) 2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206) 2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771) 2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245) 2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563) 2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807) 2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316) 2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945) 2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309) 2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313) 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 ...
…osal Keep the queued scene cleanup from flutter#196748 before releasing the rasterizer and its shared surfaces. Verify that disposal completes the queued request immediately and only the in-flight frame reports timings.
In Flutter Web, multi-threaded WebAssembly backends (
skwasmandwimp) execute rasterization asynchronously on dedicated Web Workers. When worker rasterization spans more than one frame interval while the UI thread continues producing frames, incoming scenes are queued inRenderer.renderSceneviarenderQueue.next.Previously, if the Flutter framework or caller called
scene.dispose()(standard inRenderView.compositeFrame) orEngineLayer.dispose()while a frame was queued or in-flight,PictureLayerinstances were disposed prematurely. During deferred rasterization,PrerollVisitorfoundpicture.isDisposed == trueand culled the pictures, resulting in an empty raster recording and blank frames. Furthermore, mutableLayer.parentback-pointers prevented safe layer reuse across frames viaSceneBuilder.addRetained.This change introduces render pinning on
ContainerLayer(pinForRender/unpinForRender) so childPictureLayers remain alive while any queued or in-flight render uses their container layer, while otherwise preserving eager picture disposal as soon as a layer's handle is disposed (dispose()).LayerSceneBuildernow manages builder depth using an explicit_layerStack(matching nativeSceneBuilder::layer_stack_), eliminating mutable parent pointers and supporting multi-parent DAG topologies acrossSceneBuilder.addRetained.Fixes #193696
Behavioral Changes
scene.dispose()orEngineLayer.dispose()was called prior to deferred worker rasterization had their pictures prematurely disposed and culled byPrerollVisitor, resulting in blank frames.ContainerLayerrender pinning keeps owned pictures alive until queued/in-flight rasterization completes (or the queued request is overwritten or cancelled), then deterministically disposes them once the layer handle has been disposed—even if an ancestorEngineLayerhandle was never disposed (such as inOffsetLayer.toImage).Where to focus
_pendingRenderCount+_isHandleDisposed) rather than reference-counting parent-to-child links ensures an undisposed ancestorEngineLayer(such as the rootTransformEngineLayerpushed byOffsetLayer.toImage) never blocks descendant layers from deterministically disposing their pictures.Layer.parentback-pointers with an explicit_layerStackinLayerSceneBuilder(matchingSceneBuilder::layer_stack_) allows retained engine layers to safely belong to multiple parents across frames viaSceneBuilder.addRetained.pinForRender()andunpinForRender()gate child recursion on0 <-> 1transitions of_pendingRenderCount, avoiding redundant traversal of already-pinnedaddRetainedsubtrees across overlapping frames and keeping diamond DAGs linear.Renderer.renderScenepins the incoming scene before unpinning an overwrittenrenderQueue.nextscene so sharedaddRetainedsubtrees stay continuously pinned without a1 -> 0 -> 1bounce._disposeRasterizer, pendingqueue.nextrequests are unpinned and their completers completed after clearingqueue.next = null.engine/src/flutter/lib/web_ui/lib/src/engine/layer/layer.dart:ContainerLayerrender pinning and picture disposal.engine/src/flutter/lib/web_ui/lib/src/engine/layer/layer_scene_builder.dart:_layerStackimplementation.engine/src/flutter/lib/web_ui/lib/src/engine/renderer.dart: Scene pinning, overwrite handling, and teardown cleanup.engine/src/flutter/lib/web_ui/test/ui/render_queue_test.dart: Reproduction, undisposed-ancestor, diamond-DAG, and deterministic picture disposal tests.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.