Skip to content

fix(3dgl): Render GLCanvasElement on WebAssembly (6.8) - #25159

Merged
agneszitte merged 2 commits into
unoplatform:servicing/6.8from
ramezgerges:dev/rara/68-wasm-glcanvas-readback
Oct 13, 2026
Merged

agneszitte merged 2 commits into
unoplatform:servicing/6.8from
ramezgerges:dev/rara/68-wasm-glcanvas-readback

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: #24497 (backport of #25158)

PR Type:

🐞 Bugfix

What changed? 🚀

Backport of #25158 to 6.8. Both commits are cherry-picked with -x.

GLCanvasElement renders nothing on WebAssembly: its first framebuffer readback asks WebGL for GL_BGRA, which WebGL 2.0 rejects with INVALID_ENUM, and the element then disables itself. The fix, the same as #25158:

  • The BGRA readback probe now runs on WebAssembly too, so the element reads RGBA and swaps R/B there.
  • The probe result is cached once per process.

Differences from #25158. The fix commit applied as is. The test commit needed two changes:

  • No OnGLUnavailable on this branch. That hook doesn't exist on 6.8, so the test treats IsGLInitialized turning false before the first render as "no usable OpenGL context" (inconclusive). A readback failure only happens after a render, so it still fails the test.
  • This branch's runtime-tests layout. The test file is in Tests/Windows_UI_Xaml_Controls/, and the Graphics3DGL reference sits next to this branch's other add-in references. The compile-excluded Uno.Core.Extensions.Logging.Singleton reference is needed here too, for the same Log() ambiguity; its version comes from Directory.Build.targets.

Validation:

  • Runtime: on 6.8's WASM SamplesApp (SamplesApp.Skia.WebAssembly.Browser, net10.0, headless Edge), from a clean bin/obj:
    • The new test fails with this branch's original GLCanvasElement.cs, with IsGLInitialized false after the readback error.
    • It passes with the fix.

PR Checklist ✅

🤖 Generated with Claude Code

ramezgerges and others added 2 commits October 9, 2026 13:12
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]>
(cherry picked from commit cf193b1)
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.

Backport: this branch has no GLCanvasElement.OnGLUnavailable, so the test
treats IsGLInitialized turning false before the first render as no usable
OpenGL context.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit 3d210f7)
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 9, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238609 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 238609 has failed on Uno.UI - CI.

@ajpinedam

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 238987 did not find any UI Test snapshots differences.

@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WASM] Regression: GLCanvasElement renders blank — BGRA glReadPixels rejected by WebGL 2.0

5 participants