Open Bug 1870699 Opened 7 months ago Updated 4 months ago

Don't poll WebGPU from a timer

Categories

(Core :: Graphics: WebGPU, defect, P3)

defect

Tracking

()

People

(Reporter: jimb, Unassigned)

References

(Blocks 1 open bug)

Details

Right now, when Firefox creates a PWebGPU IPDL parent, the WebGPUParent constructor starts a timer thread calling wgpu_core::global::device::Global::poll_all_devices, to respond to the completion of work on the GPU. This polling runs ten times a second, and probably has an unacceptable impact on battery life.

Instead, creating a WebGPUParent should start a separate thread that polls the wgpu devices only as necessary. Submitting a command buffer to a queue should dispatch a runnable to that thread (in classic Gecko style, using nsIEventTarget::Dispatch or something like it) that calls Global::device_poll, passing Maintain::WaitForSubmissionIndex with the submission index returned by the submission. This will cause the thread to block until the GPU has completed the submitted work.

Various other WebGPU operations require calling device_poll as well, and these can be handled by sending the thread appropriate runnables.

This approach should ensure that WebGPU consumes the CPU's attention only when we are actually waiting for work.

Blocks: webgpu-v1
Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.