-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Serious performance regression on rendering the index page of stackoverflow.com_eng_all_2017-05.zim #381
Comments
I'll see if I can test a bit. Are you sure it's CSS and not SVGs causing the issue? The latter bring every browser to its knees with our current decompression engine. Anyway, I'll take a look. |
I don't think so but not 100% sure. |
Hmm, I can't really test that ZIM because it is 52GB and my home connection would be overwhelmed, or if I torrent it it'll take a few days. I accidentally downloaded |
I can't reproduce this with If you have a moment, put a break at the very beginning of the displayArticleInForm function (inside it), and inspect the html in the htmlArticle variable. How many stylesheets are in the header of the html? If they are no more than five or six, it can't be the number of CSS that is causing the issue. Search for any .svg files with ZIM URLs, because they could definitely explain the problem. Another explanation might be one malformed stylesheet or one that is stored without the terminating byte, so the decompressor gets into a loop until it reaches the end of the ZIM file... You could find the culprit by breaking inside
|
With stackoverflow.com_eng_all_2017-05.zim, it takes around 9 minutes on Chromium, but "only" around 1 minute on Firefox. In the dev tools of both browsers, they say all this time is spent in "Recalculate style". I tried with desktop kiwix : the same welcome page of stackoverflow only takes around 15 seconds to be displayed (on the same machine). There are 3 CSS in this page : -/static/bootstrap/css/bootstrap.min.css, -/static/bootstrap/css/bootstrap-theme.min.css and -/static/main.css . And no SVG. |
Before the slowdown, all items are above each other (in a vertical list). After the slowdown, they are in rectangles with borders, which seem to come from the main.css style below :
If I modify this CSS class in dev tools, it's quite fast to update, so I don't think it comes from this specific class. |
I'll continue to investigate but it might take some time because I don't always have the relevant test context with such a big ZIM file. |
Strange. Askubuntu also contains the same three CSS files. If the old layout was very complicated, I guess it's possible main.css might depend on the rules in the two bootstrap files being in place, so that if they are added in after main, they cause multiple re-draws? It's odd that this issue has surfaced with v2.3. If it's a layout issue, I can't think of anything we've changed that would affect speed of layout. We're effectively using the same insertion method as before (jQuery's I would suggest making a branch from commit 6bf87b2, seeing if the problem is there, and if not, move up through the commits, until you find at what specific point the issue occurs for the first time. Or move backwards if the problem is in that commit already. |
I think that this CSS was not injected at all in version 2.2 (I'll check). If this is confirmed, I don't understand why the same (relatively simple) CSS and the same HTML is so slow on a recent browser, where it is way faster on the very old embedded gecko engine of desktop kiwix. |
OK. Might be worth checking if we're moving something that should be in the Two last resorts come to mind:
|
I confirm that this issue starts in commit id 0faae34. In fact, in 2.2, the main.css stylesheet was correctly injected, but some styles were not applied because the |
Instead of calling displayArticleInForm like in jQuery mode. This seems to fix #381 in ServiceWorker mode.
I've made some progress. I suppose the browsers are smart enough to generate the DOM and apply the CSS styles at the same time. But, in jQuery mode, we first make the browser generate the DOM, then make it apply the CSS styles. |
Ah, that makes sense now. I think it's a lot better to let Service Worker run the whole process in Service Worker mode -- it's always been confusing that we start up Service Worker mode in that hybrid way, since we don't need to do any processing on the DOM. It sounds like a clear candidate for a PR. Regarding JQuery mode, it seems we have three possibilities:
I quite like the idea of option 3, but we should probably try option 2 first (option 2 is a step on the way to option 3 anyway). I have some code, based on master, for a persistent cache using indexedDB and/or localStorage that could complement such approaches (assets are cached per-ZIM). |
Yes, I agree for the ServiceWorker mode : I opened #382 for that. Thanks for your proposals for the jQuery mode. These are good ideas.
I would suggest to try the easiest option first, at least to check it really solves the issue. NB : let's hope ServiceWorkers will be soon widely available, because the jQuery mode forces us to do more and more dirty things like that. |
Regarding 1, I mean what we currently do (replacing all The main issue with this method is that the user could be stuck looking at a blank screen, or the spinner, longer than currently (while the CSS decompresses). That's why I suggested 2 and 3, which are just variations of 1, but showing the unstyled HTML first (more or less as we currently do), and then two different methods of injecting the CSS in one go at later points. As you say, it would be easiest to try 1 first, and then experiment. The trouble with Service Worker is that I have yet to see it work from the file.// protocol in any browser. |
OK, I've tested preloading stylesheets with this ZIM, and it makes a big difference on Firefox, Chromium and Edge. We get to a "useable" page relatively quickly on both (I say "useable" with quotation marks because most of the tags don't work). EDIT: This is because the page had stalled during rendering. The tags are useable. |
Apologies, I didn't realize I was looking at an incomplete render of the home page of this ZIM, hence my comment about gazillions of useless tags. They're not useless. I've deleted that comment. |
Cool, that's good news! I'll try to fix #382 on my side (for ServiceWorker mode). |
Fixed by #387 |
The index page (that is automatically loaded when you choose this ZIM file) is very heavy.
In version 2.2, it already took some time to load it.
But now, applying the extra CSS (that were not loaded in 2.2) takes almost 10 minutes on my computer, with the browser eating a whole CPU all this time.
It's not a bug, but the fact that we are now able to apply all CSS styles has this consequence. And it makes this ZIM file unusable.
I did not have the time to investigate more on that. It would be worth testing with the desktop version
The text was updated successfully, but these errors were encountered: