Skip to content

bug: SharedArrayBuffer support #6182

@marcelo-nagatomo

Description

@marcelo-nagatomo

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.6.1
  @capacitor/core: 4.6.1
  @capacitor/android: 4.6.1
  @capacitor/ios: 4.6.1

Installed Dependencies:

  @capacitor/android: not installed
  @capacitor/cli: 4.6.1
  @capacitor/core: 4.6.1
  @capacitor/ios: 4.6.1

Platform(s)

  • iOS

Current Behavior

I'm using the latest Cornerstone.js for scan/image viewing which heavily uses SharedArrayBuffer.

To enable SharedArrayBuffer I need to set the following Response headers at the top HTML Document level, - capacitor://localhost for iOS:

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin

After digging into the code, it seems capacitor-ios uses WebKit UrlSchemeHandler to load the local files via capacitor://localhost and it always set some Response headers as default. e.g. "Cache-Control": "no-cache":

Screen Shot 2022-12-21 at 12 04 00 am

Screen Shot 2022-12-21 at 12 05 38 am

However, these default headers (or even the 200 status code) are not included in the initial files loaded to launch the app:
Screen Shot 2022-12-20 at 11 40 52 pm

Since I cannot set custom Response headers at the top level, I cannot use SharedArrayBuffer in Ionic apps.

Expected Behavior

All Reponse headers set on WebViewAssetHandler should be included on all files loaded during app initialisation.

Code Reproduction

The code reproduction can be found here: https://github.com/marcelo-nagatomo/capacitor-issue-6182

Other Technical Details

npm --version output: 8.19.2

node --version output: v16.18.1

pod --version output (iOS issues only): 1.11.2

iOS version: 15.2

Additional Context

Similar issue was previously reported: #4520

I'm also investigating the same issue on Cordova, on that case the WKWebView initially loads with correct headers but the WebView is reloaded at some point and the Response headers information is lost. I'm not sure if the same happens in Capacitor though.

More info on COOP/COEP headers: https://web.dev/why-coop-coep/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions