Skip to content

[web] Commit platform-view DOM after rasterization - #195104

Open
MarlonJD wants to merge 5 commits into
flutter:masterfrom
MarlonJD:web-platform-view-commit
Open

MarlonJD wants to merge 5 commits into
flutter:masterfrom
MarlonJD:web-platform-view-commit

Conversation

@MarlonJD

Copy link
Copy Markdown
Contributor

Related: #187660. Part 3 of 5, split from #188628. This change can land independently of the hybrid rasterizer.

Keeps the previous platform-view DOM order, size and clip chain while the next frame rasterizes. New canvas allocation happens before rasterization; DOM publication and staged canvas commits happen after it completes. Failed or disposed frames release their temporary canvases without publishing the new composition.

Verified locally: delayed-rasterization, enter/exit and failure-recovery regressions with CanvasKit's single- and multi-surface paths, plus Skwasm and Wimp ST/MT. Existing platform-view positioning tests also pass.

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.

@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 Oct 22, 2026
yexuan910812 pushed a commit to yexuan910812/flutter that referenced this pull request Oct 30, 2026
…188628)

Related: flutter#187660. Part 1 of 5 from the original hybrid-rasterizer
change. This PR is now limited to the independent benchmark
instrumentation.

Adds `presentation_duration` around preparation and frame submission,
including asynchronous raster work, and records it in the web benchmark
harness. The timer stops before reporting, and benchmark listeners are
cleaned up even when startup fails. The existing profile JSON schema is
unchanged.

Verified locally: two engine timing tests cover enabled/disabled
profiling and delayed preparation/rasterization; a browser regression
test covers listener cleanup after synchronous startup failures. Static
analysis and formatting pass. This change is independent of the hybrid
rasterizer.

The remaining pieces are separate drafts:

- flutter#195103: native callback IDs and optional bitmap capture.
- flutter#195104: platform-view DOM commit after rasterization.
- flutter#195105: opt-in hybrid presentation, depending on the two changes
above.
- flutter#195106: desktop default policy and benchmark results, depending on
the opt-in implementation.

The duplicate semaphore and codec changes were dropped on rebase because
master already includes flutter#194139 and flutter#193187.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant in-code documentation (doc comments with
`///`).
- [ ] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

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](https://developers.google.com/gemini-code-assist/docs/review-github-code).
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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@MarlonJD
MarlonJD marked this pull request as ready for review November 5, 2026 17:49

@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 refactors the platform view compositing flow to delay DOM injection and parameter updates until after rasterization successfully completes, adding robust disposal and error handling to prevent rendering inconsistent states. The feedback suggests adding documentation comments to the new public getter isDisposed in rasterizer.dart to comply with the style guide, and removing a redundant block of code in embedder.dart that sets displayCanvas to null unnecessarily.

Comment on lines +357 to +361
if (composition.equalsForCompositing(_activeComposition)) {
for (final CompositionCanvas canvas in _activeComposition.canvases) {
canvas.displayCanvas = null;
}
}

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.

medium

This block is redundant because _updateDomForNewComposition(composition) (called on line 356) already iterates through all entities and sets previousEntity.displayCanvas = null for all matching canvases when indexMap[index] != -1. Since composition.equalsForCompositing(_activeComposition) is true, all canvases will have a valid mapping in indexMap and thus will already have had their displayCanvas set to null.

Keep canvases alive until pending rasterization finishes and clean up partially prepared frames. Handle platform-view removal during rasterization and keep staged presentation hooks with the hybrid rasterizer.
Merge current master while preserving disposed-frame cancellation and timing guards. Pass each queued render size through the rasterizer and update the platform-view regression helper for the required size argument.
@MarlonJD

Copy link
Copy Markdown
Contributor Author

Would someone be able to reapply the CICD label when they have a moment? I’ve resolved the merge conflicts and verified the updated commit locally (267 tests passed). Thank you!

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant