Is it a specification that the Service Worker doesn’t work in an internal iframe only when the parent page in a WebView is file://? It works in Mobile Safari under the same conditions, and we couldn’t find any specification that says Service Worker-like behavior doesn’t work with this combination.
Step to reproduce:
We use Vite to develop the application.
For the iframe in Webview,
- Install
vite-plugin-pwa
with version^0.20.5
- Add
VitePWA({...})
to plugins[] array in vite.config.ts - Build and preview the app: npm run build && npm run preview.
- We open a Webview with file:// and then open the iframe with the URL to which we preview the app (We use ngrok to create the URL).
- Then we open Safari and inspect the Webview but inside the Developer > Service workers tab doesn’t have a registered service worker.
For safari, we do the same step 1-3,
- We open Safari browser with the URL that we have deployed the app (The same URL we used in the iframe in Webview).
- We go inside the Developer > Service workers tab and it has a registered service worker.
Environment:
Simulator: IOS 18.2
Safari: MacOS 15.2
Expectation: Safari and the iframe in Webview should have a registered service worker inside the Developer > Service workers.