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

[PWA] Printing is buggy on Safari (MacOS and iOS) #364

Open Jaifroid opened 1 year ago

Jaifroid commented 1 year ago

It works fine on Chrome and Firefox on MacOS, but fails with Safari on both MacOS and iOS. It must be that Safari doesn't implement the print() function for printing the iframe. It is possible to press Ctrl/Cmd-P, but then lazy-loaded images are not printed.

The reason we have to support Safari is because this is the only browser that is allowed to run Service Workers on iOS. If we can invoke Ctrl/Cmd-P programmatically, then this issue should be quite easy to solve.

The current workaround is to export the article to a new tab and then print that, but the user needs to disable popup blocking for the domain, and on iOS this involves finding an option deeply embedded in the browser Settings.

Jaifroid commented 1 year ago

While https://github.com/kiwix/kiwix-js-windows/commit/f32157b7579a489241f95ed0eff2d9f8fb689b5d fixes the issue with detecting the print button, and we can now launch the system print dialogue, there is an issue with lazy-loaded images not being downloaded fully prior to printing, despite the fact that there is code provided precisely to get all images. and it works on Firefox and Chromium.

However, if user scrolls to bottom to get all images, then it is possible to print them.

It seems like there might be a race condition or an issue with async getting of images before launching print dialogue.

Jaifroid commented 1 year ago

May be same cause as #311.

Jaifroid commented 1 year ago

Interestingly, printing seems to work OK on recent iPhone, with all images correctly retrieved (tested via Browser Stack).