Fixes TSAN race by moving cleanup of platform into dtor.

- Before since it was in the TearDown, cleanup can be called before
  the device was gone which meant that async tasks could still be in
  flight.

Bug: dawn:1374
Change-Id: I4cd5a4e096a3fe13e230197a6a4d4d57daea31c8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133480
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
This commit is contained in:
Loko Kung 2023-05-17 22:03:16 +00:00 committed by Dawn LUCI CQ
parent 43b110ce53
commit 5ae7d10977
1 changed files with 3 additions and 3 deletions

View File

@ -739,6 +739,9 @@ DawnTestBase::~DawnTestBase() {
// Check that all devices were destructed.
EXPECT_EQ(gTestEnv->GetInstance()->GetDeviceCountForTesting(), 0u);
// Unsets the platform since we are cleaning the per-test platform up with the test case.
dawn::native::FromAPI(gTestEnv->GetInstance()->Get())->SetPlatformForTesting(nullptr);
gCurrentTest = nullptr;
}
@ -1113,9 +1116,6 @@ void DawnTestBase::TearDown() {
EXPECT_EQ(mLastWarningCount,
dawn::native::GetDeprecationWarningCountForTesting(device.Get()));
}
// Unsets the platform since we are cleaning the per-test platform up with the test case.
dawn::native::FromAPI(gTestEnv->GetInstance()->Get())->SetPlatformForTesting(nullptr);
}
void DawnTestBase::DestroyDevice(wgpu::Device device) {