Repository navigation
fix(3dgl): Render GLCanvasElement on WebAssembly - #25158
Conversation
|
The build 238608 found UI Test snapshots differences: Details
|
GLCanvasElement skipped its BGRA readback probe on the browser, on the premise that the JS shim translated BGRA reads. GL entry points now resolve to emscripten's native GL first, so glReadPixels reaches WebGL with GL_BGRA, which WebGL 2.0 rejects with INVALID_ENUM. The first readback failed and the element stopped rendering, leaving it blank. WebGL reports itself as OpenGL ES, so the existing GLES probe now runs there and selects the RGBA read with the red/blue swap. Every element gets its context from the same platform logic, so the probe now runs once per process instead of per element, which also keeps the browser from logging a WebGL warning for each element. Fixes unoplatform#24497 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Renders a GLCanvasElement cleared to pure red and checks the readback shows red, which fails for a blank canvas and for a red/blue mix-up. Inconclusive where no OpenGL context is available. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
3d210f7 to
01c412e
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25158/wasm-skia-net9/index.html |
|
The build 239689 found UI Test snapshots differences: Details
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
GitHub Issue: closes #24497
PR Type:
🐞 Bugfix
What changed? 🚀
GLCanvasElementrendered nothing on WebAssembly. Its first frame failed withThe framebuffer readback failed with InvalidEnum, and the element then disabled itself, leaving a blank area.Cause. The element copies its framebuffer into a BGRA
WriteableBitmapwithglReadPixels. GLES drivers don't all support BGRA reads, soNeedsRgbaReadbackSwapprobes with a 1×1 BGRA read and falls back to RGBA plus an R/B swap. On the browser it skipped the probe, assuming the JS shim translated BGRA reads. That stopped being true when GL entry points started resolving to emscripten's native GL first (7482315):glReadPixelsnow reaches WebGL withGL_BGRA, which WebGL 2.0 always rejects withINVALID_ENUM. The probe and its stale assumption landed three days after that change (eb66ce7).Fix:
OpenGL ES 3.0 (…); I checked its GL library for the .NET 10 (3.1.56) and .NET 11 (6.0.3) emsdks. So the existing GLES path applies: the probe fails and the element reads RGBA and swaps R/B.readPixels: invalid formatwarning, so this keeps it to one per page.Test.
Given_GLCanvasElement.When_Cleared_Then_Shows_Clear_Colorclears aGLCanvasElementto pure red and checks the screenshot. It catches a blank canvas and a red/blue mix-up. It's inconclusive when no OpenGL context is available (OnGLUnavailable). These are the firstGLCanvasElementruntime tests.Uno.WinUI.Graphics3DGL.Uno.Core.Extensions.Logging.Singleton, whoseUno.Extensions.LogExtensionPointmakes existingLog()calls in the tests ambiguous. The test project references it withExcludeAssets="compile", leavingGraphics3DGL's own dependencies untouched.Backports: #25159 (6.8) and #25160 (6.7). WebAssembly
GLCanvasElementsupport first shipped in 6.7 together with this bug, so no stable release has rendered it.Validation:
net11.0-browserwasm, headless Edge):IsGLInitializedfalse after theInvalidEnumreadback error, and passes with it.GLCanvasElement_Cubesample shows a blank area before and the rotating cube after.readPixelsfails with0x500and leaves the buffer all zero; an RGBA read returns the right pixel.Uno.WinUI.Graphics3DGLbuilds with analyzers on.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code