Fix fuzzer hang when waiting for fence signal after device loss
When the fuzzer passes the command DeviceLoseForTesting, the
DawnWireServerFuzzer will hang forever when waiting for a fence signal
because the device was lost. This commit sets a callback on device loss
which gives an extra condition to break the hang.
Bug: dawn:444
Change-Id: I0157358ed6da39cc6fcab7e1be8a3d5fde74266f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23141
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Natasha Lee <natlee@microsoft.com>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
diff --git a/src/fuzzers/DawnWireServerFuzzer.cpp b/src/fuzzers/DawnWireServerFuzzer.cpp
index 81be868..1a70f18 100644
--- a/src/fuzzers/DawnWireServerFuzzer.cpp
+++ b/src/fuzzers/DawnWireServerFuzzer.cpp
@@ -50,6 +50,8 @@
std::string sInjectedErrorTestcaseOutDir;
uint64_t sOutputFileNumber = 0;
+ bool sCommandsComplete = false;
+
WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device,
WGPUSurface surface,
const WGPUSwapChainDescriptor*) {
@@ -59,6 +61,10 @@
return sOriginalDeviceCreateSwapChain(device, surface, &desc);
}
+ void CommandsCompleteCallback(WGPUFenceCompletionStatus status, void* userdata) {
+ sCommandsComplete = true;
+ }
+
} // namespace
int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) {
@@ -156,7 +162,8 @@
wgpu::Queue queue = device.GetDefaultQueue();
wgpu::Fence fence = queue.CreateFence();
queue.Signal(fence, 1u);
- while (fence.GetCompletedValue() != 1u) {
+ fence.OnCompletion(1u, CommandsCompleteCallback, 0);
+ while (!sCommandsComplete) {
device.Tick();
utils::USleep(100);
}