Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read PDF files from Kiwix-serve #670

Open
Popolechien opened this issue Mar 21, 2024 · 5 comments
Open

Unable to read PDF files from Kiwix-serve #670

Popolechien opened this issue Mar 21, 2024 · 5 comments
Assignees
Milestone

Comments

@Popolechien
Copy link
Member

It used to be that a user trying to access a PDF file from their mobile phone via Kiwix-serve (either directly from library.kiwix.org or from the hotspot) would be able to read them directly and without problem.

But now trying to check https://library.kiwix.org/viewer#maitre_lucas_completer_les_mots_fr_2023-05/files/compl%C3%A9ter%20les%20mots%205.pdf from my mobile leads to this:
Screenshot (21 mars 2024 12_08_12)

Phone is Nothing phone 2 running Android 14 and Google Chrome 122.0.6261.119

@kelson42
Copy link
Contributor

library.kiwix.org link works fine for me on my android. @rgaudin Do you see anything weird at http response level? Might that be that the problem is that the browser can simply nor handle properly the PDF (within the iframe)?

@kelson42 kelson42 self-assigned this Mar 21, 2024
@rgaudin
Copy link
Member

rgaudin commented Mar 21, 2024

I can reproduce on Chrome/Android but not on Firefox/Android

@rgaudin
Copy link
Member

rgaudin commented Mar 21, 2024

Refused to frame '' because it violates the following Content Security Policy directive: "frame-src 'self'".
viewer.js?cacheid=5fc4badf:282 Uncaught DOMException: Failed to read a named property 'href' from 'Location': Blocked a frame with origin "https://library.kiwix.org" from accessing a cross-origin frame.
    at handle_content_url_change (https://library.kiwix.org/skin/viewer.js?cacheid=5fc4badf:282:62)
    at on_content_load (https://library.kiwix.org/skin/viewer.js?cacheid=5fc4badf:393:5)
    at HTMLIFrameElement.onload (https://library.kiwix.org/viewer#maitre_lucas_completer_les_mots_fr_2023-05/home:77:32)
viewer.js?cacheid=5fc4badf:208 Uncaught TypeError: Cannot read properties of null (reading 'documentElement')
    at updateToolbarVisibilityState (viewer.js?cacheid=5fc4badf:208:24)
Screenshot 2024-03-21 at 14 10 04

@veloman-yunkan
Copy link
Collaborator

It turns out that since v85 and until very recently (though as an experimental feature) Chrome on Android doesn't support displaying PDF's inline.

@kelson42:

library.kiwix.org link works fine for me on my android.

This seems to suggest that (as of the time of your comment) your chrome's version was pre-85

@rgaudin:

I can reproduce [the bug] on Chrome/Android but not on Firefox/Android

My guess is that you were using a more recent version of Chrome.

Having checked that my phone runs Chrome 132 I tried to enable the experimental support for native PDF preview but when it didn't work I was surprised to find out that I am still running Android 10 (below the minimal version 12 on which that functionality is supported). Will have to use a different device for debugging/testing.

@veloman-yunkan
Copy link
Collaborator

Well, Chrome 132 on Android 14 with "Open PDF Inline" flags enabled also doesn't display PDFs (but proposes to download them) when PDF links are clicked on https://maitrelucas.fr/fiche/completer-les-mots-cp-ce1/.

Even if we manage to display PDFs inline in Chrome (132+) on Android (12+), there will be configurations where it won't work. Best we can do is to download the file (instead of attempting to load it in the iframe). I will provide a quickfix for that workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants