Do tabs go to sleep?

(Jeremiah Lee) #1

My extension sends a message from background script to content scripts (using browser.tabs.sendMessage()) running in all active tabs as determined by browser.tabs.query(). The content script in each receiving tab then modifies the DOM loaded in the tab temporarily. Much of the time, all of the tabs properly perform their DOM modifications simultaneously, as desired. However, frequently there is a tab that will react to the message much later—even 10 minutes later—when the window and tab receive focus again. This is not a desired behavior.

This behavior does not seem to be documented anywhere. Can anyone explain it to me and the intention behind it? I suspect it is some kind of performance preservation that pauses and quickly resumes tabs, like a sleep state. (This seems different than the discarded state, as the contents are still visible, loaded, and not reloaded when the window/tab receive focus.)

Also, is there any way to query tabs based on if they are not currently in this paused/sleep state?

If it helps provide context, my extension is LULO. It blanks out all of your Firefox windows for 20 seconds every 20 minutes to force you to take an eye break.