diff --git a/src/fuzzers/BUILD.gn b/src/fuzzers/BUILD.gn index 4479cef67a..71a6d88a96 100644 --- a/src/fuzzers/BUILD.gn +++ b/src/fuzzers/BUILD.gn @@ -90,6 +90,7 @@ static_library("dawn_wire_server_fuzzer_common") { "${dawn_root}/src/dawn:dawncpp", "${dawn_root}/src/dawn_native:dawn_native_static", "${dawn_root}/src/dawn_wire:dawn_wire_static", + "${dawn_root}/src/utils:dawn_utils", ] } diff --git a/src/fuzzers/DawnWireServerFuzzer.cpp b/src/fuzzers/DawnWireServerFuzzer.cpp index aa0da429c3..81be868d05 100644 --- a/src/fuzzers/DawnWireServerFuzzer.cpp +++ b/src/fuzzers/DawnWireServerFuzzer.cpp @@ -21,6 +21,7 @@ #include "dawn/webgpu_cpp.h" #include "dawn_native/DawnNative.h" #include "dawn_wire/WireServer.h" +#include "utils/SystemUtils.h" #include #include @@ -149,8 +150,17 @@ int DawnWireServerFuzzer::Run(const uint8_t* data, wireServer->HandleCommands(reinterpret_cast(data), size); - // Fake waiting for all previous commands before destroying the server. - device.Tick(); + // Wait for all previous commands before destroying the server. + // TODO(enga): Improve this when we improve/finalize how processing events happens. + { + wgpu::Queue queue = device.GetDefaultQueue(); + wgpu::Fence fence = queue.CreateFence(); + queue.Signal(fence, 1u); + while (fence.GetCompletedValue() != 1u) { + device.Tick(); + utils::USleep(100); + } + } // Destroy the server before the device because it needs to free all objects. wireServer = nullptr;