Service worker is killed when Device memory usage is high. But service worker doesn't return after memory is freed up on device

We have a Safari browser extension experiencing an issue we believe the be caused by an iOS bug.

The issue is affecting physical devices, particularly iPads with low amounts of RAM. When RAM usage goes up, iOS appears to kill the Service Worker to free up memory. Then, even after the RAM usage has gone down, the Service Worker does not come back. The only way to bring it back is for the user to manually disable and re-enable the extension, meaning any functionality that required the Service Worker to function remains broken.

We have been able to reliably reproduce this crash on multiple mobile devices

We do not see any memory leaks or particularly high usage, but we do see low memory warnings. The worker appears to be killed when RAM usage hits approx. 80%.

Note that this is NOT related to the normal lifecycle of a service worker, once the background process is killed the connection is completely severed and it can not recover on its own.

We think we are experiencing a similar problem with our extension service worker being killed and never restarted, resulting in users essentially having the extension silently disabled.

It sounds like you have been able to reproduce the problem, can you share more info about how you were able to do this? We are very interested in trying to reproduce.

Same for us :( I posted some crash logs through Feedback Assistant awhile back for our case but haven't received any response. Have you found any workaround? Also how are you monitoring the memory usage specifically?

Any updates from folks? We recently started encountering this problem. The service worker seems to silently fail, breaking our extension. In our case, it sometimes starts working again (like a day later). Disabling and re-enabling the extension does fix it.

+1. My users are reporting this too - toggling off and on the extension in Safari settings seems to fix it. C'mon Apple.

Up exactly the same issue here, no info no errors just death :)

Did anybody find a solution for this problem?

I think I experienced exactly the same issue just now, and after some attempts, here is a possibly working workaround (not a good solution though): replace the background.service_worker with background.scripts in manifest.json, like:

{
    ...
    "background": {
        "service_worker": "background.js"
    },
   ...
}

replaced by:

{
    ...
    "background": {
        "scripts": [
            "background.js"
        ],
        "persistent": false
    },
   ...
}

I tested several times, the listeners registered in background.js can always continue working after RAM usage reaches 80%.

Service worker is killed when Device memory usage is high. But service worker doesn't return after memory is freed up on device
 
 
Q