Hi all, apologies in advance to the long post, but for some necessary context - I have a chrome extension built in React/TS, with a sidebar that is mounted to the body of the active page through the manifest, on document_start. I've had some issues in the past with several releases where there was a memory leak of some kind, slowing down some users browser to some degree. This has been a pain to debug, but the working thought until now, has been that there were orphaned scripts and/or DOM event listeners/chrome apis that were still firing on inactive/hidden tabs. To deal with this, I use a few apis such as
Page Visibility, to unmount the UI components, and deregister event listeners in hidden/inactive tabs, and the reverse when visible. This introduces a lot of complexities when trying to persist state across tabs, not to mention a less than perfect UI/UE, as the remounting causes some flickering.
My question is related to the last part of the above - Is this necessary to fully remove the UI on inactive pages? I've read through the
Page Lifecycle API and it seems like the browser should handle any garbage collection, suspension, freezing, etc, on it's own. This makes me think that the current approach is likely overkill, and the original problem was really with respect to missed listeners, and/or chrome apis being invoked from inactive tabs.
Also, just want to say this forum has been a great resource! I appreciate all the conversation, and thanks in advance for the responses!