Bug 424324 - Plasma Integration slowing down firefox on gitlab.com
Summary: Plasma Integration slowing down firefox on gitlab.com
Status: REPORTED
Alias: None
Product: plasma-browser-integration
Classification: Plasma
Component: Firefox (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Kai Uwe Broulik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-17 10:10 UTC by Nicolas Morel
Modified: 2020-07-22 14:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Slow down warning (7.80 KB, image/png)
2020-07-17 10:10 UTC, Nicolas Morel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Morel 2020-07-17 10:10:16 UTC
Created attachment 130198 [details]
Slow down warning

SUMMARY

I'm often getting the attached warning when browsing some gitlab.com pages, especially on diff or merge request pages. 

STEPS TO REPRODUCE
I don't really know, it seems to happen more on medium to large diffs, but it's not consistent on any given page.

OBSERVED RESULT
Frozen tab for a few seconds.

EXPECTED RESULT
No warning.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Firefox: Nightly 80.0a1 (2020-07-16) (64-bit)
Plasma Integration: 1.7.5
Comment 2 Nate Graham 2020-07-17 15:16:18 UTC
Mitigated or fully resolved?
Comment 3 Kai Uwe Broulik 2020-07-17 19:41:04 UTC
Mitigated. GitLab isn't particularly efficient in how they do the Ajax and page rendering, so it'll still trip the mutation observer excessively.
Comment 4 Nicolas Morel 2020-07-18 00:20:19 UTC
I don't know the ins and outs of this extension at all, but wouldn't it be possible to make the mutation observer use requestIdleCallback to schedule that work for a later time when the browser is less busy? The addedNodes loop would just need to make sure the nodes are still attached.
Comment 5 Nicolas Morel 2020-07-18 00:50:26 UTC
Otherwise, I don't know if this comment (https://stackoverflow.com/a/38882022) is still true to this day, but maybe querySelectorAll should be avoided? A quick benchmark (https://jsperf.com/getelementsby-vs-queryselectorall/7) on my Firefox shows getElementsBy* being at least 100 times faster, Chrome also shows lower but similar results, hopefully it'll be the same on real world pages.
Comment 6 Kai Uwe Broulik 2020-07-18 06:55:55 UTC
Very good ideas! The code is admittedly a bit messy. If you want you can give it a poke, here's the relevant code: https://invent.kde.org/plasma/plasma-browser-integration/-/blob/master/extension/content-script.js#L557
Comment 7 Nicolas Morel 2020-07-21 22:39:15 UTC
So I've been running a custom build including both patches for 3 days, I don't know if it's a placebo effect or not, but Firefox feels much smoother and responsive across the board now, and I've seen no issue so far. Do you think it's worth implementing the idle suggestion or is it enough as it is? I don't know if it's worth the complexity.
Comment 8 Nicolas Morel 2020-07-22 14:58:24 UTC
And I spoke too soon :) I just had it for a brief moment on a massive diff on gitlab, but it's definitely an improvement as it's not stuck for several seconds. I guess my previous question still stands.