Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lint.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ SET TIMEOUT: webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/me
SET TIMEOUT: webauthn/*timeout.https.html
SET TIMEOUT: webdriver/*
SET TIMEOUT: webmessaging/*
SET TIMEOUT: webnn/resources/utils.js
SET TIMEOUT: webrtc-encoded-transform/script-metadata-transform-worker.js
SET TIMEOUT: webrtc-encoded-transform/script-transform-generateKeyFrame.js
SET TIMEOUT: webrtc-encoded-transform/script-transform-sendKeyFrameRequest.js
Expand Down
17 changes: 15 additions & 2 deletions webnn/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,21 @@ async function getContext() {
try {
context = await navigator.ml.createContext(contextOptions);
} catch (e) {
throw new AssertionError(
`Unable to create context for ${variant} variant. ${e}`);
// A previous test case may kill the GPU process on which the WebNN service
// runs. If you call `createContext` again immediately before the GPU
// process restarts, it will fail again. So wait a moment and retry.
if (e.message.includes('WebNN service connection error.')) {
await new Promise(resolve => setTimeout(resolve, 3000));
try {
context = await navigator.ml.createContext(contextOptions);
} catch (retryError) {
throw new AssertionError(
`Unable to create context for ${variant} variant on retry. ${retryError}`);
}
} else {
throw new AssertionError(
`Unable to create context for ${variant} variant. ${e}`);
}
}
return context;
}
Expand Down