Skip to content

fix(3dgl): Render GLCanvasElement on WebAssembly (6.7) - #25160

Merged
agneszitte merged 2 commits into
unoplatform:release/stable/6.7from
ramezgerges:dev/rara/67-wasm-glcanvas-readback
Nov 2, 2026
Merged

agneszitte merged 2 commits into
unoplatform:release/stable/6.7from
ramezgerges:dev/rara/67-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.7. 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.7, 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.7'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

@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 238610 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 238610 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 238988 did not find any UI Test snapshots differences.

@unodevops

Copy link
Copy Markdown
Contributor

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

@ramezgerges
ramezgerges force-pushed the dev/rara/67-wasm-glcanvas-readback branch from 90d2d16 to 74f32b6 Compare October 20, 2026 14:38
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

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

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@ramezgerges
ramezgerges enabled auto-merge November 2, 2026 17:02
@nventive-devops

Copy link
Copy Markdown
Contributor

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

@ramezgerges
ramezgerges force-pushed the dev/rara/67-wasm-glcanvas-readback branch from 2865d55 to b2db2a9 Compare November 2, 2026 18:47
ramezgerges and others added 2 commits November 2, 2026 13:47
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)
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@agneszitte
agneszitte disabled auto-merge November 2, 2026 20:43
@agneszitte
agneszitte merged commit 7b47d77 into unoplatform:release/stable/6.7 Nov 2, 2026
48 of 63 checks passed
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