Skip to content

[web] Fix 2 bugs in emdawnwebgpu (patches dawn)#27641

Open
fs-eire wants to merge 3 commits intomainfrom
fs-eire/patch-dawn-em
Open

[web] Fix 2 bugs in emdawnwebgpu (patches dawn)#27641
fs-eire wants to merge 3 commits intomainfrom
fs-eire/patch-dawn-em

Conversation

@fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Mar 13, 2026

Description

Fix 2 bugs in emdawnwebgpu.

  1. Fix incorrect handling for device lost. See also:

  2. Fix wrong call to WGPUBufferImpl constructor. See also:

@fs-eire fs-eire force-pushed the fs-eire/patch-dawn-em branch from 35bee1c to c04f11d Compare March 14, 2026 03:22
@fs-eire fs-eire changed the title [web] fix device lost handler [web] Fix 2 bugs in emdawnwebgpu (patches dawn) Mar 14, 2026
@fs-eire fs-eire requested a review from Copilot March 14, 2026 03:34
@fs-eire fs-eire marked this pull request as ready for review March 14, 2026 03:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ONNX Runtime’s Dawn (emdawnwebgpu) patch set to address two upstream bugs impacting WebGPU on Emscripten, and wires those patches into the Dawn FetchContent patch pipeline.

Changes:

  • Add a patch to keep the Emscripten runtime alive until device.lost resolves, avoiding premature ABORT that can drop subsequent callbacks.
  • Add a patch to fix importJsBuffer creating WGPUBufferImpl with the wrong constructor by disambiguating the “injection” constructor path.
  • Apply both new patches during Dawn dependency setup in onnxruntime_external_deps.cmake.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmake/patches/dawn/dawn_device_lost_keepalive.patch Patches library_webgpu.js to add runtimeKeepalivePush/Pop around the device.lost handler.
cmake/patches/dawn/dawn_buffer_fix_injection.patch Patches webgpu.cpp to adjust WGPUBufferImpl injection constructor usage for JS-imported buffers.
cmake/external/onnxruntime_external_deps.cmake Adds the new Dawn patches to the patch command sequence with explanatory comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +780 to +782
# tagged with kImportedFromJS. This removes the unused WGPUBufferMapState parameter
# from the injection constructor so emwgpuCreateBuffer correctly uses it, ensuring
# imported buffers are properly tagged as kImportedFromJS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants