Skip to content

Commit af8045c

Browse files
committed
fix: correct comment about document.write vs srcdoc in sandbox
Update comment to accurately explain the canvas tainting issue rather than incorrectly claiming srcdoc creates an opaque origin. Follow-up to PR #234 per domfarolino's review feedback.
1 parent 6377357 commit af8045c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

examples/basic-host/src/sandbox.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ window.addEventListener("message", async (event) => {
9595
inner.setAttribute("allow", allowAttribute);
9696
}
9797
if (typeof html === "string") {
98-
// Use document.write instead of srcdoc for WebGL compatibility.
99-
// srcdoc creates an opaque origin which prevents WebGL canvas updates
100-
// from being displayed properly. document.write preserves the sandbox
101-
// origin, allowing WebGL to work correctly.
98+
// Use document.write instead of srcdoc for WebGL canvas tainting workaround.
99+
// While srcdoc iframes normally inherit the parent's origin, some browsers
100+
// treat the about:srcdoc URL as "tainted" for canvas security checks,
101+
// which breaks WebGL rendering (e.g., CesiumJS, Three.js).
102+
// Using document.write avoids this issue while preserving the sandbox origin.
102103
// CSP is enforced via HTTP headers on this page (sandbox.html).
103104
const doc = inner.contentDocument || inner.contentWindow?.document;
104105
if (doc) {

0 commit comments

Comments
 (0)