Skip to content

[web] Isolate SkwasmRenderer.pictureToImageSurface from rasterizer offscreenSurface - #192770

Closed
harryterkelsen wants to merge 4 commits into
flutter:masterfrom
harryterkelsen:repro-skwasm-182476
Closed

harryterkelsen wants to merge 4 commits into
flutter:masterfrom
harryterkelsen:repro-skwasm-182476

Conversation

@harryterkelsen

Copy link
Copy Markdown
Contributor

Description

In Skwasm, SkwasmRenderer.pictureToImageSurface directly aliased (rasterizer as OffscreenCanvasRasterizer).offscreenSurface. When asynchronous Picture.toImage() or toByteData() calls ran concurrently with active view rendering (renderScene), viewport dimensions and rendering contexts contended, causing image exports to be corrupted or stomped by window dimensions.

This PR decouples pictureToImageSurface in SkwasmRenderer to a dedicated Surface created via rasterizer.createPictureToImageSurface(), restoring architectural parity with CanvasKitRenderer. It also adds unit and adversarial lifecycle stress tests verifying isolation and reset semantics.

Fixes part of #182476

Pre-launch Checklist

@github-actions

Copy link
Copy Markdown

This pull request targets the main branch, but the primary branch for this repository is master.

Please change the base branch of this pull request to master.

See: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request

@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 Sep 14, 2026
@harryterkelsen
harryterkelsen changed the base branch from main to master September 14, 2026 21:22
bdero pushed a commit to bdero/flutter_scene that referenced this pull request Sep 19, 2026
On the web, a glTF texture went browser decode -> ui.Image ->
Image.toByteData -> CPU mip chain -> texSubImage2D per level. That read-back
runs on the framework's renderer, which on skwasm clips images above 5760²
(flutter/flutter#182476) and races with frame rendering
(flutter/flutter#192770), and the whole path blocks the main thread.

createImageBitmap + texSubImage2D + generateMipmap never leaves the
backend's WebGL context. Normal maps keep the CPU chain. Other backends
return null and decode through dart:ui as before.

Node.fromGlbBytes gains maxTextureSize, honoured on every backend.
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