I’m looking into non-persistent background scripts, for (improved?) Android support.
The docs say:
“However, a background page does not unload until all visible views and message ports are closed.”
What are “message ports”? Are they the thing that
runtime.connect() gives you (which is documented as returning a
runtime.Port)? Because if I make such a connection, I see the background script unload* and break my functionality – which depends on the port being connected as long as the content page has a reference to it. ( https://github.com/greasemonkey/greasemonkey/issues/3173#issuecomment-1810597347 ) But the BG script unloading disconnects the port.
* I think! I can’t directly observe this because if I inspect the extension, i.e. to observe a log about the thing unloading, instead Firefox doesn’t unload the non-persistent script. (And logs that this is what it did (not do).) But in this (console open, BG not unloaded) case, my functionality does not break, so I’m pretty confident non-persistent-script-unloading is the cause.
So is an open message/port/connection supposed to prevent unloading the BG script? Is that what the quoted part of the docs are trying to communicate?