Skip to content

[web] Add opt-in hybrid Skwasm canvas presentation - #195105

Draft
MarlonJD wants to merge 15 commits into
flutter:masterfrom
MarlonJD:skwasm-hybrid-opt-in
Draft

MarlonJD wants to merge 15 commits into
flutter:masterfrom
MarlonJD:skwasm-hybrid-opt-in

Conversation

@MarlonJD

Copy link
Copy Markdown
Contributor

Related: #187660. Part 4 of 5, split from #188628. Depends on #195103 and #195104; this draft includes those prerequisite commits. The hybrid implementation is e0773adebdaa. It stays draft until the prerequisites land and the matching engine prebuilts are available.

With skwasmUseHybridRasterizer: true, stable single-canvas scenes use a transferred onscreen canvas; multi-canvas compositions use bitmap export. A separate export surface preserves the visible frame during exit, and entry checks the placeholder against an independently exported frame. Unset configuration keeps bitmap rendering on every platform.

Offscreen and onscreen Skwasm surfaces have separate typed implementations over a shared lifecycle. Context-recovery errors reach pending render operations; continuous resize and unavailable 2D contexts retain bitmap presentation. The semaphore and codec implementations already covered by #194139 and #193187 are omitted.

Verified locally with the prerequisites: transition, resize, context-loss, callback, image and shader regressions across Chrome, Safari, Firefox and Wimp in ST/MT, with two known Wimp shader skips (#175431). Actual-display recordings cover 288 directional transitions with no invalid, missing or regressing scene frames. Five of six configurations passed the 60 Hz clock calibration; Safari MT retained all scene frames but its clock calibration remains inconclusive.

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
Zero marks an unset context-loss callback. Skip it when the shared uint32_t callback sequence wraps so context-loss notifications remain registered.
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.
Integrate upstream render sizes and deferred platform-view publication. Verify placeholder pixels independently of animation callbacks, clear stale readback pixels, and release GPU resources in their owning contexts.

Dispatch context-loss notifications without dereferencing a disposed surface. Add regression coverage for unavailable placeholders, delayed animation callbacks, context disposal, and explicit DPR in platform-view coordinate tests.
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