Skip to content

feat(play): delegate WebGPU to game iframes via Permissions-Policy - #114

Merged
yusufkaraaslan merged 1 commit into
mainfrom
feat/webgpu-permissions-policy
Aug 4, 2026
Merged

yusufkaraaslan merged 1 commit into
mainfrom
feat/webgpu-permissions-policy

Conversation

@yusufkaraaslan

Copy link
Copy Markdown
Owner

Problem

The webgpu Permissions Policy defaults to self, which blocks sandboxed/opaque-origin (no --games-domain) and cross-origin (games.*) game iframes from reaching 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.

Changes

  • frontend/index.html — iframe allow="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 global securityHeaders middleware sets, since c.Header overwrites rather than appends — dropping them would have silently widened the game sandbox.

Test

TestServe_GameHTMLDelegatesWebGPU pins three things:

  • the webgpu=* delegation is present on game HTML,
  • the baseline restrictions survive alongside it,
  • the HTML-only Permissions-Policy is absent on non-HTML assets.

go test ./... passes clean.

🤖 Generated with Claude Code

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.
@yusufkaraaslan
yusufkaraaslan merged commit 2ab2d39 into main Aug 4, 2026
2 checks passed
@yusufkaraaslan
yusufkaraaslan deleted the feat/webgpu-permissions-policy branch August 4, 2026 04:43
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.

1 participant