Implement progress bar in the Dock icon in a different way in order to save CPU
Categories
(Core :: Widget: Cocoa, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: mstange, Assigned: mstange)
References
(Blocks 1 open bug)
Details
(Keywords: power)
Attachments
(3 files)
When you download a file in Firefox on macOS, we draw a progress bar in the application dock icon. The API we use to do that drawing is slightly inefficient: We create a new NSImage with the combined icon + progress bar drawing, and set that as our application icon.
There's a more efficient API: We can set our own NSView instance as the application dock tile's content view and draw into that NSView. This is also a more modern API and lets us remove another lockFocus
call from the code base.
Another thing that drained CPU as part of dock drawing was the progress bar animation: On 10.9 and below, the native progress bar had a wavy pattern that was animated. So we triggered a redraw of the dock icon 8 times per second while the progress bar was visible. Starting on 10.10, the style is different and there is no more wavy pattern, but we were still triggering the redraws unnecessarily.
This patch reimplements the drawing using manual strokes and fills that look similar to the 10.12 progress bar style, and removes the animated redraws.
Assignee | ||
Comment 1•5 years ago
|
||
Assignee | ||
Comment 2•5 years ago
|
||
Two profiles for comparison:
Before: https://perfht.ml/2X4HrvZ, 247ms of dock drawing over the span of 15 seconds
After: https://perfht.ml/2X5O9SL, 16ms of dock drawing over the span of 15 seconds
So in this particular case the patch reduces the CPU impact of dock drawing by 15x.
Assignee | ||
Comment 3•5 years ago
|
||
Assignee | ||
Comment 4•5 years ago
|
||
Comment 5•5 years ago
|
||
Bugbug thinks this bug is a enhancement, but please change it back in case of error.
Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/9823d19217e2 Use NSDockTile to implement the dock download progress bar. r=spohl
Comment 7•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Description
•