Firefox memory usage in Angular + Polymer WebComponents application is huge in comparison to other browsers
Categories
(Core :: DOM: CSS Object Model, defect, P3)
Tracking
()
People
(Reporter: msbasanth, Unassigned)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [MemShrink])
Attachments
(9 files)
59.49 KB,
image/jpeg
|
Details | |
94.37 KB,
application/x-gzip
|
Details | |
2.44 MB,
image/gif
|
Details | |
2.00 MB,
image/gif
|
Details | |
89.84 KB,
application/x-gzip
|
Details | |
483.57 KB,
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
Details | |
28.90 KB,
image/jpeg
|
Details | |
85.23 KB,
image/jpeg
|
Details | |
11.39 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Steps to reproduce:
Test Scenario: Angular page with 30 Dropdowns with 120 items each, 30 Tabs, 100 Checkboxes and 20 buttons.
Demos
Angular + HTML: https://github.com/msbasanth/AngularHtmlHeavyUIApp
Angular + Polymer WebComponents: https://github.com/msbasanth/AngularPolymerHeavyUIApp
Steps to Reproduce
- Launch an Angular application with 30 Dropdowns with 120 items each, 30 Tabs, 100 Checkboxes and 20 buttons.
- Check the performance using Chrome performance tab with Memory check enabled.
- Note down the initial load time and total memory usage by the application.
- There is very high memory usage in firefox with Polymer WebComponents enabled at the same time a performance degradation observed with IE11 (no webcomponents support, polyfills used)
Actual results:
As you could see firefox memory usage is very high (726MB/276MB) compared to other browsers and IE11 initial load time is drastically high (2 Minutes)
Expected results:
We should have a comparable results across browsers when we use polymer webcomponents.
Comment 1•5 years ago
|
||
I'm setting a component in order to involve the development team in reviewing this issue.
If it is not the correct one, please feel free to set a more approriate one.
Thank you for reporting!
Comment 2•5 years ago
|
||
Thanks for the test-case!
In case this is browser dependent, could you export your about:memory
, or provide a test-case? You can click Measure and Save
on that page and attach the result.
Also, is this using just web components, or web components + shadow DOM? I'm not familiar with polymer itself.
Finally, how is memory measured in that table?
Thanks again.
Updated•5 years ago
|
Any chance for a testcase one could just load in a browser without need for local server?
Comment 5•5 years ago
|
||
Well I'll wait for the questions to be answered, otherwise I don't know what's being measured, but feel free to ni? me back if they get answered and I miss it or something :)
Tested on my computer(MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)), about:memory
:
72.0a1 (2019-10-22) (64-bit): 580MB, And it doesn't seem to load properly
68.0 (64-bit): 2.49GB, And it doesn't seem to load properly
Google Chrome 80.0.3947.0 (Official Build) canary (64-bit)
1.3G
When I open devtools:
4.4GB
This is the about:memory taken from Firefox with the Angular + Polymer application shared.
Reporter | ||
Comment 10•5 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #2)
Thanks for the test-case!
In case this is browser dependent, could you export your
about:memory
, or provide a test-case? You can clickMeasure and Save
on that page and attach the result.Also, is this using just web components, or web components + shadow DOM? I'm not familiar with polymer itself.
Finally, how is memory measured in that table?
Thanks again.
Hi,
I am attached about:memory (Measure and Save) result here.
We are using Polymer WebComponents for developing our UI elements. As I understand the latest Firefox builds we have WebComponents enabled by default and not required to enable using dom.webcomponents.enabled flag. So by default the UI elements will use WebComponents with with ShadowDOM in modern browsers. As mentioned in the table in older Mozilla Firefox (v67) when we tried disabling WebComponents we are not getting this high memory usage issue.
So here it is something to do with WebComponents with ShadowDOM.
How the memory is measured?
- We opened diagnostic window
- Took a memory snapshot.
- We can also see the high memory usage in task manager
Attached a GIF for detailing the same.
Reporter | ||
Comment 11•5 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #4)
Any chance for a testcase one could just load in a browser without need for local server?
Polymer +WebComponents controls require local server. Not sure about a way to load with the server.
Reporter | ||
Comment 12•5 years ago
|
||
I am attaching my observation in Chrome here. I could see memory usage below 200MB with Chrome Version 77.0.3865.120 (Official Build) (64-bit).
Comment 13•5 years ago
|
||
I'll find some time to dig through the memory report...
But there's only one attached (the one with web components, looks like). Could you attach the one without web components too?
797.01 MB (52.41%) ── heap-unclassified
344.77 MB (22.67%) ── text-nodes
The heap-unclassified is rather annoying. We're missing some memory reporters.
But that text-nodes part... how could we have that much data attached to DOM if Chrome shows just 32MB memory usage.
Is the Chrome memory usage for its parent process, not for the renderer process, by any chance?
(Or does Polymer somehow leave text nodes in the DOM when one uses Firefox. Polymer used to have leaks when using webcomponents, but I think at least some of them were fixed.)
Reporter | ||
Comment 15•5 years ago
|
||
To take the memory snapshot without webcomponent I had to go to Firefox version 66. I uninstalled latest Firefox and installed version 66. Now we are seeing a different memory snapshot, it's 3GB!.
It was not the case when initially I tested with webcomponent disabled (It was 50MB). I will attach the previous observations for webcomponent disabled separately.
One thing I could observe is in the 2nd launch there is a forceful update happening to version 69. Will it happen that I am seeing Firefox 69 results instead of version 66 (with WC disabled)?
Reporter | ||
Comment 16•5 years ago
|
||
Attaching my observations with Firefox version 66 with webcomponents disabled. Now I am not able to reproduce this as each time firefox gets updated to version 69 automatically. The option in the setting for disabling auto update doesn't help.
But as shown in the screenshot it was 50MB with webcomponents disabled to load the same UI (offcourse time taken is more).
Updated•5 years ago
|
Reporter | ||
Comment 17•4 years ago
|
||
Reporter | ||
Comment 18•4 years ago
|
||
Comment 19•4 years ago
|
||
@msbasanth This should use the Constructable Stylesheets
API
Reporter | ||
Comment 20•4 years ago
|
||
Reporter | ||
Comment 21•4 years ago
|
||
I have some further observations related to high memory usage in Firefox with WebComponents.
One difference in Firefox when comparing with Chrome is how styles are handled.
Style nodes are not static but per instance and in our example we have high (7000 nos) icon elements used which is having big style node. And this gets duplicated per instance in firefox and memory usage grows drastically.
Attached shadowdom style tag difference - chrome_shadowdom.jpeg & ff_shadowdom.jpeg.
It is observed because of this style duplication there is a huge memory usage (5,8 GB now) in #document. I am attaching a newer Firefox 84 (64Bit) memory snapshot from the same application.
As you could see #document contributes to maximum (4GB) to total memory usage.
Another observation is with shadowDom we have a huge number of DOM node created (more than 2lc) here.
Depending on the size style tag that we have it creates high memory usage. Is there any option(config) to modify the style tag not getting duplicated per instance?
Reporter | ||
Comment 22•4 years ago
|
||
(In reply to 709922234 from comment #19)
@msbasanth This should use the
Constructable Stylesheets
API
Thanks for the reply
I will look into it.
(In reply to 709922234 from comment #19)
@msbasanth This should use the
Constructable Stylesheets
API
Thank you @709922234 with Constructable Stylesheets
API I could see the style duplication per instance of shadow dom is not there.
i.e. by layout.css.constructable-stylesheets.enabled to true reduced the memory usage in my case from 6GB to 470MB.
I could see this option is available in Fireox Nightly (86.0a1 (2020-12-20) ) and also in Firefox 84.0.
Any information on when we can get this enabled y default in Firefox? :)
Perhaps Erik has some estimate when we could enable Constructable Stylesheets.
Comment 24•4 years ago
|
||
Ok, so it seems most of the duplication actually comes from the text nodes in the DOM... Is there any chance to use a shared blob URI and <link rel="stylesheet" href="blob:...">
rather than <style>
to inject the stylesheet inside the shadow tree? That should have roughly the same memory savings as using constructable stylesheet and doesn't need the new API.
Reporter | ||
Comment 25•4 years ago
|
||
The major memory is contributed by icon component CSS section with face types. I tried adding style as link to the component but then it is not picking face types the way it normally do when we link the styles outside shadow dom.
Is there any known restrictions @facetypes inserted using <link> inside shadowdom?
Comment 26•4 years ago
|
||
Comment 28•4 years ago
|
||
With regard to enabling Constructable StyleSheets, the feature is currently blocked on implementing Observable Array for WebIDL (Bug 1683281).
I am working on getting an estimate on the scope of work required for that.
Otherwise, there remains the spec-level issue that is still be discussed regarding whether the array should be assignable or not. Here is the latest comment (as of right now) regarding this discussion:
https://github.com/WICG/construct-stylesheets/issues/45#issuecomment-719640907
Updated•2 years ago
|
Updated•2 years ago
|
Comment 29•1 year ago
|
||
Constructable stylesheets are now supported on Firefox 101.
Description
•