browser.runtime.onMessage in content script intermittently fails on iOS 18.5 (Safari Web Extensions)
Hi everyone,
I’m encountering a critical reliability issue with message passing in my Safari Web Extension on iOS 18.4.1 and iOS 18.5.
In my extension, I’m using the standard messaging API. The background script sends a message to the content script using browser.tabs.sendMessage(...), and the content script registers a listener via:
browser.runtime.onMessage.addListener(handler);
This setup has been working reliably in all prior versions of iOS. However, after updating to iOS 18.4.1 and 18.5, I’ve noticed the following behavior:
✅ The content script is successfully injected, and onMessage.addListener is registered (I see logging confirming this).
✅ The background script sends the message using the correct tabId (also confirmed via logs).
❌ The content script’s onMessage listener is not consistently triggered.
⚠️ This issue is intermittent, sometimes the message is received, sometimes it is silently dropped.
❌ No exceptions or errors are thrown in either script, the message appears to be sent, but not picked up from the content script message listener.