Service Worker isn't working in Internal iframe of WebView file://

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 I couldn’t find any specification that says Service Worker-like behavior doesn’t work with this combination. Please help me answer this.

Step to reproduce:

We use Vite to develop the application.

For the iframe in Webview,

  1. Install vite-plugin-pwa with version ^0.20.5
  2. Add VitePWA({...}) to plugins[] array in vite.config.ts
  3. Build and preview the app: npm run build && npm run preview.
  4. We open a Webview with file:// and then open the iframe with the URL we have deployed the build app (We use ngrok to create the URL).
  5. 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,

  1. We open Safari browser with the URL that we have deployed the app (We use ngrok to create the URL same as above).

  2. 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.

Service Worker isn't working in Internal iframe of WebView file://
 
 
Q