WebGPUEngine initAsync function is slow

Here is the code to initialize the engine,

    const webGPUSupported = await WebGPUEngine.IsSupportedAsync;
    if (webGPUSupported) {
      const engine = new WebGPUEngine(this.canvas);
      await engine.initAsync();
      return engine;
    return new Engine(this.canvas, true, this._option);


createEngine: 120.93310546875 ms
logger.js:49 BJS - [10:07:08]: Babylon.js v6.2.0 - WebGPU1 engine
index.ts:39 initAsync: 2567.6669921875 ms

u could possibly shave a little time by doing something like

return (navigator.gpu && await new WebGPUEngine(this.canvas).initAsync ) || new Engine(this.canvas, true, this._option);

the logical or will shortcut and never be evaluated, whereas in ur current one, v8 will prep both branches.

But, one thing to consider is that webgpu and vulkan in general requires you to declare and compile stuff up front, so i think longer init time is probably unavoidable.

Also, the webgpu engine comes with twgsl, and idk if that done sequentially after calling init, but if it is, you’ll be network bound and could benefit from packaging it locally.


Yes, most of the time is probably spent downloading TWGSL, which is part of the initialization process.