Detecting WebGPU compatability/Good idea in the first place?

In my code, I am trying to do the following:

if (supportsWebGPU) {
    engine = new WebGPUEngine(canvas);
    await engine.initAsync();
else {
    engine = new Engine(canvas);

const scene = new Scene(engine);
MeshBuilder.CreateSphere("sphere", { diameter: 1 }, engine);

Whenever a users’ browser supports WebGPU, I want it to use the WebGPUEngine instead of the regular Engine. With this comes my first question: How do I detect if a users’ browser supports WebGPU?

My second quesiton is; is there a difference in the way the Engine and WebGPUEngine classes are handled? Or can you simply switch them out with the same code, like in the snippet above? (Stability aside)

Thanks in advance!

1 Like

Hi, the docs mention that only the asynchronous initialization is different and the APIs will be the same: WebGPU Support | Babylon.js Documentation

Checking whether WebGPU is supported should be possible via BABYLON.WebGPUEngine.IsSupportedAsync (a static property), according to the API docs.

Since this is a pretty basic thing to worry about when it comes to using the feature, maybe this should be covered in the WebGPU section of the docs? They seem a bit WIP and unfinished, so maybe that’s why it’s not mentioned anywhere (or it’s there and I just didn’t find the info).

Pinging @PirateJC about the docs

You can even use:


to automate it all for you. This is listed in the webgpu breaking change list of the doc as the API is a bit different from webgl which is not async.

I thought about that, but I really didn’t want to cause even more work than I already have (sorry)! :sweat_smile:

1 Like

@rdw1 @sebavan @RaananW Apologies for the late reply, thank you all so much for the help!


I really like this solution, the less lines the merrier, but the method seems to return a ThinEngine, which can not be converted to Engine or WebGPUEngine. Any clue on how to convert ThinEngine to a regular one?

1 Like

ThinEngine is a more general (abstract) class than Engine or WebGPUEngine. I don’t think it’s possible to reverse the abstraction since you’d have to add the missing functionality back in, at which point you might as well create a WebGPUEngine to begin with…

Hmm, so there is no use in using EngineFactory.CreateAsync then? Shame :confused:

Don’t take my word as gospel, I’m going purely by the info provided in the docs. It sounds like the engine returned might even have all the required functionality (if it’s supported), but you mentioned that you want a different return type. Have you tried using the ThinEngine for WebGPU features to see if it it works similarly when WebGPU is supported?

1 Like

I changed the return type of CreateAsync to Engine as I agree it is not usefull in the general case.

This will be available in the next release.

1 Like

Ah, it does seem to be working, I just messed something else up elsewhere. I guess its just a typing issue, it will be solved in the next release according to sebavan tho, thanks for the help!

1 Like