Skip to content

Conversation

harryterkelsen
Copy link
Contributor

Refactors the renderer code so both renderers (Skwasm and CanvasKit) use the same SceneBuilder and platform view embedding code. This change is discussed in a design doc here: https://flutter.dev/go/web-renderer-unification

Fixes #172311
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.

@harryterkelsen harryterkelsen requested review from mdebbar and removed request for matanlurey September 15, 2025 23:07
@github-actions github-actions bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically labels Sep 15, 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 introduces a major refactoring to unify the rendering code for the Skwasm and CanvasKit web renderers. The changes are extensive, moving shared logic into a common Renderer base class and abstracting backend-specifics into Rasterizer implementations. This unification also involves removing old scene building logic and replacing it with a new shared implementation. Additionally, the testing infrastructure is updated to support different build modes. The changes are well-structured and consistent with the goal of renderer unification. A positive side-effect of this work is that many tests previously skipped for Skwasm are now enabled, indicating better feature parity. The overall code quality is high, and I found no issues in this large but well-executed refactoring.

@harryterkelsen harryterkelsen force-pushed the unify-web-renderers branch 5 times, most recently from 9225a9b to 249f31b Compare September 17, 2025 17:18
@harryterkelsen harryterkelsen changed the title [web] Refactor renderers to use the same frontend code #174588 [reland][web] Refactor renderers to use the same frontend code #174588 Sep 17, 2025
@harryterkelsen
Copy link
Contributor Author

@mdebbar PTAL

This is a reland of #174588 with some tweaks to fix the bugs that were discovered which caused us to revert the original PR.

The changes from the original PR are small. They can be found in bench_mouse_region_grid_hover.dart and bench_mouse_region_grid_mixed_hover.dart which fixes the benchmark crash. The benchmark crashed due to Skwasm speeding up due to using transferToImageBitmap instead of createImageBitmap, which caused timing issues with postFrameCallbacks being run after the benchmark was stopped. The benchmarks, as they were written before, were buggy.

There is another change to address a crash which was discovered in Google3 which happens if a frame is pumped with an empty viewport, which causes the renderer to early-exit out of rendering, but without populating the fields in the FrameTimingRecorder, which caused a crash when we tried to submit timings. This is fixed in rasterizer.dart and renderer.dart by having Rasterizer.draw return a bool indicating if it actually drew the frame and only recording frame timings if the frame was actually drawn.

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.

Looks great! I hope it sticks this time 🤞

Fix commits that are a result of bad merge

Trigger rebuild

Unify web renderers

Refactor debug JSON helpers. Make _kickRenderLoop use a while loop

remove unused import
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 17, 2025
@harryterkelsen harryterkelsen added this pull request to the merge queue Sep 17, 2025
Merged via the queue into flutter:master with commit 2e51c3f Sep 18, 2025
188 of 189 checks passed
@harryterkelsen harryterkelsen deleted the unify-web-renderers branch September 18, 2025 00:04
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 18, 2025
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
Projects
None yet
2 participants