dawn_wire: Return early in callbacks after the server is destroyed

After the server is destroyed, the server's can't do anything like
forward callbacks to the client. Track this with a weak_ptr and
return early if it has expired.

It also updates device destruction in dawn_native so the lost
callback is always called, even on graceful destruction. This
is consistent with the rest of WebGPU where all callbacks are
guaranteed to be called in finite time.

Bug: chromium:1147416, chromium:1161943
Change-Id: Ib80dea36517401a2b8eafb01ded255ebbe757aef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35840
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Austin Eng
2021-01-05 08:37:08 +00:00
committed by Commit Bot service account
parent e3fd026108
commit 200941c797
8 changed files with 200 additions and 146 deletions

View File

@@ -86,6 +86,13 @@ void WireTest::TearDown() {
// cannot be null.
api.IgnoreAllReleaseCalls();
mWireClient = nullptr;
if (mWireServer) {
// These are called on server destruction to clear the callbacks. They must not be
// called after the server is destroyed.
EXPECT_CALL(api, OnDeviceSetUncapturedErrorCallback(_, nullptr, nullptr)).Times(Exactly(1));
EXPECT_CALL(api, OnDeviceSetDeviceLostCallback(_, nullptr, nullptr)).Times(Exactly(1));
}
mWireServer = nullptr;
}
@@ -110,6 +117,13 @@ dawn_wire::WireClient* WireTest::GetWireClient() {
void WireTest::DeleteServer() {
EXPECT_CALL(api, QueueRelease(apiQueue)).Times(1);
if (mWireServer) {
// These are called on server destruction to clear the callbacks. They must not be
// called after the server is destroyed.
EXPECT_CALL(api, OnDeviceSetUncapturedErrorCallback(_, nullptr, nullptr)).Times(Exactly(1));
EXPECT_CALL(api, OnDeviceSetDeviceLostCallback(_, nullptr, nullptr)).Times(Exactly(1));
}
mWireServer = nullptr;
}