-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
WebGPU: "Error: Invalid Surface Status" triggered randomly #23407
Comments
The error raised from a Lines 100 to 102 in ab2ab0f
I found that reconfiguration can fix the problem: // https://deno.com/blog/v1.40#webgpu-windowing--bring-your-own-window
import {
createWindow,
mainloop,
} from "https://deno.land/x/dwm@0.3.6/mod.ts";
const width = 800;
const height = 600;
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
console.error("WebGPU not supported!");
Deno.exit(1);
}
const device = await adapter.requestDevice();
const win = createWindow({
title: "Deno Dwm WebGL",
width,
height,
});
/* Returns a Deno.UnsafeWindowSurface */
const surface = win.windowSurface();
/* Returns a WebGPU GPUCanvasContext */
const context = surface.getContext("webgpu");
context.configure({
device,
format: navigator.gpu.getPreferredCanvasFormat(),
width,
height,
});
function frame() {
// Sine wave
// console.log("Draw!");
const r = Math.sin(Date.now() / 1000) / 2 + 0.5;
const g = Math.sin(Date.now() / 1000 + 2) / 2 + 0.5;
const b = Math.sin(Date.now() / 1000 + 4) / 2 + 0.5;
let textureView;
try {
textureView = context.getCurrentTexture().createView();
} catch (e) {
console.error(e);
context.configure({
device,
format: navigator.gpu.getPreferredCanvasFormat(),
width,
height,
});
console.log("reconfigured");
return;
}
const commandEncoder = device.createCommandEncoder();
const passEncoder = commandEncoder.beginRenderPass({
colorAttachments: [
{
view: textureView,
clearValue: { r, g, b, a: 1.0 },
loadOp: "clear",
storeOp: "store",
},
],
});
passEncoder.end();
device.queue.submit([commandEncoder.finish()]);
surface.present();
}
mainloop(frame); @crowlKats Do you have any suggestions? Can we just add code in |
User should manually reconfigure the surface when a resize event occurs. Example |
Environment:
Repuroducable code:
Save it as "example.ts" and run (SDL needs to be installed in advance):
Got:
Only one success.
If replacing
deno_sdl2
withdwm
, the same error would occur:Maybe this is a wgpu bug on Xwayland? When I start my desktop environment with X11, this problem disappears.
By the way, I think it worthy of adding a
"wayland"
backend forDeno.UnsafeWindowSurface
The text was updated successfully, but these errors were encountered: