Cannot read property 'requestDevice' of null

Viewed 1574

im trying to render web GPU shader object in WebGpu

and it returning this error

Uncaught (in promise) TypeError: Cannot read property 'requestDevice' of null at cube.html:28

this is my code to the requestDevice

(async () => {
 

    const [adapter, glslang] = await Promise.all([
        navigator.gpu.requestAdapter(),
        import("https://unpkg.com/@webgpu/glslang@0.0.7/web/glslang.js").then(m => m.default())
    ]);

    const device = await adapter.requestDevice();
    
    const canvas = document.getElementById("webgpu-canvas");
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;

});

any idea to fix this error ??

1 Answers

After trying many things, I fixed it by re-enabling the --enable-unsafe-webgpu flag in about:flags !

Refreshing the page worked before that a couple of times but then stopped... it seems to be fine now!

Related