Closed Bug 1877904 Opened 8 months ago Closed 4 months ago

Dark Reader addon causes some sites to use lots of memory and OOM the browser.

Categories

(WebExtensions :: Developer Outreach, defect, P3)

Firefox 124
ARM64
Android
defect

Tracking

(firefox122 affected, firefox123 affected, firefox124 affected)

RESOLVED MOVED
Tracking Status
firefox122 --- affected
firefox123 --- affected
firefox124 --- affected

People

(Reporter: pbone, Assigned: willdurand)

References

Details

(Whiteboard: [addons-jira])

I'm using a Samsung Galaxy Tab S6 Lite, it has 4GB of RAM (the problem doesn't happen on my Pixel 6 Pro with 12GB).

When I use Firefox, either Nightly or Release, with Dark Reader addon installed and visit http://kellysports.com.au it uses lots of RAM and the browser is OOMed.

STR, the browser sometimes crashes right away, sometimes it takes a little while, but these are some actions that almost always cause it for me:

  1. Open the site
  2. Click the X to dismiss the banner.
  3. Click the hamburger to open the menu
  4. Choose Parents and Kids
  5. Choose Before, During and After School Programs.
    (Almost always it has crashed by now)
  6. A new page loads
  7. Scroll down to choose where you live.
  8. Enter a place or a postcode. "3000" means the centre of Melbourne, try that.
  9. Click submit,
  10. A new page loads and you can choose a school.

At some point in the above steps things become unresponsive then the screen goes black (except for the status line at the top) then a moment later my home screen appears. I connected a USB debugger and saw lots of OOM killings in adb logcat at about the time of the crash. it seemed firefox wasn't the only thing it killed! There's no problem if I turn off the Dark Reader extension. It happens both in my Nightly profile which I use daily and probably has many tabs I've left open, as well as the Release profile which I hardly ever use and only has one tab open.

Thanks.

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

We've had a quick discussion and look at the issue with :pbone. Here are the profilers I got for this issue:

  1. Without the Dark Reader addon: https://share.firefox.dev/3HHI5JO
  2. With the Dark Reader addon: https://share.firefox.dev/3HG65Nj

From a quick glimpse of these profilers, it looks like we are getting a huge amount of IPC messages and requestAnimationFrame callbacks in the buggy case (2nd profiler). Hope this helps scoping down the issue.
That being said, I could not reproduce the crash that takes down the entire browser but rather the situation affects the content process as its RAM consumption grows drastically when addon enabled up until to the point when the OS decides to kill the content process. When the OS kills the process, the page reloads and a new content process is respawn.

(In reply to Kayacan Kaya [:kaya] from comment #2)

We've had a quick discussion and look at the issue with :pbone. Here are the profilers I got for this issue:

  1. Without the Dark Reader addon: https://share.firefox.dev/3HHI5JO
  2. With the Dark Reader addon: https://share.firefox.dev/3HG65Nj

From a quick glimpse of these profilers, it looks like we are getting a huge amount of IPC messages and requestAnimationFrame callbacks in the buggy case (2nd profiler). Hope this helps scoping down the issue.
That being said, I could not reproduce the crash that takes down the entire browser but rather the situation affects the content process as its RAM consumption grows drastically when addon enabled up until to the point when the OS decides to kill the content process. When the OS kills the process, the page reloads and a new content process is respawn.

Thanks for collecting and sharing profiles with and without the extension!

These profiles do not have the JS Allocations and/or Native Allocations GeckoProfiler features enabled, and so I couldn't see what the trend of memory allocation in the GeckoProfiler timeline, but focusing the timeline around the first slightly longer GCMajor bar (the orange bar in the timeline) and then looked what was at the top of the Call Stack view when inverting it and filtering to just Javascript made me notice a call to a function from the DarkReader content script named tryConvertDataURLToBlobSync (which is defined here in the DarkReader sources) and also that at the top there is "Image decoding", which I don't see in the profiler data collected without DarkReader installed.

I'm not yet sure if that is related or not, but seems worth taking a closer look:

I remember we had another memory leak related to themes and I dug it out, it was bug 1828587. Maybe it might provide some hints as to what's going on here?

@kaya. I think I've now seen both content process and whole browser being killed. Sometimes the page gets reloaded a couple of times as the content process is killed then the whole browser is killed.

The severity field is not set for this bug.
:zombie, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(tomica)

Assigning to William to investigate this.

Assignee: nobody → wdurand
Flags: needinfo?(tomica)
Whiteboard: [addons-jira]

The severity field is not set for this bug.
:rpl, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(lgreco)

FYI bug 1800440 was reported before, including a link to https://github.com/darkreader/darkreader/issues/10297
I posted an analysis of a profile at https://bugzilla.mozilla.org/show_bug.cgi?id=1800440#c6, here is the relevant part:

It looks like a performance issue caused by DarkReader, here is the profile: https://share.firefox.dev/3GgZnga
It shows significant jank on the main thread at Google, within MutationObserver, requestAnimationFrame AND setTimeout callbacks, handled by the watchForNodePosition function in Dark Reader (version 4.9.70, latest version as of today). It seems that Dark Reader is eternally busy on this specific site, trying to somehow patch stylesheets in Google

See Also: → 1800440

Add-ons Operations, please reach out to the developer of this add-on and make them aware of this bug.

Outreach information:

  • Add-on ID (mandatory): addon@darkreader.org
  • Add-on version(s) (recommended): latest version?
  • Specific message to include to the developer (optional): None but Comment 2 and Comment 9 seem relevant.
Component: Android → Developer Outreach
Flags: needinfo?(lgreco)
Severity: -- → S3
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → MOVED
You need to log in before you can comment on or make changes to this bug.