kiwix-js icon indicating copy to clipboard operation
kiwix-js copied to clipboard

Error displaying content on Kiwix-JS

Open ghost opened this issue 5 years ago • 17 comments

@IPECORE commented on Aug 18, 2020, 12:58 PM UTC:

navigation is not clear and black background black background navigation is not clear

This issue was moved by kelson42 from openzim/openedx#120.

ghost avatar Aug 25 '20 08:08 ghost

@satyamtg commented on Aug 18, 2020, 1:34 PM UTC:

Okay I see. I think you're using the KiwixJS based browser extension in jQuery mode. I tried and active content doesn't work there. I get all the issues that you opened while using jQuery mode in browser extension. It appears to me that active content is not supported in browser extensions in jQuery mode. Am I right @rgaudin @kelson42 ?

ghost avatar Aug 25 '20 08:08 ghost

@rgaudin commented on Aug 18, 2020, 1:54 PM UTC:

Yes, @IPECORE and @Popolechien please don't use kiwix-js for testing as this is not supported/tested the same way. Let's use a shared online library for those tests. Will also prevent testing different versions of the ZIM file

ghost avatar Aug 25 '20 08:08 ghost

@kelson42 commented on Aug 18, 2020, 2:33 PM UTC:

@rgaudin Should we move ticket to kiwix/kiwix-js?

ghost avatar Aug 25 '20 08:08 ghost

@satyamtg commented on Aug 18, 2020, 2:40 PM UTC:

@rgaudin @kelson42, running this on Kiwix Chrome Extension in service worker mode, it takes forever to load (probably due to large number of scripts and dynamic content). Also, loading of images and video fails with many failures logged in console.

Screenshot from 2020-08-18 19-20-30

On Kiwix desktop and Kiwix-Serve though, that works fine.

ghost avatar Aug 25 '20 08:08 ghost

@kelson42 commented on Aug 25, 2020, 8:31 AM UTC:

The problem is still visible with https://download.kiwix.org/zim/mooc/phzh_core-english-one_en_2020-08.zim. Moving to Kiwix JS.

ghost avatar Aug 25 '20 08:08 ghost

@Jaifroid @mossroy We believe this is a problem with Kiwix JS itself, but it would be good to confirm please.

kelson42 avatar Aug 25 '20 08:08 kelson42

Ironically, this ZIM works better in jQuery mode than SW mode... In jQuery mode, the sub-pages load correctly and the videos can be played. In Kiwix JS Windows, a prompt allows the user to download each module's video and play with a different app if they wish.

In SW mode, the landing page loads correctly, but any subsequent pages take literally minutes to load during which the app appears completely blank, and then videos refuse to load. Additionally, on clicking on one of the content links, something in the enclosed JavaScript attempts to rewrite the top window, and this overwrites the Kiwix JS UI, making any kind of subsequent navigation impossible.

So, while we could say the issue is with the reader, there is also an issue with the way the dynamic page loading code is written. But it's very hard to diagnose: pausing on all exceptions did not yield any useful clues to me.

However, the bottom line is that the ZIM is usable in jQuery mode (currently still the default mode) even if it doesn't have all bells and whistles. This is actually a slight surprise to me. NB I didn't test for the existence of other dynamic content (i.e. other than videos).

Jaifroid avatar Aug 25 '20 09:08 Jaifroid

Another reason why this ZIM might be failing is that assets are incorrectly located in the Article namespace. In other words, it's not a valid ZIM archive in terms of the specification, and Kiwix JS follows the specification closely. See screenshot.

image

Jaifroid avatar Aug 25 '20 13:08 Jaifroid

Interesting, there might be a bug in scraperlib for the namespace assignation. Will check.

rgaudin avatar Aug 25 '20 14:08 rgaudin

Downloaded that files and tested all of those unexpected URLs. Those are all in the I/ namespace.

files = [
"assets/audio_default.png",
"assets/fontawesome/webfonts/fa-brands-400.svg",
"assets/fontawesome/webfonts/fa-brands-400.woff",
"assets/fontawesome/webfonts/fa-brands-400.woff2",
"assets/fontawesome/webfonts/fa-regular-400.svg",
"assets/fontawesome/webfonts/fa-regular-400.woff",
"assets/fontawesome/webfonts/fa-regular-400.woff2",
"assets/fontawesome/webfonts/fa-solid-900.svg",
"assets/fontawesome/webfonts/fa-solid-900.woff",
"assets/fontawesome/webfonts/fa-solid-900.woff2",
"assets/fonts/opensans/open-sans-v17-vietnamese_latin-ext_latin_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff",
]

