Verify event page wakeup with runtime.onMessage/onConnect/onMessageExternal/onConnectExternal listener
Categories
(WebExtensions :: General, task, P1)
Tracking
(firefox120 fixed)
| Tracking | Status | |
|---|---|---|
| firefox120 | --- | fixed |
People
(Reporter: robwu, Assigned: robwu)
References
(Blocks 1 open bug)
Details
(Whiteboard: [addons-jira])
Attachments
(1 file)
An event page should wake up as soon as a top-level listener is triggered. This is especially important with runtime.onMessage, runtime.onConnect, runtime.onMessageExternal, runtime.onConnectExternal, because these are often called by an independent external trigger (in a content script or other extension). Because the caller (runtime.sendMessage / runtime.connect) are independent of the recipient, the likelihood of the event page being suspended is higher than usual.
These listeners are currently not persisted after an event page suspends, which means that runtime.connect / runtime.sendMessage will unexpectedly not wake up the event page.
The logic existed before, but was removed in https://hg.mozilla.org/mozilla-central/rev/7f4f1d605c69b3a471727810b6fc876187e8211e (bug 1624235). This made sense at the time because back then there was no support for non-persistent background pages. Now we need to restore the functionality (not necessarily with the same implementation).
Updated•2 years ago
|
| Assignee | ||
Comment 1•2 years ago
|
||
Upon taking a closer look, the issue is not as bad as I thought.
While there is no explicit support for persistent listeners of the extension messaging APIs, the background is awakened as desired when a message is sent, due to https://searchfox.org/mozilla-central/rev/7fe1954b761abeff36122b4a6ac74619704ee787/toolkit/components/extensions/ExtensionParent.sys.mjs#332.
Because the call is unconditional, it doesn't require persistent listeners for the system to work. However, it also means that extension events are delayed (blocked on event page startup) even if the background does not have a listener. This is suboptimal but could be tackled later if desired.
For now, I'll resolve this ticket by adding unit tests that verify the behavior, and add some comments in the right locations.
| Assignee | ||
Comment 2•2 years ago
|
||
Comment 4•2 years ago
|
||
| bugherder | ||
Description
•