RESOLVED FIXED315092
Some WebGPU content not rendering in Safari
https://bugs.webkit.org/show_bug.cgi?id=315092
Summary Some WebGPU content not rendering in Safari
Ashley Gullen
Reported 2026-05-19 05:22:13 PDT
We make Construct, a browser-based game development tool (www.construct.net). Based on a customer report we have found some content that appears to render incorrectly when using WebGPU in Safari only. The same WebGPU content renders correctly in Chrome on Windows and macOS, Firefox Nightly on Windows and macOS, and Safari when rendering with WebGL, so we suspect a Safari WebGPU bug. FWIW, some of the content that does not render uses a repeat texture mode for a tiling effect, but I don't know if that's relevant to the issue. WebGL content: https://downloads.scirra.com/labs/bugs/ioswebgpu/webgl/ WebGPU content: https://downloads.scirra.com/labs/bugs/ioswebgpu/webgpu/ Observed result: Some content missing from WebGPU rendering in Safari on macOS only. This also reproduces in TP 243. Expected result: Safari on macOS to render WebGPU content the same as WebGL or Chrome/Firefox WebGPU result.
Attachments
stencilCompareAlways (251.02 KB, image/png)
2026-05-25 20:12 PDT, Mike Wyrzykowski
no flags
Radar WebKit Bug Importer
Comment 1 2026-05-19 10:08:47 PDT
Mike Wyrzykowski
Comment 2 2026-05-25 20:12:03 PDT
Created attachment 479824 [details] stencilCompareAlways Disabling stencil test, i.e., setting .stencilCompareFunction = MTLCompareFunctionAlways works around the issue
Mike Wyrzykowski
Comment 3 2026-05-25 20:25:24 PDT
Oh likely the bug is this. The spec for setStencilReference https://www.w3.org/TR/webgpu/#dom-gpurenderpassencoder-setstencilreference setStencilReference(reference) Sets the [[stencilReference]] value used during stencil tests with the "replace" GPUStencilOperation. But this site is not using replace, it's using equal. So we should ignore the value, 1, getting passed to GPURenderPassEncoder.setStencilReference
Mike Wyrzykowski
Comment 4 2026-05-25 20:32:03 PDT
This fixes the issue: % git diff ./Source/WebGPU/WebGPU/RenderPassEncoder.mm diff --git a/Source/WebGPU/WebGPU/RenderPassEncoder.mm b/Source/WebGPU/WebGPU/RenderPassEncoder.mm index 8ed3d2fb6bcf..ac7e59406b48 100644 --- a/Source/WebGPU/WebGPU/RenderPassEncoder.mm +++ b/Source/WebGPU/WebGPU/RenderPassEncoder.mm @@ -562,7 +562,7 @@ void RenderPassEncoder::setCachedRenderPassState(id<MTLRenderCommandEncoder> com } if (m_blendColor) [commandEncoder setBlendColorRed:m_blendColor->r green:m_blendColor->g blue:m_blendColor->b alpha:m_blendColor->a]; - if (m_stencilReferenceValue) { + if (m_stencilReferenceValue && m_pipeline && m_pipeline->depthStencilDescriptor().frontFaceStencil.stencilFailureOperation == MTLStencilOperationReplace) { [commandEncoder setStencilReferenceValue:*m_stencilReferenceValue]; m_stencilReferenceValue = std::nullopt; } I just need to see if I should check the back stencil face too and what to do when both front and back due not have replace.
Mike Wyrzykowski
Comment 5 2026-05-25 20:56:07 PDT
Mike Wyrzykowski
Comment 6 2026-05-26 13:55:39 PDT
So the root cause is actually: The spec says to treat undefined loadOps with read only storage as loads, but we were defaulting to clear which is wrong. landing PR shortly
EWS
Comment 7 2026-05-26 22:14:18 PDT
Committed 313943@main (442e2c0e0168): <https://commits.webkit.org/313943@main> Reviewed commits have been landed. Closing PR #65650 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.