Use webgpu for initialization, but after rendering the scene a few more times it will display :8888/#/screen/17540… 2af33e895048f7e88:1 Uncaught (in promise) RangeError: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instance error, so I want to make a bottom line scheme, after capturing this error, use webgl mode to render, but I can not capture, the code is as follows
async createEngine(dom: HTMLCanvasElement) {
if (dom) {
try {
const webgpuSupported = await BABYLON.WebGPUEngine.IsSupportedAsync;
if (webgpuSupported) {
this.engine = await new BABYLON.WebGPUEngine(dom);
await (this.engine as BABYLON.WebGPUEngine).initAsync();
} else {
console.warn(
“WebGPU is not supported. Falling back to standard Babylon.js engine.”
);
this.engine = new BABYLON.Engine(dom, true);
}
} catch (error) {
throw new Error(error as string);
}
return this.engine;
} else {
throw new Error(“dom element missing”);
}
}
Does initAsync return a message about whether the creation was correct or not, which is to use webgl to load, but now returns void regardless of whether it was successful or not, how should I capture the corresponding creation result, or is there an attribute for me to make a judgment
Do not repeat the creation many times, maybe I have a shader to write dynamic sky box is more memory consuming? I thought so. try… catch… It will work, but it won’t catch initAsync errors, so I would say does the engine instance have any indication that it failed to create