Fix race condition in shader validation tests#4597
Fix race condition in shader validation tests#4597diegodelatoba wants to merge 1 commit intogpuweb:mainfrom
Conversation
Combines GPU error scope validation and compilation info checks into a single sequential async operation to prevent non-deterministic error message ordering. This fixes intermittent test failures where error messages would appear in different orders across test runs due to parallel async execution.
|
@greggman is there a race in the current logic? We see errors print in different orders based on promise resolution and the spec says: https://www.w3.org/TR/webgpu/#dom-gpudevice-poperrorscope says:
or am I missing something and is the test currently guaranteed to be deterministic? |
|
I'm not seeing the race but I'm terrible at seeing races 😅 The first check just expects that eventually the compilation validation succeeds or fails. Regardless, it will immediately and synchronously return a shader module. The 2nd check is that you can call I don't see a race about which order those are expected happen. The test seems like it allows them happening in any order @diegodelatoba where do you see the race? |
@greggman From my understanding the race isn't about which check happens first since those can happen in any order. Perhaps "race" was not the correct wording here but the issue here is that currently there is non-deterministic error message printing in the test output. What I found is that |
ok, that makes more sense to me. I wouldn't expect to see logs get interleaved, there's still only one JS thread. But, the order individual tests get logged might be different. I wonder if it would be better to order the outputs at a lower level. As it is, it looks like the code calls throwing out ideas
I'm leaning toward something more like 1. There aren't that many calls to Or maybe we can just make this change for this test. I'd be nice to get @kainino0x's feedback. |
|
The ordering of test logs is definitely not meant to be deterministic, because it can always depend on things in the browser that have nondeterministic orders. We can certainly make some common code more deterministic, but it'll always be possible to write a test with nondeterministic logs. Let me make sure I'm understanding the issue correctly.
In which case you could only be running into log ordering on failing tests. So is the issue that tests that are expected to fail in WebKit have nondeterministic error logs, so your test infra can't verify that they are failing in the expected way? (If my memory is still accurate about how WebKit's failure expectations work) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
At least not for the WebGPU CTS or many other WebKit tests
Both passing and failing tests print logs.
Like for https://gpuweb.github.io/cts/standalone/?q=webgpu:shader,validation,expression,binary,add_sub_mul:* for instance, we pass all the tests, but sometimes it seems we complete test case So the pass lines are out of order and the expected result is not necessarily equal to a prior run. But if this is not guaranteed or expected in general from WebGPU's CTS then I think it would be on WebKit to change our test runner. |
I didn't realize this, I thought you ran the WPT-compatible build using your WPT infra. Is the code open source where I could take a look to understand a bit better? It'll be useful for me in the future.
Ah, if it's just about the ordering of the "subcase ran" messages (as those seem to be the only logs in this test) then I think we can fix that generally. (Depending on how you run tests, there may also be "case passed" logs - those should already be in order, but if not that would be fixable too.) |
Changes:
expectCompileResultimplementations to use a singleeventualAsyncExpectationthat executes GPU validation and compilationchecks sequentially
let shaderModuletoconst shaderModulefor better code qualityTesting:
Verified in WebKit with 500 consecutive test runs with no failures (previously
failed around iteration 15-304).
Note: This is a test infrastructure bug fix, not related to a spec change.
No CTS project tracker issue is required.
Requirements for PR author:
.unimplemented()./** documented */and new helper files are found inhelper_index.txt.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.