[dawn][emscripten][test] Add workaround for WASM tests startup.
- In g3, we are seeing test flakes for the first WebGPU tests
to run. This is likely a regression in Chromium, and we are
investigating further. In the meantime, this workaround works
locally in g3 to make the flake almost never happen since
the issue is believed to be a race between the tests and
Chromium startup.
Bug: 404535888
No-Try: true
Change-Id: I9085bb3e6ce62d72f2759204306462484342529c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/231678
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/src/emdawnwebgpu/tests/FuturesTests.cpp b/src/emdawnwebgpu/tests/FuturesTests.cpp
index aae545bd1..296ccea1 100644
--- a/src/emdawnwebgpu/tests/FuturesTests.cpp
+++ b/src/emdawnwebgpu/tests/FuturesTests.cpp
@@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <dawn/webgpu_cpp_print.h>
+#include <emscripten.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <webgpu/webgpu_cpp.h>
@@ -50,6 +51,14 @@
protected:
wgpu::Adapter RequestAdapter(const wgpu::RequestAdapterOptions* adapterOptions = nullptr) {
+ // TODO(crbug.com/404535888): Remove this sleep once we figure out regression.
+ static bool sSleepWorkaround = false;
+ if (!sSleepWorkaround) {
+ // Make the test sleep for an additional 2 seconds before trying to requestAdapter.
+ emscripten_sleep(2000);
+ sSleepWorkaround = true;
+ }
+
wgpu::RequestAdapterStatus status;
wgpu::Adapter result = nullptr;
EXPECT_EQ(instance.WaitAny(