kiwix / kiwix-js-pwa

Kiwix JS Offline Browser implemented as a Progressive Web App (PWA), and packaged as Electron, NWJS and UWP apps for Windows and Linux.
https://pwa.kiwix.org
GNU General Public License v3.0
177 stars 29 forks source link

In zimit2 ZIMs, when the content specifies opening a link in a new browser window/tab, the main app window blanks out #572

Open Jaifroid opened 6 months ago

Jaifroid commented 6 months ago

The content does load in the new tab or window (in browser), and is fully navigable, but there are no app search or navigation bars in that instance. That is as expected, but what should not happen is that the main app UI is blanked out and all navigation controls disappear.

What appears to be happening is that the app is unaware that a new tab has been opened. The Service Worker has no idea of the DOM, so can't tell which client is requesting resources. Because the app believes it is loading a local resource, it tears down the existing article in the iframe ready to receive new content, which instead goes to the new window/tab.

This does not happen if the new tab/window is one opened by the app itself as a result of a user gesture. So, to fix this, we need to handle the fact that the content will be sent by the SW to a different client. We already know how to do this in the message channel event, but it needs to be coordinated.

Jaifroid commented 6 months ago

This does not happen upstream in KJS. The article does load in a new window/tab, but the main app remains perfectly usable. So it's very much a bug/regression specific to this Repo's earlier implementation.

Jaifroid commented 6 months ago

Issue is confirmed to affect only zimit2, not zimit1 archives.