Repository navigation
[web] Unify ui.Canvas behind a shared EngineCanvas frontend - #196348
Merged
auto-submit[bot] merged 11 commits intoNov 13, 2026
Merged
auto-submit[bot] merged 11 commits into
auto-submit[bot] merged 11 commits into
Conversation
Adds EngineCanvas, a ui.Canvas implementation shared by all renderers, over a new stateless BackendCanvas boundary. EngineCanvas owns the argument checks (matching native dart:ui), image retention, the per-draw paint lifecycle and unwrapping of frontend objects. CkCanvas and SkwasmCanvas become thin BackendCanvas translators. Skwasm and wimp now get the same argument checks as native, empty drawAtlas colors are treated as no colors, and WebParagraph can be drawn on every renderer.
…etained by every draw, empty point and atlas lists, and local clip bounds under rotation and singular transforms
…cs, drop dead toFlatColors
harryterkelsen
marked this pull request as ready for review
November 11, 2026 00:44
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the web engine's canvas architecture by introducing a unified EngineCanvas frontend that implements ui.Canvas and handles argument validation, image tracking, and paint lifecycles. It delegates rendering operations to stateless backend implementations (CkCanvas and SkwasmCanvas) via a new BackendCanvas interface. The review feedback suggests optimizing drawPoints, drawRawPoints, drawAtlas, and drawRawAtlas in EngineCanvas by returning early when the input collections are empty to avoid unnecessary allocations and setup.
mdebbar
reviewed
Nov 12, 2026
mdebbar
reviewed
Nov 12, 2026
…eduplicate test fakes
mdebbar
approved these changes
Nov 12, 2026
This was referenced Nov 13, 2026
This was referenced Nov 13, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Nov 13, 2026
…13653) Manual roll Flutter from 9c427b5d7b1c to 1b9585481095 (32 revisions) Manual roll requested by [email protected] flutter/flutter@9c427b5...1b95854 2026-11-13 [email protected] Roll pub packages (flutter/flutter#196541) 2026-11-13 [email protected] Do not route PRs for review without cla, convert to draft (flutter/flutter#196341) 2026-11-13 [email protected] Roll Skia from d87a6c04da74 to 11f46cfe8838 (13 revisions) (flutter/flutter#196533) 2026-11-13 [email protected] [flutter_tools, flutter_test] Deprecate --experimental-faster-testing (flutter/flutter#196123) 2026-11-13 [email protected] [flutter_tools] Handle RPCError in ScreenshotCommand.runSkia (flutter/flutter#196132) 2026-11-13 [email protected] Roll Dart SDK from a8b961fd48bb to c91e8b6674e2 (2 revisions) (flutter/flutter#196502) 2026-11-13 [email protected] Roll Skia from 0c5ce4960cef to d87a6c04da74 (12 revisions) (flutter/flutter#196497) 2026-11-13 [email protected] Don't call `skia_image()` for raster-owned images in `DlImage::Equals` (flutter/flutter#196473) 2026-11-13 [email protected] [flutter_tools] Require FlutterCommandRunner DI fields and extract findCommandName (flutter/flutter#196331) 2026-11-13 [email protected] [web] Unify ui.Canvas behind a shared EngineCanvas frontend (flutter/flutter#196348) 2026-11-13 [email protected] Link to MediaQuery.displayFeaturesOf from DisplayFeatures (flutter/flutter#193728) 2026-11-13 [email protected] Removes reference to unnecessary ensureSemantics call in doc (flutter/flutter#195831) 2026-11-13 [email protected] [flutter_tools] Register trackWidgetCreation in AppleBuildOptionsBundle (flutter/flutter#196078) 2026-11-12 [email protected] [Android] Skip the HardwareBuffer defect fallback for platform views (flutter/flutter#193441) 2026-11-12 [email protected] Fix supports_decal check in framebuffer_blend.frag (flutter/flutter#196227) 2026-11-12 [email protected] [ios] Update the screen in didUpdateEffectiveGeometry (flutter/flutter#195508) 2026-11-12 [email protected] [flutter_tools] Add `Cache-Control` headers for web test assets (flutter/flutter#196414) 2026-11-12 [email protected] Roll Skia from 3b71ec08218f to 0c5ce4960cef (16 revisions) (flutter/flutter#196472) 2026-11-12 [email protected] [web] Render bounded ImageFilter.blur on wimp (flutter/flutter#196081) 2026-11-12 [email protected] Roll Dart SDK from 69567bd3c427 to a8b961fd48bb (2 revisions) (flutter/flutter#196464) 2026-11-12 [email protected] [engine] Release the Skia OpenGL resource context on shutdown (flutter/flutter#193592) 2026-11-12 [email protected] [web] Fix decoding of still AVIF images on Chrome (flutter/flutter#195958) 2026-11-12 [email protected] Gate SurfaceControl context setting on API 34+ (flutter/flutter#196394) 2026-11-12 [email protected] [flutter_tools] Only pass on a valid root tool in DASH__TOOL (flutter/flutter#196228) 2026-11-12 [email protected] Support GL_TEXTURE_EXTERNAL_OES embedder textures in Impeller (flutter/flutter#195857) 2026-11-12 [email protected] Stop building linux/wasm_release in local_engine_builds (flutter/flutter#196345) 2026-11-12 [email protected] Split flame out of Linux customer_testing (flutter/flutter#196347) 2026-11-12 Jiwon Lee [Windows] Fix Space input after Alt+Space with previous Microsoft IME (flutter/flutter#192105) 2026-11-12 [email protected] [flutter_tools] Add ToolExtensionException, exit() guard, graceful shutdown, and base modifiers (flutter/flutter#195908) 2026-11-12 [email protected] Roll Packages from 653628e to 14f9933 (9 revisions) (flutter/flutter#196450) 2026-11-12 [email protected] Roll Dart SDK from e5add7a25b32 to 69567bd3c427 (2 revisions) (flutter/flutter#196437) 2026-11-12 [email protected] Roll Skia from 9aa2513a4ac9 to 3b71ec08218f (1 revision) (flutter/flutter#196436) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unifies
ui.Canvasacross CanvasKit and Skwasm behind a sharedEngineCanvasfrontend (primitives/canvas.dart) and statelessBackendCanvasboundary (backend/canvas.dart), turningCkCanvasandSkwasmCanvasinto thin native translators. Centralizing argument validation,PictureImageTrackerimage retention, the per-drawBackendPaintlifecycle, point/atlas typed-array flattening, superellipse path emulation,getLocalClipBounds, andWebParagraphdispatch brings all web renderers onto a single implementation with consistent runtime behavior.Part of #175630
Behavioral Changes
Canvasarguments identically to CanvasKit and nativedart:ui:transformmatrix without 16 entries, an odd-lengthdrawRawPointslist, or mismatcheddrawAtlas/drawRawAtlastransform, rect, and color lengths.ArgumentErrorand message as CanvasKit and nativedart:ui, without mutating the save stack, transform, or tracked images.clipRSuperellipse/drawRSuperellipseon CanvasKit as well).Image,Picture,Paragraph,Vertices, or atlas image, or callingdrawAtlas/drawRawAtlaswith colors and anullblendMode, now throwsAssertionErroracross all web renderers (previously missing, or throwingStateErrorfor disposed pictures on CanvasKit and disposed vertices).drawAtlas(colors: [])on Skwasm now treats an empty color list as "no colors":dart:uiby passingnullwhencolorsis empty.drawParagraphnow supportsWebParagraphon Skwasm:SkwasmCanvas.drawParagraphthrew aTypeErrorwhen given aWebParagraph; only CanvasKit routed it toWebParagraph.paint.EngineCanvas.drawParagraphdispatchesWebParagraphon every renderer.Where to focus
lib/src/engine/primitives/canvas.dart: Ordering invariant inEngineCanvas—all validation and throwing delegate unwraps (backendPath,backendImage,EngineVertices.delegate,getBackendFilter) run before_trackerrecording andcreateBackendPaint(), so rejected calls never retain images or leak a native paint. Image and atlas draws passdefaultBlurTileMode: ui.TileMode.clamp; all other draws use the default decal mode.lib/src/engine/canvaskit/canvas.dartandlib/src/engine/skwasm/skwasm_impl/canvas.dart: StatelessBackendCanvastranslators preserving backend-specific conversions (CanvasKit degree conversion, Mitchell cubic sampling, and float nine-slice centers; SkwasmStackScopeconversions, integer nine-slice centers, anddrawAtlascullRect).lib/src/engine/canvaskit/{picture_recorder,picture,surface}.dartandlib/src/engine/skwasm/skwasm_impl/picture.dart: Recorders and internal raster canvases now wrap their backend canvas inEngineCanvas, andLayerPictureexposesimageTrackersoEngineCanvas.drawPicturemerges retained image sources in the frontend.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-assistbot 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.