Skip to content

fix(🔺): scale WebGPUCanvas surface to device pixel resolution#3763

Open
kbrandwijk wants to merge 1 commit intoShopify:mainfrom
kbrandwijk:fix/webgpu-canvas-pixel-ratio
Open

fix(🔺): scale WebGPUCanvas surface to device pixel resolution#3763
kbrandwijk wants to merge 1 commit intoShopify:mainfrom
kbrandwijk:fix/webgpu-canvas-pixel-ratio

Conversation

@kbrandwijk
Copy link
Contributor

Summary

WebGPUCanvas was creating its surface at point dimensions instead of pixel dimensions. On high-DPI devices (e.g., iPhone 16 Pro at 3x), this resulted in a 402×874 surface instead of 1206×2622, causing blurry/low-resolution rendering.

Fix

Multiply getBoundingClientRect() dimensions by PixelRatio.get() before passing to MakeWebGPUCanvasContext. Web is excluded (scale = 1) since browser canvas handles DPR separately.

Test plan

  • Tested on iPhone 16 Pro (3x scale) — GPU overlay shows 1206×2622 after fix
  • Triangle example renders at full retina resolution
  • WebGPU compute shader output renders crisp at native resolution

Fixes #3762

WebGPUCanvas was creating its surface at point dimensions instead of
pixel dimensions. On high-DPI devices (e.g., iPhone 16 Pro at 3x),
this resulted in a 402×874 surface instead of 1206×2622.

Multiply getBoundingClientRect dimensions by PixelRatio.get() before
passing to MakeWebGPUCanvasContext. Web is excluded (scale = 1) since
browser canvas handles DPR separately.

Fixes Shopify#3762

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

WebGPUCanvas renders at point resolution instead of pixel resolution on high-DPI devices

1 participant