Closed jelmervdl closed 2 years ago
Probably best to treat pageshow
and pagehide
as load & unload, and stop any translations after pagehide
to avoid non-visible pages that keep using resources. This will require InPageTranslation to have some way to pause and resume, or see which nodes have already be translated when starting over. It will need to re-submit everything that hasn't been translated since if we treat pagehide
as an unload, the background-script will have cleared any pending requests from that page from the translation request queue.
I noticed that when you navigate between two pages that are in the cache, they both stay connected and interact with the background script.
Using pageshow and pagehide events we can treat these the same as if they are unloaded, but after a pageshow event, much of the javascript state is still there which is really odd. For example, The tab's
state
variable could betranslation-available
but the InPageTranslator could still be active from when the page waspage-is-translating
.Another effect is that when you navigate from one page to the next, and the new page is asked for a language sample, the old page will also respond. This messes with language detection.
Example: navigate to de.wikpedia.org. Then go to es.wikipedia.org. Then go back to de.wikipedia.org. It is a mess.