mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-11 22:44:04 +00:00
Track and destroy all child objects on wire client destruction
This is needed so that:
1. We can support multiple devices in the wire. The device will need
to know how to destroy its child objects.
2. The wire needs to be aware of all objects and their in-flight
callbacks so that it can reject them if the wire is disconnnected.
A future change will handle this.
3. Fix leaks of objects on page teardown. When the page is torn down,
the wire client is destroyed, and we skip calling release() for all
objects since the object holding the proc table was also destroyed.
Bug: dawn:384, dawn:556
Change-Id: Ie23afe4e515b02e924fcfc2db92b749fd2257c9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31160
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
f3c8290472
commit
3120d5ea0d
@@ -126,3 +126,27 @@ TEST_F(WireDisconnectTests, DisconnectThenServerLost) {
|
||||
EXPECT_CALL(mockDeviceLostCallback, Call(_, _)).Times(Exactly(0));
|
||||
FlushServer();
|
||||
}
|
||||
|
||||
// Test that client objects are all destroyed if the WireClient is destroyed.
|
||||
TEST_F(WireDisconnectTests, DeleteClientDestroysObjects) {
|
||||
WGPUSamplerDescriptor desc = {};
|
||||
wgpuDeviceCreateCommandEncoder(device, nullptr);
|
||||
wgpuDeviceCreateSampler(device, &desc);
|
||||
|
||||
WGPUCommandEncoder apiCommandEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice, nullptr))
|
||||
.WillOnce(Return(apiCommandEncoder));
|
||||
|
||||
WGPUSampler apiSampler = api.GetNewSampler();
|
||||
EXPECT_CALL(api, DeviceCreateSampler(apiDevice, _)).WillOnce(Return(apiSampler));
|
||||
|
||||
FlushClient();
|
||||
|
||||
DeleteClient();
|
||||
|
||||
// Expect release on all objects created by the client.
|
||||
EXPECT_CALL(api, QueueRelease(apiQueue)).Times(1);
|
||||
EXPECT_CALL(api, CommandEncoderRelease(apiCommandEncoder)).Times(1);
|
||||
EXPECT_CALL(api, SamplerRelease(apiSampler)).Times(1);
|
||||
FlushClient();
|
||||
}
|
||||
|
||||
@@ -113,6 +113,10 @@ void WireTest::DeleteServer() {
|
||||
mWireServer = nullptr;
|
||||
}
|
||||
|
||||
void WireTest::DeleteClient() {
|
||||
mWireClient = nullptr;
|
||||
}
|
||||
|
||||
void WireTest::SetupIgnoredCallExpectations() {
|
||||
EXPECT_CALL(api, DeviceTick(_)).Times(AnyNumber());
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ class WireTest : public testing::Test {
|
||||
dawn_wire::WireClient* GetWireClient();
|
||||
|
||||
void DeleteServer();
|
||||
void DeleteClient();
|
||||
|
||||
private:
|
||||
void SetupIgnoredCallExpectations();
|
||||
|
||||
Reference in New Issue
Block a user