Manifest V3 introduces a new limitation to background script lifetimes that is not a problem in V2.
This stemmed from #884 which lead to #907
The new manifest will stop background scripts after 30s of non-vital activity, which is a problem if the extension - like Iridium - is designed counting on staying alive for as long as at least one YouTube page is still open.
Since the extension was not prepared for such a drastic change like this, it was necessary to revert to Manifest V2.
The changes needed in the extension are feasible and fortunately it will not require the background to be running all the time, as far as I could tell during preliminary tests.
There are two important aspects to the extension that need the background script to work properly:
Opening the extension options by pressing the Iridium button in YouTube pages
Unfortunately content scripts have very limited API access, and the API to open the extension options page is not available, for this reason a message has to be passed to the background script instructing it to open the extension options
Manipulating loaded content
This is the most important one since it allows the extension to make code changes to scripts and html loaded, without this the alternative would be not only more difficult (it would require overwriting functions and objects at the DOM level) and in some cases even impossible
For case 1, the adjustment should be easy. The content script only needs to ensure that any time it requires to communicate with the background script, the port gets connected beforehand every time it is not already connected. This automatically wakes up the background script and processes as normal.
For case 2, the listeners used to intercept the content must be set up at the top of the file. This ensures that any future events will correctly wake up the background script and be intercepted correctly.
Other than these two primary functionalities, the other one is meant to centralize data handling (user setting changes), but since content-scripts have access to the same API (local and sync) this can be migrated to them.
Tentatively targeting this for the very next version.
Manifest V3 introduces a new limitation to background script lifetimes that is not a problem in V2.
This stemmed from #884 which lead to #907
The new manifest will stop background scripts after 30s of non-vital activity, which is a problem if the extension - like Iridium - is designed counting on staying alive for as long as at least one YouTube page is still open.
Since the extension was not prepared for such a drastic change like this, it was necessary to revert to Manifest V2.
The changes needed in the extension are feasible and fortunately it will not require the background to be running all the time, as far as I could tell during preliminary tests.
There are two important aspects to the extension that need the background script to work properly:
For case 1, the adjustment should be easy. The content script only needs to ensure that any time it requires to communicate with the background script, the port gets connected beforehand every time it is not already connected. This automatically wakes up the background script and processes as normal.
For case 2, the listeners used to intercept the content must be set up at the top of the file. This ensures that any future events will correctly wake up the background script and be intercepted correctly.
Other than these two primary functionalities, the other one is meant to centralize data handling (user setting changes), but since content-scripts have access to the same API (local and sync) this can be migrated to them.
Tentatively targeting this for the very next version.