Skip to content

[web] Unify Renderer frontend code #173426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 54 commits into
base: master
Choose a base branch
from

Conversation

harryterkelsen
Copy link
Contributor

@harryterkelsen harryterkelsen commented Aug 7, 2025

Unifies the shared code between the two web renderers, CanvasKit and Skwasm.

See https://flutter.dev/go/web-renderer-unification for details.

Fixes #172308
Fixes #142072

Pre-launch Checklist

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

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 a: text input Entering text in a text field or keyboard related problems engine flutter/engine repository. See also e: labels. platform-web Web applications specifically labels Aug 7, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 is a significant refactoring aimed at unifying the frontend code for the CanvasKit and Skwasm web renderers. The changes are extensive, introducing a new layer-based scene representation and compositing mechanism, which replaces the previous SceneBuilder. Many files have been moved and renamed, and classes have been updated to implement new unified interfaces like LayerCanvas and LayerPicture. The platform view embedding logic has also been modernized to use CSS clip-path instead of SVG clips. Overall, the refactoring appears well-executed and consistent with the goal of code unification. I've found one minor issue to address.

@harryterkelsen
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 is a large-scale refactoring to unify the frontend code for the CanvasKit and Skwasm web renderers. It introduces a common layer-based scene representation and compositing logic, moving and renaming many files to create a more modular and shared architecture. The changes are extensive and touch many parts of the web engine, from rendering primitives to the scene building and rasterization pipeline. My review focuses on one potential issue found in the new platform view clipping implementation, but overall the refactoring appears well-structured and consistent with its goal.

@harryterkelsen harryterkelsen changed the title [WIP] [web] Unify Renderer frontend code [web] Unify Renderer frontend code Aug 18, 2025
Copy link
Contributor

@eyebrowsoffire eyebrowsoffire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big refactor, thanks for doing this! Curious whether you've run the benchmarks yet and have any idea whether this change has any perf effects?

@harryterkelsen
Copy link
Contributor Author

Big refactor, thanks for doing this! Curious whether you've run the benchmarks yet and have any idea whether this change has any perf effects?

I haven't yet. I plan to run them today. Differences in Skwasm performance are the main remaining risk for this PR so I definitely want to make sure there are no regressions

@harryterkelsen
Copy link
Contributor Author

Big refactor, thanks for doing this! Curious whether you've run the benchmarks yet and have any idea whether this change has any perf effects?

I haven't yet. I plan to run them today. Differences in Skwasm performance are the main remaining risk for this PR so I definitely want to make sure there are no regressions

I ran the benchmarks several times and didn't notice any benchmarks that were consistently slower or faster by a significant amount. It's difficult to tell, though, since the benchmarks that are faster or slower change with each run of the benchmarks.

@harryterkelsen harryterkelsen requested a review from mdebbar August 19, 2025 23:30
@eyebrowsoffire
Copy link
Contributor

Big refactor, thanks for doing this! Curious whether you've run the benchmarks yet and have any idea whether this change has any perf effects?

I haven't yet. I plan to run them today. Differences in Skwasm performance are the main remaining risk for this PR so I definitely want to make sure there are no regressions

I ran the benchmarks several times and didn't notice any benchmarks that were consistently slower or faster by a significant amount. It's difficult to tell, though, since the benchmarks that are faster or slower change with each run of the benchmarks.

Great, thanks for checking. Unless it's really drastic, it can be hard to really make a judgment on perf from a single run of benchmarks due to noise. Let's just keep an eye on skia-perf in the coming days after this lands.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #173426 at sha 4729b62

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Aug 20, 2025
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #173426 at sha 6b6de7e

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #173426 at sha 5910aac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems engine flutter/engine repository. See also e: labels. platform-web Web applications specifically will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web] Use the same platform view embedder for Skwasm and CanvasKit [web] Use EngineScene logic in CanvasKit renderer.
3 participants