fix(web): cap /play canvas at the real 2048 wgpu limit (corrects #97) #98
Reference in New Issue
Block a user
Delete Branch "fix/web-canvas-cap-2048-constant"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Corrects #97, which would not have fixed the crash.
The 1440p question
Nothing hardcodes 1440p. The
2560×1440in the panic is the reporter's logical viewport: a 3840×2160 display at 150% scaling → devicePixelRatio 1.5 →3840÷1.5 = 2560,2160÷1.5 = 1440. Withscale_factor_override(1.0)the surface is sized to that logical viewport.Why #97 was wrong
#97 capped the canvas wrapper to
gl.MAX_TEXTURE_SIZE— the hardware limit. On a 4K/integrated GPU that reports 8192+, so the wrapper was never capped and the 2560-wide surface still exceeded the limit → same panic.The real ceiling is wgpu's, not the hardware's. On wasm, Bevy creates the device with
Limits::downlevel_webgl2_defaults()(forced byWgpuSettingsPriority::WebGL2insolitaire_web/src/lib.rs; confirmed inbevy_render-0.18.1/src/settings.rs:85), whosemax_texture_dimension_2dis a fixed 2048 regardless of GPU. That's why the panic says "maximum extent … is 2048" even on a 4K-capable machine.Fix
Cap the wrapper at the constant 2048. Reporter's surface 2560×1440 → 2048×1440 → within the limit. HTML-only, no wasm rebuild.
Trade-off / follow-ups
Any viewport over 2048 logical px now letterboxes (centered, black bars). On a 4K@150% that's 2048 of 2560 → ~256px bars each side. Two ways to improve, both needing a real-browser test:
max_texture_dimension_2din lib.rs (up to the adapter's real max) so capable GPUs render full-res — riskier (can fail device creation on true-2048 GPUs / interact with WebGL2 shader limits).⚠️ Still can't browser-test here — needs Rhys to hard-reload
/playafter deploy and confirm it renders (letterboxed) instead of panicking.🤖 Generated with Claude Code