uBlockOrigin / uBlock-issues

This is the community-maintained issue tracker for uBlock Origin
https://github.com/gorhill/uBlock
919 stars 78 forks source link

slowing down browser (site issue) #3091

Closed ghajini closed 7 months ago

ghajini commented 7 months ago

Prerequisites

I tried to reproduce the issue when...

Description

when i visit https://alliptvlinks.com/iptv-m3u-lists/ on firefox ,after a while browser becomes unresponsive & crashes saying ublock origin is slowing down the browser, stop that extension there's antiadb but that can be solved later after solving this bug

The firefox profile => https://gofile.io/d/NrJQ6j

A specific URL where the issue occurs.

https://alliptvlinks.com/iptv-m3u-lists/

Steps to Reproduce

  1. visit https://alliptvlinks.com/iptv-m3u-lists/
  2. wait for website to load complete
  3. antiadb kicks in( => this can be solved later ,first bug needs to be fixed)
  4. now wait for some seconds
  5. a native dialogue from firefox kicks in saying ublock origin is slowing down the browser ,stop that extension
  6. now refresh the browser ,but its kind of unresponsive
  7. sometimes you need to refresh the website in order to reproduce
  8. On firefox android browser ,there's too much slowness such that there's lag

Expected behavior

no slowness of browser and normal performance

Actual behavior

browser crashes & firefox saying ublock origin is slowing down the browser, stop that extension Screenshot (296)

uBO version

1.55.1.14 & 1.55

Browser name and version

firefox 122.0 & firefox android 121.1.0

Operating System and version

win10 & android

Notes

ghajini commented 7 months ago

seems to be this happen with adguard browser extension also so overall, its related to website slowing down firefox browser when adblocking active but it doesn't happen on chrome, i will report this to bugzilla

mapx- commented 7 months ago

I cannot reproduce the issue on FF desktop.

ghajini commented 7 months ago

I cannot reproduce the issue on FF desktop.

disable quick fixes list, you will reproduce(scroll a bit on website) notice memory spiked 99% in task manager so win10 also crashes

gwarser commented 7 months ago

https://share.firefox.dev/3SsjvTp

ghajini commented 7 months ago

@gwarser did you reproduced?

gwarser commented 7 months ago

Yes. Looks like for some reason cookie dialog is removed and anti ad block in mutation observer is reinserting it back (.rc-panel). But it's the same file and I have no idea why the cookie dialog is marked as removed. Thought maybe it's Firefox cookiebanner removal setting, but does not seem to be enabled in stable where I'm testing.

Rob--W commented 7 months ago

I was pinged to take a look at this issue. For posterity, the JS file of the site that triggers the issue is https://pastebin.com/H6wWh78y

In the profile from https://github.com/uBlockOrigin/uBlock-issues/issues/3091#issuecomment-1907863481, I can see that a considerable amount of time is spent in DOM mutations and GC. Based on the source code and the functionality here, that is not too surprising: the website continuously tries to restore any removed DOM nodes, and I suppose that ad blockers try to remove these, which is effectively an infinite loop.

Here is a self-contained test case that does something similar but without any throttling whatsoever, for comparison: https://jsfiddle.net/qg3fsbc0/ When I run this example in a new Firefox profile, I can observe a seemingly unbounded memory growth in the profiler: https://share.firefox.dev/3S5INFs

Here is a slight variation of the test case: https://jsfiddle.net/71q3Lgd8/. Instead of removing nodes immediately in the MutationObserver callback, I debounce it with setTimeout. Now it also has memory growth, but also stops occasionally to collect garbage (like the original test case in this report): https://share.firefox.dev/3UeBsGs

gorhill commented 7 months ago

i will report this to bugzilla

What's the bugzilla entry?

ghajini commented 7 months ago

i will report this to bugzilla

What's the bugzilla entry?

sorry i can't report because my account(bugzilla) related problems

gorhill commented 7 months ago

I was able to reproduce at first but now I am unable. Are there filters in uBO which have changed to prevent the issue?

Also, I can't see any filters in uBO which causes DOM nodes to be removed on that site, so I wonder what is removing the node -- could be an issue in the site's code itself.

ghajini commented 7 months ago

disable quick fixes list & then use firefox with STR provided

gorhill commented 7 months ago

disable quick fixes list & then use firefox with STR provided

Right, still cannot reproduce no matter how often I reload the tab.

ghajini commented 7 months ago

i can consistently reproduce the issue on firefox desktop i have ubo logger & dashboard opened

here's my profile from fx android = https://profiler.firefox.com/public/6geh3740e8aqj1n3h2vabjg0tq3gk9r2apkrvh8

garry-ut99 commented 7 months ago

i can consistently reproduce the issue on firefox desktop

Same here, it's eating 1 cpu core constantly + huge memory leak constantly (incerasing +120MB per second), I've stopped recording at 12 GB RAM eaten, because it was pointless to continue., as seen: there are 2 similiar messages: one saying "it's website slowing down browser " and the other saying "it's uBlock Origin slowing down browser" they keep switching alternately all the time, as the website and the extension were interrupting each other. Closing the website tab in browser causes the issue to be gone after 10-20 secs. I haven't recorded the profile, as my only intention was to show general fell & look of the issue, also like everbody at the moment, I'm not sure whether it's a website, an extension, a filter, or a browser to be blamed for the issue, it needs to be investigated, here is ANIMATION:

Nagrywaj_2024_01_24_22_19_27_910

gorhill commented 7 months ago

The issue is caused by the site's code repeatedly moving one single element from one position to another, forever.

