Running ServiceWorker in Capacitor App on iOS #5502
Replies: 5 comments 3 replies
-
Hi @merri-ment , did you end up solving this? Running into the same obstacle as well! |
Beta Was this translation helpful? Give feedback.
-
COOP/COEP heaaders are required for crossOriginIsolated capabilities, but they are not necessarily sufficient. |
Beta Was this translation helpful? Give feedback.
-
Also facing this issue and would appreciate any help from the Capacitor team or community! Particularly, we should be able to tap into the Capacitor http server and set headers as needed. |
Beta Was this translation helpful? Give feedback.
-
hey all, I'm also facing this issue while trying to enable I tested in Android Chrome opening the link below and |
Beta Was this translation helpful? Give feedback.
-
@marcelo-nagatomo Can you clarify how you were able to downgrade to a different webview in a capacitor project? My initial tests have failed and it is listed as a known incompatible plugin in the capacitor documentation. |
Beta Was this translation helpful? Give feedback.
-
tl;dr
Essentially i need to set COOP/COEP headers to enable SharedArrayBuffer functionality in my Capacitor v3 iOS App and running a ServiceWorker to set the headers is the only solution i have found so far.
Background to the problem
Both Chrome Android and Safari iOS now support SharedArrayBuffer which now means Ffmpeg.wasm can utilise multi-threading. SharedArrayBuffer requires a secure context to enable functionality, this is done by setting the following headers;
Further requirements;
I've found this problematic in Capacitor to implement.
My App is self contained (App files served locally), it doesn't require external http requests to serve the App files. This means setting the required headers server-side isn't an option.
The Work-around solution
The following solution suggests using a ServiceWorker to set the COOP/COEP headers client-side, which is exactly what i need. Enabling COOP/COEP without touching the server
The Problem
ServiceWorkers have their own set of requirements and this is where i'm stuck.
To enable this ServiceWorker API on iOS i'm using App-Bound Domains.
The following issue in github Support deploying a PWA with capacitor as native app outlines the steps required to implement App-Bound Domains in Capacitor.
Which include;
After setting App-Bound Domains i get the following error;
This happens because Capacitor apps are served from capacitor:// in iOS.
Is there anyway around this? ( that does not require serving from a remote url).
Or has anyone discovered a better approach to setting COOP/COEP headers client-side in Capacitor?
Thanks Cam
Beta Was this translation helpful? Give feedback.
All reactions