Inspector WebGPU GPU Frame Time at 0

On WebGPU the frame time values are always at 0.

PG: https://playground.babylonjs.com/#HH8T00#1
^ Select WebGPU as main engine

Yes this is expected. We do not have timer queries in WebGPU (Is it supported yet @Evgeni_Popov ?)

It is supported, but Chrome must be launched with a special flag, as exposing timer queries may have security implications: --enable-dawn-features=allow_unsafe_apis

You can also set this option in chrome://flags:

Would still be nice if GPU Frame Time support was added for WebGPU in bjs, even if you’d have to toggle something in chrome flags :+1:

It is supported, just launch Chrome with the flag and you will some values for GPU frame time :slight_smile:

@Evgeni_Popov Good day, I’m new to this but I have tried what you have suggested, which is adding the flag, but I still can’t seem to get any data for the GPU Frame time. Could I be missing something?


Thank you in advance for the response.

I found the fix 5 minutes after posting this. I was missing the " enableAllFeatures: true" property in my WebGPUEngine constructor call.

Following up on this thread with Chromium 147 and Babylon 9.32.0: without the flag, the GPU frame time still reads 0, and there is a way to get it with no flag at all.

Playground: https://playground.babylonjs.com/#W2203S#1. It creates the engine with enableAllFeatures: true (as in #7), turns timing on and logs this after 3 seconds:

timestamp-query: true | typeof encoder.writeTimestamp: undefined | GPU frame time: current 0.000 ms, average 0.000 ms over 242 readings

  • WebGPUDurationMeasure stamps the frame with GPUCommandEncoder.writeTimestamp. That method is not in the WebGPU spec, and Chromium only exposes it behind allow_unsafe_apis, as said above.
  • The spec writes timestamps with timestampWrites on a pass, which only needs the timestamp-query feature, and no flag.
  • There’s a second detail: the resolve is submitted right away, ahead of the frame’s own command buffers. So even with the flag, the value read belongs to the previous measured frame.

A fix is ready as a PR:

  • The start and the end of the frame are stamped by two empty compute passes with timestampWrites.
  • The resolve goes in the frame’s encoder, and the buffer is mapped after the frame is submitted.
  • With it, the same Playground reads current 0.418 ms, average 0.526 ms over 206 readings in Chromium 147, with no flag.
  • It has four new unit tests, and the existing engine tests are unchanged.

Should I open it?

Prepared by Mema (formerly Memo), the AI of our studio 53ON (Claude in the 53ON harness, with MemoriaBios, our long-term memory), and reviewed by me.

cc @ryantrem

This sounds like changes to WebGPUEngine, so probably should get input from @Evgeni_Popov , but just opening a PR is probably the best way to show us your proposal anyway.

Opened #19066, as ryantrem suggested. The start and the end of the frame are stamped by two empty compute passes with timestampWrites, and the resolve goes in the frame’s own encoder, read once the frame is submitted. With it, the repro Playground above reads the GPU frame time in Chromium 147 with no browser flag: current 0.418 ms, average 0.526 ms over 206 readings, where 9.32.0 reads 0.

Prepared by Mema, the AI of our studio 53ON (Claude in the 53ON harness, with MemoriaBios, our long-term memory), and reviewed by me.