test_runner.js: fix heartbeat code disrupting async behavior
The way we injected heartbeats meant we were returning a userspace
promise to the CTS, rather than the real one from the browser.
Modify this so that we attach heartbeats to the promise, but still
return the original promise object. This fixes
`webgpu:api,validation,buffer,mapping:` tests that were testing the
exact behavior of the API (task vs. microtask).
There's a small chance this will fix some other tests, too.
I've removed the code that was supposed to trigger a heartbeat both
before and after the responding code. It would not have worked:
resolve() doesn't run the awaiting code, it just marks the promise as
resolved, so both heartbeats ran before. I tried fixing it, but it made
some tests very slow, so I've just removed the second heartbeat. I don't
think it's that useful; it only helps on slow synchronous code.
Fixed: 42241427
Change-Id: I4995c3518f1dc5d05524a0155f601f9103891d8d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/233954
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/webgpu-cts/compat-expectations.txt b/webgpu-cts/compat-expectations.txt
index cac5d33..84dee2b 100644
--- a/webgpu-cts/compat-expectations.txt
+++ b/webgpu-cts/compat-expectations.txt
@@ -427,11 +427,6 @@
crbug.com/42241454 [ intel-0x9bc5 linux mesa_ge_23.2 ] webgpu:api,operation,storage_texture,read_write:basic:format="r32uint";shaderStage="fragment";textureDimension="3d";depthOrArrayLayers=2 [ Failure ]
crbug.com/42241454 [ intel-0x9bc5 linux mesa_ge_23.2 ] webgpu:shader,execution,memory_model,atomicity:atomicity:memType="atomic_storage";testType="inter_workgroup" [ Failure ]
-# Failures due to splitting off worker tests (crbug.com/330501141)
-crbug.com/42241427 webgpu:api,validation,buffer,mapping:mapAsync,earlyRejection: [ Failure ]
-crbug.com/42241427 webgpu:api,validation,buffer,mapping:mapAsync,state,mappingPending: [ Failure ]
-crbug.com/42241427 [ linux ] webgpu:api,validation,buffer,mapping:getMappedRange,state,mappingPending: [ Failure ]
-
crbug.com/341282603 [ intel-0x4680 linux ] webgpu:api,operation,command_buffer,queries,occlusionQuery:occlusion_query,alpha_to_coverage:writeMask=0;* [ Failure ]
crbug.com/341282605 [ intel-0x4680 linux ] webgpu:shader,execution,limits:switch_case_selectors: [ Failure ]
diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt
index 343c57e..9715f0b 100644
--- a/webgpu-cts/expectations.txt
+++ b/webgpu-cts/expectations.txt
@@ -532,12 +532,6 @@
# Failures from initially enabling tests on ChromeOS volteer (crbug.com/340815322)
crbug.com/342602625 [ chromeos chromeos-board-volteer ] webgpu:web_platform,canvas,readbackFromWebGPUCanvas:onscreenCanvas,uploadToWebGL:format="rgba16float";* [ Failure ]
-
-# Failures due to splitting off worker tests (crbug.com/330501141)
-crbug.com/42241427 [ webgpu-no-worker ] webgpu:api,validation,buffer,mapping:mapAsync,state,mappingPending: [ Failure ]
-crbug.com/42241428 [ webgpu-no-worker ] webgpu:api,validation,buffer,mapping:getMappedRange,state,mappingPending: [ Failure ]
-crbug.com/42241428 [ webgpu-no-worker ] webgpu:api,validation,buffer,mapping:mapAsync,earlyRejection: [ Failure ]
-
# Failures due to enabling codecs on bots (crbug.com/41490478)
crbug.com/41490478 [ dawn-backend-validation intel-0x4680 ubuntu webgpu-adapter-default ] webgpu:web_platform,copyToTexture,video:copy_from_video:* [ Failure ]
crbug.com/41490478 [ dawn-backend-validation intel-0x4680 ubuntu webgpu-adapter-default ] webgpu:web_platform,external_texture,video:importExternalTexture,sample:* [ Failure ]
diff --git a/webgpu-cts/test_runner.js b/webgpu-cts/test_runner.js
index 6f24738..72d4da5 100644
--- a/webgpu-cts/test_runner.js
+++ b/webgpu-cts/test_runner.js
@@ -141,15 +141,12 @@
function wrapPromiseWithHeartbeat(prototype, key) {
const old = prototype[key];
prototype[key] = function (...args) {
- return new Promise((resolve, reject) => {
- // Send the heartbeat both before and after resolve/reject
- // so that the heartbeat is sent ahead of any potentially
- // long-running synchronous code awaiting the Promise.
- old.call(this, ...args)
- .then(val => { sendHeartbeat(); resolve(val) })
- .catch(err => { sendHeartbeat(); reject(err) })
- .finally(sendHeartbeat);
- });
+ const promise = old.call(this, ...args);
+ // Send a heartbeat just before any code that was waiting on the promise.
+ promise.finally(sendHeartbeat);
+ // Return the original promise so we don't interfere with the behavior
+ // of the API itself.
+ return promise;
}
}