for file in files:
    print(reader.get_article(f"I/{file}"))
ReadArticle(url=I/assets/audio_default.png, title=assets/audio_default.png)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-brands-400.svg, title=assets/fontawesome/webfonts/fa-brands-400.svg)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-brands-400.woff, title=assets/fontawesome/webfonts/fa-brands-400.woff)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-brands-400.woff2, title=assets/fontawesome/webfonts/fa-brands-400.woff2)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-regular-400.svg, title=assets/fontawesome/webfonts/fa-regular-400.svg)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-regular-400.woff, title=assets/fontawesome/webfonts/fa-regular-400.woff)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-regular-400.woff2, title=assets/fontawesome/webfonts/fa-regular-400.woff2)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-solid-900.svg, title=assets/fontawesome/webfonts/fa-solid-900.svg)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-solid-900.woff, title=assets/fontawesome/webfonts/fa-solid-900.woff)
ReadArticle(url=I/assets/fontawesome/webfonts/fa-solid-900.woff2, title=assets/fontawesome/webfonts/fa-solid-900.woff2)
ReadArticle(url=I/assets/fonts/opensans/open-sans-v17-vietnamese_latin-ext_latin_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff, title=assets/fonts/opensans/open-sans-v17-vietnamese_latin-ext_latin_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff)

Either your tool is wrong or we're testing a different ZIM file. Can you check again? I used the URL above.

rgaudin avatar Aug 26 '20 09:08 rgaudin

Hmm. Sorry about that, I'll check. Why do they appear in the title pointer index? This should only have article titles, not asset URLs. This is probably what's causing the confusion with the title-reading tool, but I'll check.

Jaifroid avatar Aug 26 '20 10:08 Jaifroid

It seems those articles have titles while they should not. Investigating that.

rgaudin avatar Aug 26 '20 10:08 rgaudin

@rgaudin I've checked, and yes those assets are indeed in I namesapace. Apologies, I should have checked more thoroughly before making that assertion. Arguably woff font files perhaps don't belong in the I namespace, but it's marginal if they are in fact being used to produce images.

But none of this probably impacts on the difficulties with reading the ZIM in Service Worker mode in Kiwix JS. There must be some attached JS code that overwrites the top-level document, which is accessible to the iframe because it is same-origin. Since this code doesn't run in jQuery mode (which simply ignores all JS assets), it would explain why the file is readable in jQuery mode, but not when we attach and run all the included scripts.

Jaifroid avatar Aug 26 '20 10:08 Jaifroid

It seems those articles have titles while they should not. Investigating that.

Please don't spend too long on this! I can't remember how the Archive Index is coded in that tool. It shouldn't be showing assets if they don't have a title entry, but it is possible that they creep in. It also certainly isn't the issue with Kiwix JS failing on this ZIM.

Jaifroid avatar Aug 26 '20 10:08 Jaifroid

There is an issue with extraneous code showing on the bottom of most pages:

image

The reason for this seems to be the premature end of commented-out script blocks:

image

Jaifroid avatar Aug 26 '20 10:08 Jaifroid

It seems those articles have titles while they should not. Investigating that.

FYI, this is not a problem in ZIM, there are no title there. It's the libzim returning URL

See _dirent.h#L84.

const std::string& getTitle() const     { return title.empty() ? url : title; }

rgaudin avatar Aug 26 '20 11:08 rgaudin

FYI, this is not a problem in ZIM, there are no title there. It's the libzim returning URL

See _dirent.h#L84.

const std::string& getTitle() const     { return title.empty() ? url : title; }

OK, sorry to have sent you on a wild goose chase...

Jaifroid avatar Aug 26 '20 12:08 Jaifroid

No longer seems to be an issue with latest phzh_core-english-one_en_2022-01.zim in either Kiwix JS PWA or Kiwix JS Browser Extension.

Jaifroid avatar Sep 05 '23 08:09 Jaifroid