Skip to content

Invalid render pass usage leads to crashes in the WebGPU Swift backend#59661

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
rr-codes:eng/170997914
Mar 2, 2026
Merged

Invalid render pass usage leads to crashes in the WebGPU Swift backend#59661
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
rr-codes:eng/170997914

Conversation

@rr-codes
Copy link
Contributor

@rr-codes rr-codes commented Mar 1, 2026

ff519ea

Invalid render pass usage leads to crashes in the WebGPU Swift backend
https://bugs.webkit.org/show_bug.cgi?id=308471
rdar://170997914

Reviewed by Mike Wyrzykowski, Lily Spiniolas, and Abrar Rahman Protyasha.

Check that metalDepthStencilTexture is non-nil and has a sampleCount greater than 0 instead of
assuming it is non-nil and force unwrapping it. This matches the non-Swift implementation logic.

Also fix a swift-format formatting error in `USDModel.swift`.

* Source/WebGPU/WebGPU/CommandEncoder.swift:
(WebGPU.beginRenderPass(_:)):
* Source/WebKit/GPUProcess/graphics/Model/USDModel.swift:

Canonical link: https://commits.webkit.org/308434@main

744164d

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ✅ 🛠 ios-apple
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests ✅ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ✅ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ❌ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@rr-codes rr-codes self-assigned this Mar 1, 2026
@rr-codes rr-codes added the WebGPU For bugs in WebGPU label Mar 1, 2026
@lilyspiniolas
Copy link
Contributor

Is this testable?

@mwyrzykowski
Copy link
Contributor

Is this testable?

It should be covered by LayoutTests/fast/webgpu/nocrash/fuzz-283006.html but it's not clear to me that WebGPU Swift is running in EWS yet due to compiler requirements.

Copy link
Contributor

@mwyrzykowski mwyrzykowski left a comment

Choose a reason for hiding this comment

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

Thank you for fixing! :) This matches the objective-C++ backend now:

            mtlDescriptor.defaultRasterSampleCount = metalDepthStencilTexture.sampleCount;
            if (!mtlDescriptor.defaultRasterSampleCount)
                return RenderPassEncoder::createInvalid(*this, m_device, @"no color targets and depth-stencil texture is nil");
            mtlDescriptor.renderTargetWidth = metalDepthStencilTexture.width;
            mtlDescriptor.renderTargetHeight = metalDepthStencilTexture.height;

@rr-codes rr-codes added the merge-queue Applied to send a pull request to merge-queue label Mar 2, 2026
https://bugs.webkit.org/show_bug.cgi?id=308471
rdar://170997914

Reviewed by Mike Wyrzykowski, Lily Spiniolas, and Abrar Rahman Protyasha.

Check that metalDepthStencilTexture is non-nil and has a sampleCount greater than 0 instead of
assuming it is non-nil and force unwrapping it. This matches the non-Swift implementation logic.

Also fix a swift-format formatting error in `USDModel.swift`.

* Source/WebGPU/WebGPU/CommandEncoder.swift:
(WebGPU.beginRenderPass(_:)):
* Source/WebKit/GPUProcess/graphics/Model/USDModel.swift:

Canonical link: https://commits.webkit.org/308434@main
@webkit-commit-queue
Copy link
Collaborator

Committed 308434@main (ff519ea): https://commits.webkit.org/308434@main

Reviewed commits have been landed. Closing PR #59661 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit ff519ea into WebKit:main Mar 2, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebGPU For bugs in WebGPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants