Skip to content

[web] Recreate canvas and context on CkOffscreenSurface resize to fix WebGL clipping - #192769

Merged
auto-submit[bot] merged 24 commits into
flutter:masterfrom
harryterkelsen:repro-canvaskit-182476
Nov 9, 2026
Merged

auto-submit[bot] merged 24 commits into
flutter:masterfrom
harryterkelsen:repro-canvaskit-182476

Conversation

@harryterkelsen

@harryterkelsen harryterkelsen commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes part of #182476

When exporting large images via Picture.toImage(), Chrome may silently clamp the physical WebGL drawing buffer during in-place canvas resizing, leaving pixels outside the clamped area unbacked and producing transparent strips.

This PR updates CkOffscreenSurface to detect when the drawing buffer is clamped on resize and acquire a fresh offscreen canvas to allocate the buffer cleanly upfront. If the requested size exceeds what the browser/GPU can support even after recreation, an UnsupportedError is thrown rather than silently returning clipped pixels.

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
@harryterkelsen harryterkelsen added the CICD Run CI/CD label Nov 3, 2026

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

Copy link
Copy Markdown
Contributor

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 refactors canvas resizing in CkSurface by introducing a _resizeCanvas method, with a specialized implementation in CkOffscreenSurface to handle WebGL drawing buffer clamping for large dimensions by recreating the WebGL context. It also adds corresponding unit and stress tests. The review feedback suggests optimizing the resource disposal order when releasing the old canvas, using the local newCanvas variable to prevent potential race conditions, and checking WebGL texture size limits in tests to avoid flakiness on restricted CI hardware.

…low, clamped bitmap capture, and post-swap context loss
Read GL_MAX_TEXTURE_SIZE through a named WebGLContext getter, reuse the
base in-place resize for the software path, restore the recorded device
pixel ratio along with the size when a resize fails, and document why the
clamp and teardown order matter. In the tests, sample single pixels
instead of reading back whole large surfaces and drop the onscreen
ping-pong check, which exercised unchanged code.
mdebbar
mdebbar previously approved these changes Nov 4, 2026
…uested

After replacing a clamped canvas, check the drawing buffer of the new
WebGL context as well. If it still cannot hold the requested size, move
the surface to a fresh canvas at its previous size and throw an
UnsupportedError instead of silently rendering clipped output.
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 7, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 7, 2026
@auto-submit

auto-submit Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/192769, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 9, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into flutter:master with commit f0add0e Nov 9, 2026
25 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 9, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 10, 2026
flutter/flutter@d463821...fffd8c2

2026-11-10 [email protected] Roll Fuchsia Test Scripts from 8QcsP_SmbsT09VgUs... to PXc5D7S_q6sIYpfFJ... (flutter/flutter#196273)
2026-11-10 [email protected] [web] Accept the capped letter spacing line shift in kitchensink (flutter/flutter#196148)
2026-11-10 [email protected] Fix Vulkan MSAA diagonal seam in FramebufferBlend (flutter/flutter#196197)
2026-11-10 [email protected] Read back images on the raster thread on OpenGLES (flutter/flutter#195927)
2026-11-10 [email protected] [web] Unify ui.Paint across CanvasKit and Skwasm (flutter/flutter#196071)
2026-11-10 [email protected] Roll Fuchsia Test Scripts from p3N3B-Kchh1bthB6n... to 8QcsP_SmbsT09VgUs... (flutter/flutter#196249)
2026-11-09 [email protected] [Impeller] Reland clipped BackdropFilter square corners fix (flutter/flutter#195716)
2026-11-09 [email protected] [web] Recreate canvas and context on CkOffscreenSurface resize to fix WebGL clipping (flutter/flutter#192769)
2026-11-09 [email protected] Roll Dart SDK from ee0f66fa0ad2 to a2baae273bb2 (1 revision) (flutter/flutter#196245)
2026-11-09 [email protected] Add Mac web_tool_tests_1_2 and _2_2 in bringup (flutter/flutter#196241)
2026-11-09 [email protected] Roll pub packages (flutter/flutter#196246)
2026-11-09 [email protected] Increase number of 'Windows tool_integration_tests' subshards (flutter/flutter#196243)
2026-11-09 [email protected] Roll Fuchsia Test Scripts from Jo-ZgQSNDuPsjlZ4s... to p3N3B-Kchh1bthB6n... (flutter/flutter#196238)
2026-11-09 [email protected] Skip UIScene pre-migration test cases on Xcode 27 (flutter/flutter#194755)
2026-11-09 [email protected] [flutter_tools] Share Analytics.isBot and make isRunningOnBot sync (flutter/flutter#194744)
2026-11-09 [email protected] [flutter_tools] Retry chromedriver startup when its port is taken (flutter/flutter#196150)
2026-11-09 [email protected] Remove unused vulkan_provider.cc (flutter/flutter#195513)
2026-11-09 [email protected] Roll Dart SDK from 3b174b7217fe to ee0f66fa0ad2 (13 revisions) (flutter/flutter#196217)
2026-11-09 [email protected] Goma is dead, long live RBE! (Take 2) (flutter/flutter#196212)
2026-11-09 [email protected] Split DevTools customer tests into its own customer_testing_devtools shard (flutter/flutter#195871)
2026-11-09 [email protected] Split mac_host_{debug,profile,release}_arm64_tests into one step per type (flutter/flutter#196031)

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

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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.

2 participants