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>
This commit is contained in:
Brandon Jones 2020-06-16 16:55:38 +00:00 committed by Commit Bot service account
parent 59cfe3ea03
commit ac6bd4c98f
1 changed files with 8 additions and 1 deletions

View File

@ -50,6 +50,8 @@ namespace {
std::string sInjectedErrorTestcaseOutDir; std::string sInjectedErrorTestcaseOutDir;
uint64_t sOutputFileNumber = 0; uint64_t sOutputFileNumber = 0;
bool sCommandsComplete = false;
WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device, WGPUSwapChain ErrorDeviceCreateSwapChain(WGPUDevice device,
WGPUSurface surface, WGPUSurface surface,
const WGPUSwapChainDescriptor*) { const WGPUSwapChainDescriptor*) {
@ -59,6 +61,10 @@ namespace {
return sOriginalDeviceCreateSwapChain(device, surface, &desc); return sOriginalDeviceCreateSwapChain(device, surface, &desc);
} }
void CommandsCompleteCallback(WGPUFenceCompletionStatus status, void* userdata) {
sCommandsComplete = true;
}
} // namespace } // namespace
int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) { int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) {
@ -156,7 +162,8 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
wgpu::Queue queue = device.GetDefaultQueue(); wgpu::Queue queue = device.GetDefaultQueue();
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence = queue.CreateFence();
queue.Signal(fence, 1u); queue.Signal(fence, 1u);
while (fence.GetCompletedValue() != 1u) { fence.OnCompletion(1u, CommandsCompleteCallback, 0);
while (!sCommandsComplete) {
device.Tick(); device.Tick();
utils::USleep(100); utils::USleep(100);
} }