MitchellMarkGeorge / TabButler

A tab manager at your service.
https://tabbutler.netlify.app/
MIT License
43 stars 5 forks source link

Old content script not orpahned on update #77

Closed MitchellMarkGeorge closed 2 years ago

MitchellMarkGeorge commented 2 years ago

Describe the bug This issue seems to happen mainly in production. When the extension updates, the idea is that the old content script should be cut off and can't receive any messages from the background script while a new content script is injected with the new code. While this seems to work in development (with the occasional hiccup), this does not seem to be the case in production. Sometimes after an update, it seems that 2 content scripts seem to receive messages from the background script, leading to 2 Search modals being rendered on top of each other, both being unresponsive due to the conflicting focus traps. This can be seen especially when the extension is updated manually using an update button. Here is an example:

Screen Shot 2022-08-13 at 10 59 18 PM

After exploring online and looking at the source code of other extensions with content script-based UI's, the best course of action would be to not reinject the content script into tabs. For now, this will make sure that everything renders correctly with one Search modal and might require users to manually reload their tabs after an update. A better strategy would be to update the extension when the browser is updating as well.

Expected behavior On update (however it happens), the extension should render the Search modal correctly with no duplicates in the page DOM.

Screenshots See above

Platform Info (please complete the following information):

Additional context N/A

MitchellMarkGeorge commented 2 years ago

The problem with this is that if the script is not injected into the currently open tabs, no new tabs with the updated content script can communicate with them.

After further inspection, this seems to be more of a problem on Firefox, as I was able to replicate this issue in development. More testing needs to be done in order to determine how exactly this is happening.

MitchellMarkGeorge commented 2 years ago

It seems that while Chromium-based browsers like Brave and Chrome disable communication with old content scripts, Firefox does not seem to do the same. The solutions now are to either find a way to manually disable all content scripts on update or just don't re-inject the extension on update. Right now the latter seems to be the best one to do. It would still be preferable if we could delay the extension update till the browser restarts or all windows close.

MitchellMarkGeorge commented 2 years ago

https://stackoverflow.com/questions/39124570/chrome-extension-update-flow

MitchellMarkGeorge commented 2 years ago

Might be resolved in the latest commit, need to do more testing.