Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/2.x] fix(uno): Ensure that the canvas' context is active when rendering #2560

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
this.currentRequest = window.requestAnimationFrame(() => {

if (this.requestRender) {
// make current for this canvas instance
GL.makeContextCurrent(this.glCtx);

this.requestRender();
}

Expand Down Expand Up @@ -178,12 +181,12 @@
throw `No <canvas> with id ${canvasOrCanvasId} was found`;
}

var ctx = SKSwapChainPanel.createWebGLContext(canvas);
if (!ctx || ctx < 0)
this.glCtx = SKSwapChainPanel.createWebGLContext(canvas);
if (!this.glCtx || this.glCtx < 0)
throw `Failed to create WebGL context: err ${ctx}`;

// make current
GL.makeContextCurrent(ctx);
GL.makeContextCurrent(this.glCtx);

// Starting from .NET 7 the GLctx is defined in an inaccessible scope
// when the current GL context changes. We need to pick it up from the
Expand All @@ -196,7 +199,7 @@
// read values
this.canvas = canvas;
return {
ctx: ctx,
ctx: this.glCtx,
fbo: currentGLctx.getParameter(currentGLctx.FRAMEBUFFER_BINDING),
stencil: currentGLctx.getParameter(currentGLctx.STENCIL_BITS),
sample: 0, // TODO: currentGLctx.getParameter(GLctx.SAMPLES)
Expand Down