dawn::wire::client Don't special case device destruction to happen first
This used to be necessary because the client's Devices could hold
references to other objects which needed to reach 0 before the objects
where removed from lists. This is no longer necessary now that objects
handle their own destruction.
Bug: 344963953
Change-Id: I505c0e6d39d0063dc12853c76b32fb12e0559be2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/197454
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp b/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp
index be8c670..742ae58 100644
--- a/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp
+++ b/src/dawn/tests/unittests/wire/WireDisconnectTests.cpp
@@ -162,19 +162,14 @@
DeleteClient();
- // Expect release on all objects created by the client. Note: the device
- // should be deleted first because it may free its reference to the default queue
- // on deletion.
- Sequence s1, s2, s3, s4, s5;
- EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, nullptr, nullptr))
- .Times(1)
- .InSequence(s1, s2);
- EXPECT_CALL(api, DeviceRelease(apiDevice)).Times(1).InSequence(s1, s2, s3, s4, s5);
- EXPECT_CALL(api, QueueRelease(apiQueue)).Times(1).InSequence(s1);
- EXPECT_CALL(api, CommandEncoderRelease(apiCommandEncoder)).Times(1).InSequence(s2);
- EXPECT_CALL(api, SamplerRelease(apiSampler)).Times(1).InSequence(s3);
- EXPECT_CALL(api, AdapterRelease(apiAdapter)).Times(1).InSequence(s4);
- EXPECT_CALL(api, InstanceRelease(apiInstance)).Times(1).InSequence(s5);
+ // Expect release on all objects created by the client.
+ EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, nullptr, nullptr)).Times(1);
+ EXPECT_CALL(api, DeviceRelease(apiDevice)).Times(1);
+ EXPECT_CALL(api, QueueRelease(apiQueue)).Times(1);
+ EXPECT_CALL(api, CommandEncoderRelease(apiCommandEncoder)).Times(1);
+ EXPECT_CALL(api, SamplerRelease(apiSampler)).Times(1);
+ EXPECT_CALL(api, AdapterRelease(apiAdapter)).Times(1);
+ EXPECT_CALL(api, InstanceRelease(apiInstance)).Times(1);
FlushClient();
// Signal that we already released and cleared callbacks for |apiDevice|
diff --git a/src/dawn/wire/client/Client.cpp b/src/dawn/wire/client/Client.cpp
index 6ded2cd..639f5e9 100644
--- a/src/dawn/wire/client/Client.cpp
+++ b/src/dawn/wire/client/Client.cpp
@@ -69,19 +69,7 @@
}
void Client::UnregisterAllObjects() {
- // Free all devices first since they may hold references to other objects
- // like the default queue. The Device destructor releases the default queue,
- // which would be invalid if the queue was already freed.
- while (!mObjects[ObjectType::Device].empty()) {
- ObjectBase* object = mObjects[ObjectType::Device].head()->value();
- object->Unregister();
- }
-
for (auto& objectList : mObjects) {
- ObjectType objectType = static_cast<ObjectType>(&objectList - mObjects.data());
- if (objectType == ObjectType::Device) {
- continue;
- }
while (!objectList.empty()) {
ObjectBase* object = objectList.head()->value();
object->Unregister();