The reason for this hardline stance is rooted in how COEP: require-corp functions. Once this header is active, the browser enforces a strict rule: every single cross-origin subresource—every image, script, or iframe loaded from a different domain—must explicitly opt in to being embedded by providing its own Cross-Origin-Resource-Policy (CORP) header or via CORS. If a third-party service has not updated its infrastructure to include these headers, the browser will silently block the resource from loading.
For a tool where the primary value proposition is "your file never leaves the tab," breaking the user’s ability to sign in via Google or GitHub, or preventing the loading of essential scripts, was deemed an unacceptable cost for a boost in inference speed. In this context, the "honest engineering call" was to prioritize the stability of the entire application over the performance of a single, albeit heavy, feature.
Implementing a Graceful Fallback
To manage this reality, the developers implemented a detection mechanism to ensure the application remains functional even when multi-threading is unavailable. By checking the globalThis.crossOriginIsolated property, the application can determine at runtime whether the environment supports SharedArrayBuffer.
The implementation involves pinning the model to a single thread when isolation is absent. As seen in the project’s source code, the configuration explicitly sets ort.env.wasm.numThreads = 1 if the site is not isolated. This prevents the WASM module from attempting a threaded initialization that would inevitably fail or hang, leading to a broken user experience.
Rather than presenting the user with an error message, the application displays a "compatibility mode" notification. This informs the user that while the tool is functional, it is not running at its theoretical maximum speed. This approach transforms a potential hard failure into a graceful degradation, ensuring that the tool remains accessible to the widest possible audience, including those on browsers or network configurations where isolation headers might cause issues.
The "Credentialless" Alternative and the Safari Caveat
The debate around cross-origin isolation recently took a turn with the introduction of a third option: COEP: credentialless. This newer header was designed specifically to address the pain points of the require-corp directive.
Under credentialless, cross-origin subresources are allowed to load without the resource itself sending a CORP header. To maintain security, the browser strips these requests of any sensitive information, such as cookies or authentication tokens. In theory, this allows developers to achieve cross-origin isolation—and thus unlock SharedArrayBuffer—without breaking every third-party embed on the page.
