File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -752,6 +752,16 @@ if (onnxruntime_USE_WEBGPU)
752752 #
753753 ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR } /patches/dawn/safari_polyfill.patch &&
754754
755+ # The dawn_device_lost_keepalive.patch contains the following changes:
756+ #
757+ # - (private) Fix premature ABORT when device.lost fires in callUserCallback
758+ # The device.lost handler was wrapped in callUserCallback without runtimeKeepalivePush/Pop,
759+ # causing maybeExit() to trigger _exit(0) and set ABORT=true when runtimeKeepaliveCounter
760+ # was 0. This silently dropped all subsequent WebGPU callbacks (e.g. requestAdapter),
761+ # breaking session re-creation after device destruction.
762+ #
763+ ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR } /patches/dawn/dawn_device_lost_keepalive.patch &&
764+
755765 # The dawn_dxc_output_dir.patch contains the following changes:
756766 #
757767 # - (private) Fix DXC output directory for RelWithDebInfo and MinSizeRel configs
Original file line number Diff line number Diff line change 1+ diff --git a/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js b/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
2+ --- a/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
3+ +++ b/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
4+ @@ -876,9 +876,11 @@
5+ #if ASSERTIONS
6+ assert(deviceLostFutureId);
7+ #endif
8+ - // Don't keepalive here, because this isn't guaranteed to ever happen.
9+ + // Keep the runtime alive until device.lost resolves, to prevent
10+ + // maybeExit() from triggering premature ABORT during callUserCallback.
11+ + {{{ runtimeKeepalivePush() }}}
12+ WebGPU.Internals.futureInsert(deviceLostFutureId, device.lost.then((info) => {
13+ // If the runtime has exited, avoid calling callUserCallback as it
14+ // will print an error (e.g. if the device got freed during shutdown).
15+ @@ -891,6 +893,7 @@
16+ {{{ gpu.passAsPointer('messagePtr') }}});
17+ stackRestore(sp);
18+ });
19+ + {{{ runtimeKeepalivePop() }}}
20+ }));
21+
22+ // Set up uncaptured error handlers.
You can’t perform that action at this time.
0 commit comments