Bug 263113 - browser.runtime.sendMessage not invoking service worker after Safari idle
Summary: browser.runtime.sendMessage not invoking service worker after Safari idle
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Extensions (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad iOS 17
: P2 Blocker
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-10-13 03:32 PDT by chu-vevo
Modified: 2023-10-13 03:32 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description chu-vevo 2023-10-13 03:32:01 PDT
Some info about the extension:
manifest_version: 3,
background: {
  service_worker: ...,
  type: 'module',
  persistent: false,
},

Our extension inject a button into the page which triger a call in service worker. Then the service worker returns the result with a port. Then the result is shown on the page.

The issue happens like this:
1. Open a web page and see the button injected
2. Switch to other pages, back to home screen
3. Use some other apps for some time and lock/unlock the iPhone several times
4. Return to Safari and the original webpage with button
5. Click the button, nothing happens

The content script make a browser.runtime.sendMessage() after the user click the button. An event listener in service worker listen to this call, call the API, and relay the data to content script using a port. 

After made some console.log calls, I can confirm that browser.runtime.sendMessage() did not fail or throw, which makes the content script believe the service worker is working. 

But the service worker is never brought up. I cannot see the service worker thread in macOS Safari developer menu. What made this even worse is that the service worker cannot be broought up ever once this happend once. No even restart Safari could solve this issue. Which means the only way to make the extension working again is uninstall/reinstall the iOS app. That's why I considered this is a Blocker level issue.
Comment 1 Radar WebKit Bug Importer 2023-10-13 03:32:11 PDT
<rdar://problem/116912618>