Repository navigation
fix(wasm): Size strided WebGL uploads to their row length - #25147
Conversation
Above a 2GB MAXIMUM_MEMORY, emscripten drops its garbage-free WebGL2 upload path and slices the source as width * height, ignoring UNPACK_ROW_LENGTH and UNPACK_SKIP_*. Skia uploads glyph atlas patches with a row length, so WebGL rejected them with INVALID_OPERATION and glyphs rendered blank. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG
|
Claude finished @MartinZikmund's task in 28s —— View job Review of #25147Verdict: looks good, with minor comments. I reviewed the diff by inspection only. I did not build or run anything.
Cross-cutting notes
|
Rounding the re-sliced length up to whole elements could run past the end of the buffer. Also skip the argument copy when no unpack stride is set. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG
🤖 Addressed PR comments up to this pointRe the Claude review summary:
|
|
Claude finished @MartinZikmund's task in 22s —— View job Review of #25147 (updated for the latest push)Verdict: fix-first (minor). I reviewed by inspection only. I did not build or run anything.
Cross-cutting notes
|
Checking for the row length constant instead of the WebGL2RenderingContext type keeps WebGL 1 out and lets the upload fix be exercised without a GPU. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG
CI browsers have no WebGL2, so the real-context tests were inconclusive there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG
|
Claude finished @MartinZikmund's task in 35s —— View job Review of #25147 (latest push)Verdict: fix-first (minor). I reviewed by inspection only. I did not build or run anything.
Notes
|
|
Follow-up on the
Local Skia WASM: |
WasmSemanticDomHelper exists only under HAS_UNO, so the WinAppSDK head failed to build. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG
|
Claude finished @MartinZikmund's task in 22s —— View job Review of #25147 (latest push)Verdict: fix-first (minor). I reviewed by inspection only. I did not build or run anything.
Notes
|
|
The build 238622 found UI Test snapshots differences: Details
|
GitHub Issue: closes #25146
PR Type:
🐞 Bugfix
What changed? 🚀
On Skia WebAssembly, text randomly lost glyphs ("Browse Grid" → "rowse r") whenever the app's WASM memory limit is above 2 GB, as in SamplesApp (
EmccMaximumHeapSize= 4 GB).Why: above 2 GB, emscripten 3.1.56 turns off its garbage-free WebGL2 upload path (a workaround for Firefox bug 1838218). The fallback slices the pixel source as
height * widthrows and ignoresUNPACK_ROW_LENGTH/UNPACK_SKIP_*. Skia uploads partial glyph-atlas patches with a row length set, so WebGL rejected them withINVALID_OPERATION: texSubImage2D: ArrayBufferView not big enough. Those atlas cells stayed empty while Skia believed they were filled.Fix:
EmscriptenWebGL.createContextnow wrapspixelStorei,texImage2DandtexSubImage2Don every emscripten-managed WebGL2 context (the Skia surface andGLCanvasElement). When a typed-array upload is shorter than the strided region the unpack state describes, the view is re-sliced to the required length from the same buffer. A short view keeps clear of the large-offset Firefox bug that the garbage-free path would reintroduce. Uploads that are already large enough, PBO offsets and non-array sources pass through untouched.Validation
1282 INVALID_OPERATION; a correctly sized view →0Given_WasmWebGlUploads(Runtime, Skia WASM, net10 publish)64,456,456,64; red before:64,64,64,64) — this one needs no GPU, so it runs on CI; plus a strided upload on a real patched WebGL2 context raises no error, and the live Skia context is patched (these two are Inconclusive on CI, whose browser has no WebGL2)texSubImage2Derrors in the console, text renders fully. Without it, the revamped shell (#25108) dropped glyphs, and 5 of 10 instrumented uploads failedfixStridedUploadsinstall call removed (Runtime, Chromium, 1280x800,?sample=RichTextBlock_Showcase)texSubImage2Derrors, visible dropout ("The qu ck ow f ju ps o the l zy", command-bar icons and description strip shredded) · with: 0 errors, all text intactPerformance
Measured in Chromium on the fixed build (Runtime):
texSubImage2D, unpatched (no-op target)No pixel data is copied; the strided path only creates a view over the same buffer. Real upload counts over a full page load:
RichTextBlock_Showcase7texSubImage2D(6 strided) + 157pixelStorei; default landing 9 (6 strided) + 71pixelStorei, with 0.1-0.3 ms spent in the native calls. That puts the added cost at roughly 10 µs per page load, once, during loading; nothing per frame. Without the fix, each rejected upload also costs a GL error and a console warning.Why now
Uploads only take this path when
MAXIMUM_MEMORYis above 2 GB. SamplesApp went to 4 GB in f49c78d (perf samples); at the 2 GB default, emscripten passes the whole heap plus an offset and WebGL sizes strided uploads correctly. Apps on the default ceiling are unaffected.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_01Dpy6FGmTfiTyJWZnteuZZG