This sample project reproduces a Safari Manifest 3 Browser Extension Service Worker crash, which renders the browser extension unusable.
See demo.mp4 for a screen recording of how to reproduce.
The browser extension service worker will crash, rendering the affected extension unusable.
This crash is related to the following simultaneous conditions:
- The extension is configured for Manifest 3.
- The extension is configured with a content script for a particular host.
- The user has granted the extension permission to access the content script host
- The user has navigated to an extension page, e.g.
safari-web-extension://<uuid>/index.html
- Enough time (~30 secs) has elapsed and service worker is shut down normally (status = "not loaded")
When the service worker starts up again, it will crash, resulting in status = "failed to load". It can take 2 unload/reload cycles for the crash to happen.
- Safari 16.4 (18615.1.26.110.1, 17615.1.26.101.10)
- Mac OS 13.3.1
- Xcode 14.1
> scripts/generate.sh
> scripts/build.sh
Alternatively, you can build it using Xcode App.
- Open Safari
- Allow Unsigned Extensions
- Enable the "Test App" Extension in "Safari -> Settings... -> Extensions"
- In "Safari -> Settings... -> Extensions -> Test App -> Edit Websites...". Set the value for
apple.com
to "Allow". - Open the Popup by clicking on the extension icon in the browser toolbar.
- Click on the "Open Extension Page" button. This will open the extension's
index.html
page in a new tab. (It doesn't do anything, but is required for the crash to happen.) - Perform the following steps 2 times:
- Wait 30 seconds
- Click "Safari -> Develop -> Web Extension Background Content" and notice that Service Worker status is now "not loaded". (This is expected.)
- Open the Popup and click "Send Message" this will trigger the service worker to reload.
(Tip: If you leave the popup open while you wait, the crash will happen after just one unload/reload cycle.)
The service worker fails to load, a crash error can be observed in Console App when searching for "reason=Crash", and the browser extension becomes unusable.
The service worker should start back up normally without crashing.