When moving that one single element from one position to another (both positions are children of the body element), Firefox triggers one mutation event with two mutations: one as a removed node, another one as an added node, both being the same element => div.rcc-panel.group.rcc-panel-fixed.

The site's code appears to make the assumption that when moving an element from one position to another, an event with a single mutation should occur, where both the addedNodes and removedNodes would be for the same element. I am guessing this was tested on Chromium-based browser and that the assumption works for such browser.

However with Firefox there is one event with two mutations, one for the removal, one for the addition. In that case, the site re-add the "removed" node according to its original nextSibling value, which means it will be put back to where it was moved from. And so it toggles the element forever between two positions in the DOM on each mutation event.

Position 1: image

Position 2: image

Code which causes the issue, it inserts back to where it was moved from -- nextSibling points to the position before it was moved: image

Note that the mutation observer handler makes the assumption that a moved node will result in one single mutation where both removedNodes and addedNodes are not empty:

//check only removal here!
if (
    mutation.removedNodes.length > 0 &&
    mutation.addedNodes.length == 0
)

image

The content blockers' mutation observer ends up being called back non-stop forever too, but their mutation observer can't be faulted here, the flaw is in the site's code.

I could trigger the faulty code path without a content blocker extension, but with Enhanced Tracking Protection set to Strict, and NextDNS DNS-based content blocker (they have a free trial easy to set up).

https://profiler.firefox.com/public/sxk3318j2d7rfb4p5ezq9k3tsnndxs1d5pxy29g/calltree/?globalTrackOrder=01&implementation=js&thread=1&v=10

I did also trigger the issue with Enhanced Tracking Protection set to normal while using NextDNS DNS-based content blocking, but when I tried to reproduce again, no luck, it appears the code path is triggered through a timing issue. I tried with only Enhanced Tracking Protection set to strict without a DNS-based blocker, but I could not, though I believe this might be possible since this triggers the anti-content blocker.


I verified in Chromium and I could never have the mutation observer callback being executed. But just to see if the code would failed if a node was moved around, I manually moved div.rcc-panel.group.rcc-panel-fixed element using click-and-drag with the mouse, and Chromium reports the mutations just as in Firefox, i.e. I could trigger the infinite mutation loop when moving the node manually.


By the way, this is the URL for the faulty code: https://alliptvlinks.com/tktk-content/plugins/eazy-ad-unblocker/js/custom.js. It is a WordPress plugin.

ghajini commented 7 months ago

If this antiadb is present on other unreported sites/unfixed sites with ublock origin installed & when this problem occurs, users will simply disable ublock origin on firefox or even remove? seeing antiadb is okay but slowness of browser is not Is there any way for fixing this at ublock level because chrome is all okay on performance?

@Yuki2718 reviews /plugins/eazy-ad-unblocker/*$script

garry-ut99 commented 7 months ago

ghajini: If this antiadb is present on other unreported sites/unfixed sites

About 131 sites contain this script : https://publicwww.com/websites/%22%2Feazy-ad-unblocker%2F%22/

ghajini: reviews /plugins/eazy-ad-unblocker/*$script

It works, no slowdown issue so far.

Also a similiar filter already exists in uBlock - Ads : /wp-content/plugins/eazy-ad-unblocker/*$script,css https://github.com/uBlockOrigin/uAssets/blob/12081185b3314717cd302c005044e4079e92b30c/filters/filters-2020.txt#L873 but doesn't work in this case because it has /wp-content/ which doesn't match /tktk-content/.

By the way there is also this whitelist rule in uBlock - Ads: : @@/wp-content/plugins/eazy-ad-unblocker/*$script,domain=imgair.net|imgblaze.net|imgfrost.net|pixsera.net|vestimage.site|imgwia.buzz|pixlev.* https://github.com/uBlockOrigin/uAssets/blob/12081185b3314717cd302c005044e4079e92b30c/filters/filters.txt#L15087

Also these scriptlets : alliptvlinks.com##+js(aopr, eazy_ad_unblocker) blog.textpage.xyz##+js(aopr, eazy_ad_unblocker) ruyashoujo.com##+js(aopr, eazy_ad_unblocker_dialog_opener)


I've visited https://daneiakartes.info/, with regional Greece list enabled, and encountered anti-adblock popup, and the script is present in the logger but is unblocked, because it has a different name: https://daneiakartes.info/wp-content/plugins/antiblocker/js/custom.js?ver=1.1.12 - neither the filter you've provided, nor the filter which is already in uBlock - Ads, will block it, also the slowdown issue hasn't appeared, but I didn't investigate further.

Also have visited another site: https://blackdesert-info.ru/ with regional RU list enabled, and the anti-adblock script is already blocked by rule from uBlock - Ads : /wp-content/plugins/eazy-ad-unblocker/*$script,css, also no slowdown issue has appeared after whitelisting the anti-adblock files, even with regional RU list disabled, I didn't investigate further.

Yuki2718 commented 7 months ago

@Yuki2718 reviews /plugins/eazy-ad-unblocker/*$script

If blocking this helps, why don't? But EL won't address anti-adb on normal sites.

gorhill commented 7 months ago

Is there any way for fixing this at ublock level

There is nothing uBO can do to fix bad code sites like this, the fix is at most filter-based as far as uBO is concerned.

ghajini commented 7 months ago

Is there any way for fixing this at ublock level

There is nothing uBO can do to fix bad code sites like this, the fix is at most filter-based as far as uBO is concerned.

okay closing, i will try to look ,how it can be solved with filters as browser slowness i am not convenient with...