Bug 1865921 Part 1: Make WebGPUParent supply a device lost callback. r=ErichDonGubler...
commit02b7d3567c520e28ffe9970b4f417c11054f0298
authorBrad Werth <bwerth@mozilla.com>
Thu, 25 Jan 2024 23:52:24 +0000 (25 23:52 +0000)
committerBrad Werth <bwerth@mozilla.com>
Thu, 25 Jan 2024 23:52:24 +0000 (25 23:52 +0000)
treec6dcaa24c44020f5a31134936b6adfa1c34a2d18
parentc0b8f83d37009b57c8e9628df11746261d8df82d
Bug 1865921 Part 1: Make WebGPUParent supply a device lost callback. r=ErichDonGubler,webgpu-reviewers,nical

This patch makes several changes:

1) It modifies WebGPUParent::RecvAdapterRequestDevice to additionally
send a device lost callback to wgpu. The user data for this callback is
stored within WebGPUParent as a hash of unique_ptr memory, which allows
for the possibility that wgpu will not call the callback (though it
should). When the callback is received, this memory is cleared. When the
WebGPUParent is destroyed, it asserts that there is no remaining held
memory for pending callbacks. These callbacks also check a WeakPtr to
the parent as additional safety.

2) It corrects some behavior in Device::ResolveLost where checking the
existence of the underlying JS object is moved earlier, since later
operations on the promise require the JS object to exist.

Differential Revision: https://phabricator.services.mozilla.com/D194310
dom/webgpu/Device.cpp
dom/webgpu/ipc/WebGPUChild.cpp
dom/webgpu/ipc/WebGPUParent.cpp
dom/webgpu/ipc/WebGPUParent.h
gfx/wgpu_bindings/src/server.rs