Closed Bug 1075482 Opened 10 years ago Closed 7 years ago

[statusbar] Statusbar causing lots of unnecessary reflows

Categories

(Firefox OS Graveyard :: Gaia::System, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: sergi, Unassigned)

Details

Attachments

(2 files, 1 obsolete file)

Whenever an icon visibility in the statusbar is updated, at least one reflow happens most of the time, since icons can have dynamic sizes. Because of that, we use `getComputedStyle` and clientWidth to get the size, causing reflows. That happens *very* often, and I believe we could cache the size the first time we retrieve the generated icon size to not have to cause reflows on the next time.
Assignee: nobody → sergi.mansilla
Attached file Github PR (obsolete) —
This patch solves two issues: - Uses offsetWidth instead of (clientWidth + marginLeft + marginRight), avoiding using getComputedStyle so often. - Caches the width value the first time it is retrieved.
Attachment #8498140 - Flags: review?(etienne)
Attachment #8498140 - Flags: feedback?
Attachment #8498140 - Flags: feedback?
Attached file Github PR
Attachment #8498140 - Attachment is obsolete: true
Attachment #8498140 - Flags: review?(etienne)
Attachment #8498759 - Flags: review?(etienne)
Comment on attachment 8498759 [details] [review] Github PR There are only two hard things in Computer Science... :) We should only go through the |getComputedStyle| call for elements with variable widths (as in variable over time, mainly time/date displays I think). So we need to invalidate the cache at some point, and I don't have any good heuristic suggestion :/ Guillaume, is what I'm saying correct? Do you have any ideas?
Attachment #8498759 - Flags: review?(etienne)
Flags: needinfo?(gmarty)
I'm not sure if caching icons width is the easiest way to go because of the invalidation issue you're pointing out. I've started applying a super easy optimisation for Bug 1074683 (see patch attached). I only call the icon reprioritisation function if an icon visibility changed. Doing so reduced the number of some reflows from 25 down to only 2. What about applying this optimisation to every icons with a defined width and for the other ones, let's only reprioritise if their content changed.
Flags: needinfo?(gmarty)
I see the problem, thanks for explaining. Regardless of caching, I believe getComputedStyle is not needed if we look at offsetWidth instead of clientWidth, no? Guillaume, looks indeed like your patch could be easily generalized for all icons.
In bug 1071512 landed, I cache the width of the date element, so this should have a positive impact on the number of reflows. But some work is still required though.
Attached file Github PR
I experimented with the idea of caching. In this patch, the time DOM element width is cached and refreshed every minute. We should see significant improvement when using both this patch and the on in Bug 1074683. Let's not merge this patch for now. Let's see how Bug 1074683 goes and I'll add more optimisations here.
Assignee: sergi.mansilla → nobody
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: