Skip to content

Fix WebGPU bundled Dawn platform cleanup - #33526

Merged
Edward Chen (edgchen1) merged 3 commits into
mainfrom
edgchen1/dawn_platform_cleanup
Oct 22, 2026
Merged

Edward Chen (edgchen1) merged 3 commits into
mainfrom
edgchen1/dawn_platform_cleanup

Conversation

@edgchen1

@edgchen1 Edward Chen (edgchen1) commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Release and reset the bundled Dawn platform after WebGPU contexts and the cached instance are released.

The original code was leaking the DawnPlatform*.

Motivation and Context

Fix Application Verifier-reported leak.

Release and reset the bundled Dawn platform after WebGPU contexts and the cached instance are released. Retain explicit lifetime control to avoid static destruction ordering hazards while fixing the allocation reported by Application Verifier on provider unload.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9bab1fc9-3c49-4110-91c4-5097c3373dd5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The cleanup order, factory locking, and build guards support the intended lifecycle, with only a nonblocking regression-test suggestion remaining.

1 open issue
What changed in this PR

Fixes the Application Verifier-reported leak by releasing the bundled Dawn platform after WebGPU contexts and the cached instance are destroyed.

Changes:

  • Adds explicit platform deletion and reset, allowing later recreation.
  • Calls cleanup only in native bundled-Dawn builds.
  • Documents teardown ordering and concurrency requirements.
File Description
onnxruntime/​core/​providers/​webgpu/​webgpu_context.cc Invokes platform cleanup after context and instance teardown.
onnxruntime/​core/​providers/​webgpu/​webgpu_context_dawn_platform.h Declares cleanup and documents its lifetime constraints.
onnxruntime/​core/​providers/​webgpu/​webgpu_context_dawn_platform.cc Makes platform storage resettable and implements deletion.

Review effort: Balanced

Comment thread onnxruntime/core/providers/webgpu/webgpu_context.cc Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9bab1fc9-3c49-4110-91c4-5097c3373dd5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Regression coverage is needed to verify platform destruction order and successful context recreation after cleanup.

2 open issues

Review effort: Balanced

Comment thread onnxruntime/core/providers/webgpu/webgpu_context.cc
Comment thread onnxruntime/core/providers/webgpu/webgpu_instance_wrapper.h Outdated
Comment thread onnxruntime/core/providers/webgpu/webgpu_context_dawn_platform.h Outdated
Pass the instance descriptor by const reference and clarify the platform deleter documentation. Allow intentional Abseil flag retention in the Windows Debug leak checker and remove the obsolete Dawn platform suppression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5f4f7562-11aa-4473-afeb-c8e1206de604

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Resource ownership and destruction order are consistent, and the reported Windows Debug verification demonstrates detection of the original leak.

1 open issue
1 resolved since last review

Review effort: Balanced

@edgchen1
Edward Chen (edgchen1) merged commit 1f4b965 into main Oct 22, 2026
99 of 100 checks passed
@edgchen1
Edward Chen (edgchen1) deleted the edgchen1/dawn_platform_cleanup branch October 22, 2026 16:43
Edward Chen (edgchen1) added a commit that referenced this pull request Oct 22, 2026
### Description
<!-- Describe your changes. -->

This cherry-picks the following commits for the release:

| Commit ID | PR Number | Commit Title |
|-----------|-----------|-------------|
| 1f4b965 | #33526 | Fix WebGPU bundled Dawn platform cleanup |
| 2297e77 | #33226 | Fix WASM Debug external-data test failures |

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

WebGPU EP release.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot-Session: 9bab1fc9-3c49-4110-91c4-5097c3373dd5
Copilot-Session: 5f4f7562-11aa-4473-afeb-c8e1206de604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants