Sitelet https://github.com/flutter/flutter/pull/190071
Skip to content

[web] Fix null-check crash when a platform view is disposed mid-frame - #190071

Merged
mbcorona merged 4 commits into
flutter:masterfrom
mbcorona:fix-190017-platform-view-missing-clip-chain
Aug 7, 2026
Merged

mbcorona merged 4 commits into
flutter:masterfrom
mbcorona:fix-190017-platform-view-missing-clip-chain

Conversation

@mbcorona

Copy link
Copy Markdown
Member

Description

On Flutter Web, PlatformViewEmbedder._getElement force-unwrapped the clip chain for a platform view (_viewClipChains[viewId]!.root). If a view is disposed while still referenced by the frame being submitted (seen under memory pressure / hidden tab), the ! threw Null check operator used on a null value and crashed the frame.

This change makes the composition tolerate a missing clip chain: the view is skipped instead of crashing, consistent with the existing invalid-view handling in submitFrame. A regression test covers the dispose-mid-frame case.

Note: the second crash reported in the issue (_PlatformViewPlaceholderBox.performLayout) is already fixed on master, so this PR only addresses the engine crash.

Fixes

Fixes #190017

Pre-launch Checklist

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

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 27, 2026
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Jul 27, 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 prevents crashes when a platform view is disposed mid-frame during composition by tracking missing views, omitting them from the DOM, removing them from the active composition, and printing a warning. A corresponding test case has been added to verify this behavior. Feedback suggests using a Set<int> instead of a List<int> for missingViewIds to optimize lookup efficiency in removeWhere.

Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/platform_views/embedder.dart Outdated
@mbcorona
mbcorona force-pushed the fix-190017-platform-view-missing-clip-chain branch from ebb490f to 0fab43a Compare July 27, 2026 16:31
@mbcorona mbcorona self-assigned this Jul 31, 2026

@harryterkelsen harryterkelsen 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.

LGTM

@mbcorona
mbcorona enabled auto-merge August 5, 2026 15:36
@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 5, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 5, 2026
@auto-submit

auto-submit Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/190071, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

4 participants