Repository navigation
feat(play): delegate WebGPU to game iframes via Permissions-Policy - #114
Merged
Merged
Conversation
The `webgpu` Permissions Policy defaults to `self`, which blocks sandboxed/opaque-origin (no --games-domain) and cross-origin (games.*) game iframes from navigator.gpu. Without explicit delegation, Godot-WebGPU exports see "WebGPU unavailable" and never boot. The dwalter/godotwebgpu fork doesn't need SharedArrayBuffer or cross-origin isolation (single queue, main thread only, frame-deferred async readback), so this delegation was the remaining PlayMore-side gate. frontend/index.html: iframe `allow="webgpu"` (parent-side delegation). handlers/games.go: `Permissions-Policy: ..., webgpu=*` on game HTML (child-side defense-in-depth; preserves the baseline camera/mic/... restrictions that the global securityHeaders middleware sets, since c.Header overwrites rather than appends). Test: TestServe_GameHTMLDelegatesWebGPU pins the webgpu=* delegation, the baseline restriction preservation on HTML, and the absence of the HTML-only Permissions-Policy on non-HTML assets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
webgpuPermissions Policy defaults toself, which blocks sandboxed/opaque-origin (no--games-domain) and cross-origin (games.*) game iframes from reachingnavigator.gpu. Without explicit delegation, Godot-WebGPU exports see "WebGPU unavailable" and never boot.The dwalter/godotwebgpu fork doesn't need SharedArrayBuffer or cross-origin isolation (single queue, main thread only, frame-deferred async readback), so this delegation was the remaining PlayMore-side gate.
Changes
frontend/index.html— iframeallow="webgpu"(parent-side delegation).internal/handlers/games.go—Permissions-Policy: ..., webgpu=*on game HTML responses (child-side defense-in-depth).The header preserves the baseline
camera=(), geolocation=(), microphone=()etc. restrictions that the globalsecurityHeadersmiddleware sets, sincec.Headeroverwrites rather than appends — dropping them would have silently widened the game sandbox.Test
TestServe_GameHTMLDelegatesWebGPUpins three things:webgpu=*delegation is present on game HTML,Permissions-Policyis absent on non-HTML assets.go test ./...passes clean.🤖 Generated with Claude Code