Skip to content
Open
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
5 changes: 4 additions & 1 deletion third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,9 @@ var LibraryWebGPU = {
#if ASSERTIONS
assert(deviceLostFutureId);
#endif
// Don't keepalive here, because this isn't guaranteed to ever happen.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually on second thought, I'm not sure this fix is right. This removed comment was about preventing the runtime from being kept alive forever just because a device hasn't been lost.

I might need to consult with Emscripten folks to figure out how to do this correctly. It's somehow interacting poorly with EXIT_RUNTIME=0 but I don't understand Emscripten would set ABORT = true in the way you described.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest I am not 100% sure about this part. The fix works in my specific usage (onnxruntime-web, which defines EXIT_RUNTIME=0), but not tested in other use case.

// Keep the runtime alive until device.lost resolves, to prevent
// maybeExit() from triggering premature ABORT during callUserCallback.
{{{ runtimeKeepalivePush() }}}
WebGPU.Internals.futureInsert(deviceLostFutureId, device.lost.then((info) => {
// If the runtime has exited, avoid calling callUserCallback as it
// will print an error (e.g. if the device got freed during shutdown).
Expand All @@ -925,6 +927,7 @@ var LibraryWebGPU = {
{{{ gpu.passAsPointer('messagePtr') }}});
stackRestore(sp);
});
{{{ runtimeKeepalivePop() }}}
}));

// Set up uncaptured error handlers.
Expand Down
Loading