Commit 2e13f6b
emdawnwebgpu: Add runtimeKeepalive for device.lost handler
The device.lost handler in emwgpuAdapterRequestDevice is wrapped in
callUserCallback(), which calls maybeExit() after the callback executes.
When runtimeKeepaliveCounter is 0 (common for --no-entry WASM modules),
maybeExit() triggers _exit(0), setting ABORT=true. This causes all
subsequent callUserCallback() invocations to silently drop their
callbacks, breaking any WebGPU operations that follow (e.g.,
requestAdapter for a new session).
Fix by adding runtimeKeepalivePush() before the device.lost promise
setup, and runtimeKeepalivePop() after callUserCallback() returns
inside the .then() handler. This ensures the runtime stays alive
during the callback and maybeExit() sees counter >= 1.
The pop is placed after callUserCallback (not before) because
callUserCallback internally calls maybeExit() - if the pop happened
first, the counter would be 0 during maybeExit, still triggering the
premature exit.
Bug: onnxruntime#27427
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent ccbc9cd commit 2e13f6b
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | | - | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
913 | 915 | | |
914 | 916 | | |
915 | 917 | | |
| |||
925 | 927 | | |
926 | 928 | | |
927 | 929 | | |
| 930 | + | |
928 | 931 | | |
929 | 932 | | |
930 | 933 | | |
| |||
0 commit comments