Skip to content

Commit eb1d526

Browse files
authored
error_scope tests: break up awaits into chunks (#4324)
1 parent 91c7fd6 commit eb1d526

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/webgpu/api/validation/error_scope.spec.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,8 @@ Tests that an error bubbles to the correct parent scope.
8585

8686
// Cause the error and then pop all the unrelated filters.
8787
t.generateError(errorFilter);
88-
const promises = [];
89-
for (let i = 0; i < stackDepth; i++) {
90-
promises.push(t.device.popErrorScope());
91-
}
92-
const errors = await Promise.all(promises);
93-
t.expect(errors.every(e => e === null));
88+
89+
await t.chunkedPopManyErrorScopes(stackDepth);
9490

9591
// Finally the actual error should have been caught by the parent scope.
9692
const error = await t.device.popErrorScope();
@@ -126,12 +122,7 @@ Tests that an error does not bubbles to parent scopes when local scope matches.
126122
t.expect(t.isInstanceOfError(errorFilter, error));
127123

128124
// Remaining scopes shouldn't catch anything.
129-
const promises = [];
130-
for (let i = 0; i < stackDepth; i++) {
131-
promises.push(t.device.popErrorScope());
132-
}
133-
const errors = await Promise.all(promises);
134-
t.expect(errors.every(e => e === null));
125+
await t.chunkedPopManyErrorScopes(stackDepth);
135126
});
136127

137128
g.test('balanced_siblings')

src/webgpu/error_test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ export class ErrorTest extends Fixture {
8080
}
8181
}
8282

83+
/**
84+
* Pop `count` error scopes, and assert they all return `null`. Chunks the
85+
* awaits so we only `Promise.all` 200 scopes at a time, instead of stalling
86+
* on a huge `Promise.all` all at once. This helps Chromium's "heartbeat"
87+
* mechanism know that the test is still running (and not hung).
88+
*/
89+
async chunkedPopManyErrorScopes(count: number) {
90+
const promises = [];
91+
for (let i = 0; i < count; i++) {
92+
promises.push(this.device.popErrorScope());
93+
if (promises.length >= 200) {
94+
this.expect((await Promise.all(promises)).every(e => e === null));
95+
promises.length = 0;
96+
}
97+
}
98+
this.expect((await Promise.all(promises)).every(e => e === null));
99+
}
100+
83101
/**
84102
* Expect an uncapturederror event to occur. Note: this MUST be awaited, because
85103
* otherwise it could erroneously pass by capturing an error from later in the test.

0 commit comments

Comments
 (0)