Open Bug 1842382 Opened 1 year ago Updated 1 year ago

Memory leak when SVG sprites are loaded (3300 SVGs)

Categories

(Core :: Performance, defect)

Firefox 115
defect

Tracking

()

UNCONFIRMED

People

(Reporter: i.vinnykov, Unassigned, NeedInfo)

References

(Depends on 1 open bug)

Details

Attachments

(3 files)

(deleted), text/plain
Details
(deleted), application/x-gzip
Details
(deleted), application/x-zip-compressed
Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Steps to reproduce:

When I run Firefox on Windows 10 x64 (or on Android) and access the site that loads 3300 SVG logos from SVG sprites, Firefox freezes, memory usage grows continously (is over 7 GB), SVGs aren't displayed correctly.

Steps to reproduce:

  1. Open https://leave-russia.org/
  2. Start typing in the Search... box and then remove entered data. The site uses on-client search, so all content is loaded (all 3300 SVG from 68 SVG sprites) and then DOM is filtered.

Actual results:

Page is displayed incorrectly. SVGs are loaded very slowly. Constant memory usage growth, over 7 GB.

Expected results:

In Chrome, Safari the same site in the same case works well. All logos are loaded and displayed in a second.

The Bugbug bot thinks this bug should belong to the 'Core::Performance' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Performance
Product: Firefox → Core

This bug was moved into the Performance component.

:i.vinnykov, could you make sure the following information is on this bug?

  • For slowness or high CPU usage, capture a profile with http://profiler.firefox.com/, upload it and share the link here.
  • For memory usage issues, capture a memory dump from about:memory and attach it to this bug.
  • Troubleshooting information: Go to about:support, click "Copy raw data to clipboard", paste it into a file, save it, and attach the file here.

If the requested information is already in the bug, please confirm it is recent.

Thank you.

Flags: needinfo?(i.vinnykov)

I reproduced the problem and captured memory and support info. I'm attaching the files.
Please note that during reproduction the page almost freezed, Windows Task Manager shows Firefox memory usage for over 5 GB. I closed Firefox because the memory dump file had 0 size during the long time. After closing Firefox the file was created.

Flags: needinfo?(i.vinnykov)
Attached file about.txt (deleted) —
Attached file memory-report.json.gz (deleted) —

Here is a profile

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

The majority is categorized as javascript by the profiler, but looking at the actual stacks it looks like it is actually dom code (called from js), and then some layout and network code.

In this case the following actions happen. This website uses client-side loading, so when search is activated, JS code retrieves data from the server. There are 3300+ entries, they are addedd to DOM. Entries include SVG images (logos of companies). The website uses SVG sprites where each sprite (gzipped) includes 50 logos. So when DOM is populates the browser needs to load 69 small sprites and render 3300 SVGs from these sprites.

The same page (with the search) works well on other browsers, such as Chrome, Safari, etc. The page rendering with all 3300 images takes a few seconds on desktop or even on mobile.

In case of Firefox rendering is blocked, the problem is in SVG rendering, because images appear very slowly. Windows Task Manager shows continuous memory usage growth - it can be 10 GB (and counting) and even in this case not all logos are displayed.

It sounds like you might be involved in the construction this site? Can you provide a stripped down site that just performs the actions that are much worse in Firefox?

There is the reason of the problem - Firefox doesn't properly loads SVG sprites. I've submitted a new bug about this at https://bugzilla.mozilla.org/show_bug.cgi?id=1843027.

To reproduce the problem open Web Developer Tools, switch to Network and open https://leave-russia.org/. As you can see, Firefox loads the same sprite (for example, sprite-01.svg) multiple times. That's the problem.

SVG sprites are designed to reduce a number of network calls. For example, when 50 logos are combined in sprite, a browser loads the sprite once. That's how other browsers work. In case of Firefox, it loads the same sprite as much times as logos from the sprite is represented on the page. In other words, it loads 50 times the same sprite file (which in size is bigger than the standalone SVG logo, because it includes multiple logos). So instead of saving memory for SVG sprites it uses much more memory.

Attached file A standalone test site (deleted) —

A standalone test site is attached. It can be opened locally on the file system or deployed to any server.

When running on Windows page opens in Firefox during 30-40 sec. Firefox uses 6.5 GB or RAM. In Chrome the same page opens in 2-3 sec and uses 200 MB of RAM.

This is hitting a known defect in firefox, the originating bugzilla for which is here:
https://bugzilla.mozilla.org/show_bug.cgi?id=1027106

We've asked for comment from that component owner.

(In reply to Benjamin De Kosnik [:bdekoz] from comment #11)

This is hitting a known defect in firefox, the originating bugzilla for which is here:
https://bugzilla.mozilla.org/show_bug.cgi?id=1027106

We've asked for comment from that component owner.

Benjamin, how did you determine this? Should we just dupe this to that?

Flags: needinfo?(bdekoz)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: