brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.62k stars 2.29k forks source link

Out of memory for Spotify and Instagram reels #36356

Closed kenewjr closed 1 month ago

kenewjr commented 7 months ago

Description

everytime i open instagram reels it makes tab instagram freeze but when i turn off widevine it's working normally and spotfy randomly crash with error : out of memory

Steps to Reproduce

-instagram-

  1. open instagram
  2. go to reels instagram
  3. freeze without showing any video but some time showing only 3-5 video -spotify-
  4. open spotify
  5. play from playlist
  6. spotfy randomly crash with error out of memory

    Actual result:

Expected result:

1.instagram showing videos reels everytime i scroll 2.spotfy continue play the song until playlist end

Brave version (brave://version info)

1.63.162 Chromium: 122.0.6261.69 (Official Build) (64-bit)

Other Additional Information:

Miscellaneous Information:

instagram reels worked when i turn off widevine

Brave-Matt commented 6 months ago

Lots of users reporting this issue (Spotify) in this thread: https://community.brave.com/t/spotify-keeps-crashing-in-brave/532078/23

wooque commented 6 months ago

I can confirm Spotify is leaking memory and crashes after some time on latest v1.64.109

wooque commented 6 months ago

Latest Chrome 123.0.6312.58 doesn't have this issue. It's a shame that I have to use Chrome to play Spotify.

ryanbr commented 6 months ago

https://www.reddit.com/r/truespotify/comments/1ay9n3d/spotify_crashes_and_gives_me_out_of_memory_error/

Looks like its in Chromium issue

wooque commented 6 months ago

I noticed that high memory usage is not reported by task manager. For example hover over tab will show 3.7GB memory usage, while task manager shows 250MB.

atuchin-m commented 4 months ago

an upstream bug: https://issues.chromium.org/issues/329580320

atuchin-m commented 3 months ago

The upstream bug is fixed and Chromium claims it helps to resolve most of the issues for them. However, it cant still reproduce the issue on a recent nightly (cr126) with chromium fix.

I've managed to grab and symbolize a memory-infra heap dump, but the data is controversial (Release optimizations?): image

atuchin-m commented 3 months ago

I've managed to get the correct stack. It matches the crash dumps and the details in the chromium issue.

image

trace_with_heap_dump.json.gz

atuchin-m commented 3 months ago

I've pushed CL to upstream that should improve the situation: https://chromium-review.googlesource.com/c/chromium/src/+/5670619/1

However, despite Chrome also has this issue, it is more severe in Brave Browser. The reason is an avalanche of requestIdleCallback originated from ReChapta javascript (from spotify.com) Each round (typically 100ms) the page got N callback fires and schedules N+1 new requestIdleCallback with timeout (usually 3000ms).I haven't managed to catch the same for Chrome.

Screenshot 2024-06-24 at 10 38 35 PM

image

kjozwiak commented 1 month ago

Closing the above as it's being resolved by https://github.com/brave/brave-core/pull/24712.

ShivanKaul commented 1 month ago

Opening since the issue still exists on Nightly

rebron commented 1 month ago

Closing out since we landed a fix in 1.69.x already. @ShivanKaul Can you create a new issue for this as it's a problem still on Nightly channel.

ShivanKaul commented 1 month ago

We landed a fix, but that didn't help right? AFAIK this problem exists on Beta and Release still.

ryanbr commented 1 month ago

Asking for confirmation in https://community.brave.com/t/spotify-keeps-crashing-in-brave/532078/105