Refreshing the touch bar makes up a big chunk of tab switch time
Categories
(Firefox :: General, defect, P2)
Tracking
()
People
(Reporter: johannh, Assigned: johannh)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: regression, Whiteboard: [fxperf:p3])
Attachments
(1 file)
|
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
I was originally investigating site identity panel performance on tab switch when I noticed that _updateTouchBarInputs was taking a huge portion of tab switch times. Here is the profile I captured, showing the inverted call stack: https://perfht.ml/2W7BFu2
I think the two causes are:
-
nsITouchBarUpdater.updateTouchBarInputsis called several times per tab switch, once fortouchbar-location-change, according to my debugging multiple times forbookmark-icon-updatedand once forreader-mode-available- The thing here is that neither the bookmark nor the reader mode buttons are available by default, so the majority of these updates are completely unnecessary
-
It seems like the majority of time is spent on NSImage initialization, which is probably because we create a new NSImage every time we "update" any touchbar icon. This still has a big impact on perf, even when taking away the unnecessary updates.
I have attached a WIP patch that adresses the first issue, but I would happily take suggestions (and/or defer the implementation to someone else) on how to get rid of that NSImage init code.
:spohl, do you have an idea how to best avoid the NSImage overhead? I assume we can re-work this to simply re-use the existing image?
| Assignee | ||
Comment 1•6 years ago
|
||
| Assignee | ||
Comment 2•6 years ago
|
||
It's late and I realize that 20-30% is probably just wrong because that was based off the JS portion of the stack list and doesn't account for the content process. Slightly amending the title to give the right impression.
Comment 3•6 years ago
|
||
Thank you for filing this! Having worked on the Touch Bar code, your patch looks great, fwiw.
Comment 4•6 years ago
|
||
We'd like to move away from rasterizing PDFs over at bug 1521893. I'm guessing after that we can introduce a cache just as easily. Stephen may have time to take a look there as well soon-ish.
Meanwhile, I think your patch looks good, Johann. I also think that we can invoke the touchbar updater inside a requestIdleCallback, because it doesn't need to be as instant as we want the actual tab-switch to be.
Updated•6 years ago
|
Comment 5•6 years ago
|
||
(In reply to Mike de Boer [:mikedeboer] from comment #4)
We'd like to move away from rasterizing PDFs over at bug 1521893. I'm guessing after that we can introduce a cache just as easily. Stephen may have time to take a look there as well soon-ish.
I agree that some kind of cache would be the way to go here.
Comment 6•6 years ago
|
||
I've got a couple of thoughts…
- An early return at line 272 if the inputs array is empty should help reduce the number of calls to updateTouchBarInputs.
- Going up a level into the
observemethod on line 279, we could check to see if the input is actually changing before calling this._updateTouchBarInputs. (I've found a lot of the time, it's getting called without anything changing.) - It looks like we have a dictionary of identifiers -> TouchBarInputs available. Maybe we could look up the nsITouchBarInput's key in that dictionary to get the TouchBarInput, and not continually re-create them?
Updated•6 years ago
|
Updated•6 years ago
|
Comment 7•6 years ago
|
||
The priority flag is not set for this bug.
:spohl, could you have a look please?
For more information, please visit auto_nag documentation.
Updated•6 years ago
|
Comment 8•6 years ago
|
||
Changing the priority to p2 as the bug is tracked by a release manager for the current nightly.
See What Do You Triage for more information
| Assignee | ||
Comment 9•6 years ago
|
||
Bug 1521893 seems a bit stalled and personally I think that this is quite bad and we should really fix up both aspects of this bug, but in order to have some progress I can move this patch forward and file a follow-up for the widget pieces...
Updated•6 years ago
|
| Assignee | ||
Comment 10•6 years ago
|
||
Thank you for all the suggestions, but looking at it again I think this patch already does the primary optimization we can do in the front-end and re-using TouchbarInputs in the widget code should resolve the biggest perf regression without needing other optimizations, so I'll just ask for review on that patch as-is and file a new bug for the widget work.
Updated•6 years ago
|
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
| bugherder | ||
Updated•6 years ago
|
| Assignee | ||
Comment 14•6 years ago
|
||
Yeah, absolutely, thanks for the reminder.
| Assignee | ||
Comment 15•6 years ago
|
||
Comment on attachment 9060837 [details]
Bug 1547116 - Avoid updating unnecessary touch bar inputs. r=mikedeboer
Beta/Release Uplift Approval Request
- User impact if declined: Slower tab switching on Mac
- Is this code covered by automated tests?: Unknown
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): This is a very simple code-restructuring to increase efficiency of our TouchBar code.
- String changes made/needed: None
Comment 16•6 years ago
|
||
Comment on attachment 9060837 [details]
Bug 1547116 - Avoid updating unnecessary touch bar inputs. r=mikedeboer
perf improvement for osx touch bar, approved for 68.0b8
Comment 17•6 years ago
|
||
| bugherder uplift | ||
Updated•6 years ago
|
Updated•4 years ago
|
Description
•