Repository navigation
Conversation
Collaborator
Author
|
This won't work because it breaks embeds like YouTube, which was the original reason for implementing #3028 |
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.
Motivation for the change, related issues
This PR explores fixing the Gutenberg editor iframe loading in Playground when cross-origin isolation headers are in play. This is an exploration, not intended to be merged as-is — it's meant to document the problem, the interactions between DIP/COEP/COOP and service workers, and a working fix that can inform a proper solution.
When Gutenberg's client-side media processing experiment is enabled, WordPress sends
Cross-Origin-Embedder-Policy: credentiallesson wp-admin pages. Playground's service worker rewrites this toDocument-Isolation-Policy: isolate-and-credentialless(DIP). This creates a new agent cluster, causing child iframes to lose their service worker controller — the browser restarts the navigation in a different browsing context group.The result: the editor iframe (
/wp-includes/empty.html, a synthetic page served by the service worker) gets a second request that bypasses the SW entirely, hits the dev server, and 404s. The block editor fails to load.Implementation details
All changes are in
packages/playground/remote/service-worker.ts.1. Disable DIP rewriting
rewriteCoopHeadersToDocumentIsolationPolicy()now records the COEP value in aMapbut returns the response unchanged — no more rewriting COEP/COOP → DIP. The DIP code path is left in place (dead code after an earlyreturn) so it can be re-enabled later.With plain COEP (no COOP), same-origin child iframes keep their service worker controller.
2. Serve matching COEP on empty.html
emptyHtml()now mirrors the parent page's COEP value (from thescopesWithCrossOriginIsolationmap). Without this, the browser blocks the iframe withERR_BLOCKED_BY_RESPONSEbecause a COEP parent requires children to also have COEP. We intentionally use COEP only — not COOP (which would swap browsing context groups) and not DIP (which would lose the SW controller).Trade-off
Without DIP,
crossOriginIsolatedisfalseon wp-admin pages, soSharedArrayBufferisn't available. Gutenberg handles this gracefully — it falls back to server-side media processing. The DIP feature detection code is still in place and can be re-enabled when Chrome fixes the DIP + service worker interaction.Open questions
Testing Instructions
npm run devto start the dev server🤖 Generated with Claude Code