Enable pointer lock in expanded desktop webviews: missing allow-pointer-lock sandbox token
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 32/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- html, javascript, typescript
Hướng nghiên cứu
Start with the host effect emitted by requestExpandedMode and investigate the likely renderer named in the issue: packages/components/devvit2/devvit2-surface/elements/devvit2-web-view.ts. Confirm how it creates or navigates expanded and inline frames, including sandboxed ancestors and any CSP sandbox. Done means an eligible expanded frame passes the stated acquisition, movement, release, and reacquisition checks while preserving the intended inline policy; the issue says this host implementation is outside the public repository.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Desktop Devvit games cannot use native mouse look in the expanded webview because the host iframe's sandbox omits allow-pointer-lock. This prevents continuous FPS aiming once the visible cursor reaches the screen edge.
I inspected SUBSTRIKE (app slug updraft-arena, version 0.0.56) in Reddit's expanded desktop preview on October 23, 2026. The live game iframe had:
<iframe
sandbox="allow-forms allow-same-origin allow-scripts"
allow="clipboard-write; web-share"
src="https://<app-version>-webview.devvit.net/game.html"
></iframe>
The same sandbox was present on its inline splash iframe. No application tokens or iframe name data are included here.
Proposed host change
At iframe creation/navigation time, add allow-pointer-lock for the eligible desktop expanded game view. Keep the existing sandbox tokens and the existing allow attribute.
This is the proposed attribute change, based on the observed DOM, not a patch against an available source file:
- sandbox="allow-forms allow-same-origin allow-scripts"
+ sandbox="allow-forms allow-same-origin allow-scripts allow-pointer-lock"
If the product policy is expanded-only, leave inline views restricted. Check every sandboxed ancestor as well: adding the token only to an inner game frame does not lift an ancestor's restriction. A CSP sandbox, if present, must also be checked. Apply the policy before the document loads; changing an already-loaded iframe's attribute alone is not a complete test.
The app should still request pointer lock directly from an explicit Play/canvas click in the focused game document, handle rejection, and retain the browser's standard Escape-to-release behavior. A click that opens/reloads the expanded document should not be assumed to activate that newly loaded document; a fresh click inside the game may be needed.
Why this needs a host-side change
I checked public reddit/devvit at commit 1cce4cecf009511cc2395e89b45cebb230201baf. It does not contain the host iframe renderer or a pointer-lock configuration option in the published config schema. The client requestExpandedMode code emits an effect for the host to handle.
The public development tool points to the separate Shreddit component packages/components/devvit2/devvit2-surface/elements/devvit2-web-view.ts: source reference. That is a likely place for maintainers to investigate; I could not inspect its implementation.
An app-side SDK helper or adding an invented devvit.json permission would not change the host's active sandbox. This is why I am submitting a reproduction and the host change proposal here rather than a PR claiming to fix code that is outside this public repository.
Minimal reproduction
Save the following two files in an empty directory, serve them from localhost (for example python -m http.server 8000), and open http://localhost:8000/host.html in foreground desktop Chrome. Click inside each child frame; press Escape between tests.
host.html:
<!doctype html>
<title>Pointer lock sandbox reproduction</title>
<h2>Current sandbox: expected SecurityError</h2>
<iframe
title="Current sandbox"
sandbox="allow-forms allow-same-origin allow-scripts"
src="child.html"
></iframe>
<h2>Proposed sandbox: expected lock, then Escape releases</h2>
<iframe
title="Proposed sandbox"
sandbox="allow-forms allow-same-origin allow-scripts allow-pointer-lock"
src="child.html"
></iframe>
child.html:
<!doctype html>
<title>Pointer lock child</title>
<button id="lock">Request pointer lock</button>
<pre id="result">Ready. Click the button; Escape releases.</pre>
<script>
const button = document.querySelector('#lock');
const result = document.querySelector('#result');
document.addEventListener('pointerlockchange', () => {
result.textContent = document.pointerLockElement ? 'LOCKED' : 'RELEASED';
});
document.addEventListener('pointerlockerror', () => {
if (!result.textContent.startsWith('ERROR:')) {
result.textContent = 'ERROR: pointerlockerror';
}
});
button.addEventListener('click', () => {
result.textContent = 'REQUESTING';
try {
const pending = button.requestPointerLock();
pending?.catch(error => {
result.textContent = 'ERROR: ' + error.name + ': ' + error.message;
});
} catch (error) {
result.textContent = 'ERROR: ' + error.name + ': ' + error.message;
}
});
</script>
Validation and limits
A separate local reproduction using two different localhost origins and the observed sandbox tokens produced this Chrome error when clicked:
SecurityError: Failed to execute 'requestPointerLock' on 'Element':
Blocked pointer lock on an element because the element's frame is
sandboxed and the 'allow-pointer-lock' permission is not set.
The nested-frame test also produced that SecurityError when the inner frame allowed pointer lock but the outer frame did not.
The game developer then brought the local reproduction to the foreground and manually confirmed that the permitted case displayed LOCKED. Afterward, the page displayed RELEASED and recorded relative mouse movement (movementX=-15; movementY=-3). This confirms successful acquisition, relative movement events, and subsequent release in the local permitted-frame test. It does not yet verify movement at screen edges, reacquisition, the nested-all-permitted case, or Reddit's actual host implementation.
During earlier automated control, the permitted case returned WrongDocumentError: The root document of this element is not valid for pointer lock; a focus-related precondition may be responsible. The foreground manual test succeeded. No production host change has been made.
Suggested acceptance checks:
- An eligible expanded frame permits a click to acquire pointer lock.
- Relative mouse movement continues at screen edges.
- Escape releases the pointer; a subsequent explicit click can reacquire it.
- Closing/detaching the expanded view or losing window focus releases it.
- Every sandboxed ancestor follows the intended policy.
- Inline views remain restricted if expanded-only is the chosen policy.
- Other sandbox restrictions and unsupported-browser fallbacks remain intact.
Specification: Pointer Lock 2.0 request algorithm.
I searched this repository's public issues for pointer lock, pointer-lock, pointerlock, and requestPointerLock and did not find a matching public issue. If this is already tracked elsewhere, please link it and route the host change to the appropriate frontend owner.
- Ngôn ngữ chính
- TypeScript
- Star
- 217
- Fork
- 89
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của reddit/devvit
-
redis.expireTime() returns relative TTL seconds on live host instead of Unix timestamp secondsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
Bound concurrent filesystem reads during asset discovery and source ZIP generationCó thể đã có người làm @CR29-22-2805 đã nhận 138 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Tất cả issue của reddit/devvit
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
amosblomqvist/learnharness#1141 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ranxianglei/billion-context#8319 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
tencent-connect/dsh-qqbot#148 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
JimLiu/open-artifact#126 ·
-
Claude Code: replace stub has no cut cue, a 6128 B Bash output reads as the one line `END6000`Đang mởbug repro-ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
mksglu/context-mode#1454 ·