Closed Bug 1620105 Opened 5 years ago Closed 5 years ago

GeckoView re-sets some preferences unnecessarily

Categories

(GeckoView :: General, defect, P1)

All
Android
defect

Tracking

(firefox75 fixed)

RESOLVED FIXED
mozilla75
Tracking Status
firefox75 --- fixed

People

(Reporter: mstange, Assigned: snorp)

Details

(Whiteboard: [geckoview:m76])

Attachments

(1 file)

Profile: https://perfht.ml/2VN7meO (2ms interval) https://perfht.ml/2ImRyrj (10ms interval)

In this profile of GeckoView startup, SafeBrowsing.readPrefs() takes up ~170ms: First, it takes ~40ms during SafeBrowsing.init(), and then ~130ms in response to various prefs being set.
We should find out whether it makes a difference to set these prefs before GeckoViewStartup calls SafeBrowsing.init(). From a brief glance at the code, it looks like the 130ms are pure repetitive work that be eliminated entirely.

Summary: GeckoView startup causes SafeBrowsing.jsm's updateProviderURLs and registerTables to run multiple times because it flips pref after SafeBrowsing initialization → GeckoView startup causes SafeBrowsing to re-initialize multiple times because it flips pref after SafeBrowsing.init(), taking an extra 130ms

This looks like Bug 1547717, which I started on a while back. Now that we have a perf-related reason to do this I think it should be a higher priority.

Whiteboard: [qf] → [qf:p1:responsiveness]

(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) (he/him) from comment #1)

This looks like Bug 1547717, which I started on a while back. Now that we have a perf-related reason to do this I think it should be a higher priority.

Hi james,
So I guess all the work here will be done in GeckoView? Is there anything you think I can help on Safe Browsing side?
If no, I'll update the component.

Flags: needinfo?(snorp)

For now I think it's all in GV, yes.

Flags: needinfo?(snorp)
Priority: -- → P1
Whiteboard: [qf:p1:responsiveness] → [qf:p1:responsiveness][geckoview:m76]
Component: Safe Browsing → General
Product: Toolkit → GeckoView

(In reply to James Willcox (:snorp) (jwillcox@mozilla.com) (he/him) from comment #1)

This looks like Bug 1547717, which I started on a while back. Now that we have a perf-related reason to do this I think it should be a higher priority.

Whoops, I was wrong. This isn't related to the resetting of prefs, but rather just setting them in response to GeckoRuntimeSettings changes. I believe this means Fenix is changing the safe browsing settings after startup, which seems unusual. Digging a bit more.

It appears that Fenix (or a-c) is setting a ton of runtime settings after startup and again on each new session. This is bad. We should fix that, but also GV could do a lot better by de-duping.

Fenix is definitely modifying a bunch of runtime settings outside of the builder both on startup and when a new page is opened. I see the following things being set on startup:

03-06 11:17:26.218  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"javascript.enabled":true}
03-06 11:17:26.220  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"browser.display.use_document_fonts":1}
03-06 11:17:26.221  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"font.size.systemFontScale":100}
03-06 11:17:26.222  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.annotate_channels":true}
03-06 11:17:26.246  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.annotate_channels.strict_list.enabled":true}
03-06 11:17:26.249  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.socialtracking.enabled":true}
03-06 11:17:26.259  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.trackingTable":"moztest-track-simple,ads-track-digest256,analytics-track-digest256,social-track-digest256"}
03-06 11:17:26.259  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.cryptomining.enabled":true}
03-06 11:17:26.266  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.cryptomining.blacklistTables":"base-cryptomining-track-digest256"}
03-06 11:17:26.272  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.fingerprinting.enabled":true}
03-06 11:17:26.278  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.fingerprinting.blacklistTables":"base-fingerprinting-track-digest256"}
03-06 11:17:26.285  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.socialtracking.block_cookies.enabled":true}
03-06 11:17:26.286  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.socialtracking.annotate.blacklistTables":"social-tracking-protection-facebook-digest256,social-tracking-protection-linkedin-digest256,social-tracking-protection-twitter-digest256"}
03-06 11:17:26.292  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"network.cookie.cookieBehavior":4}
03-06 11:17:26.293  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"browser.safebrowsing.malware.enabled":true}
03-06 11:17:26.293  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"browser.safebrowsing.phishing.enabled":true}
03-06 11:17:26.294  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"devtools.debugger.remote-enabled":false}
03-06 11:17:26.294  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"ui.systemUsesDarkTheme":0}
03-06 11:17:26.295  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"font.size.inflation.minTwips":120}
03-06 11:17:26.296  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"browser.ui.zoom.force-user-scalable":false}

And then the following settings are modified when a new tab is opened:

03-06 11:18:06.191  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.annotate_channels":true}
03-06 11:18:06.193  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.annotate_channels.strict_list.enabled":true}
03-06 11:18:06.194  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.socialtracking.enabled":true}
03-06 11:18:06.195  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.trackingTable":"moztest-track-simple,ads-track-digest256,analytics-track-digest256,social-track-digest256"}
03-06 11:18:06.201  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.cryptomining.enabled":true}
03-06 11:18:06.201  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.cryptomining.blacklistTables":"base-cryptomining-track-digest256"}
03-06 11:18:06.202  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.fingerprinting.enabled":true}
03-06 11:18:06.203  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.fingerprinting.blacklistTables":"base-fingerprinting-track-digest256"}
03-06 11:18:06.203  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.socialtracking.block_cookies.enabled":true}
03-06 11:18:06.204  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.socialtracking.annotate.blacklistTables":"social-tracking-protection-facebook-digest256,social-tracking-protection-linkedin-digest256,social-tracking-protection-twitter-digest256"}
03-06 11:18:06.205  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"network.cookie.cookieBehavior":4}
03-06 11:18:06.207  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.annotate_channels":true}
03-06 11:18:06.211  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.annotate_channels.strict_list.enabled":true}
03-06 11:18:06.212  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.socialtracking.enabled":true}
03-06 11:18:06.212  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.trackingTable":"moztest-track-simple,ads-track-digest256,analytics-track-digest256,social-track-digest256"}
03-06 11:18:06.216  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.cryptomining.enabled":true}
03-06 11:18:06.217  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.cryptomining.blacklistTables":"base-cryptomining-track-digest256"}
03-06 11:18:06.220  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.fingerprinting.enabled":true}
03-06 11:18:06.221  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.fingerprinting.blacklistTables":"base-fingerprinting-track-digest256"}
03-06 11:18:06.222  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.socialtracking.block_cookies.enabled":true}
03-06 11:18:06.223  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.socialtracking.annotate.blacklistTables":"social-tracking-protection-facebook-digest256,social-tracking-protection-linkedin-digest256,social-tracking-protection-twitter-digest256"}
03-06 11:18:06.224  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"network.cookie.cookieBehavior":4}
03-06 11:18:06.413  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.annotate_channels":true}
03-06 11:18:06.413  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.annotate_channels.strict_list.enabled":true}
03-06 11:18:06.414  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.socialtracking.enabled":true}
03-06 11:18:06.416  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.trackingTable":"moztest-track-simple,ads-track-digest256,analytics-track-digest256,social-track-digest256"}
03-06 11:18:06.417  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.cryptomining.enabled":true}
03-06 11:18:06.417  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.cryptomining.blacklistTables":"base-cryptomining-track-digest256"}
03-06 11:18:06.417  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.trackingprotection.fingerprinting.enabled":true}
03-06 11:18:06.420  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.fingerprinting.blacklistTables":"base-fingerprinting-track-digest256"}
03-06 11:18:06.421  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"privacy.socialtracking.block_cookies.enabled":true}
03-06 11:18:06.421  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"urlclassifier.features.socialtracking.annotate.blacklistTables":"social-tracking-protection-facebook-digest256,social-tracking-protection-linkedin-digest256,social-tracking-protection-twitter-digest256"}
03-06 11:18:06.422  8215  8243 D GeckoViewStartup: SNORP: SetDefaultPrefs {"network.cookie.cookieBehavior":4}

This is pretty bad, but GV can also de-dup a bunch of this too. I have a patch for that, and I'll also file a Fenix bug to stop doing this.

Assignee: nobody → snorp
Status: NEW → ASSIGNED

The de-dup patch here helps, but there's still a bunch of stuff being set. I filed an A-C bug about this here: https://github.com/mozilla-mobile/android-components/issues/6193

Pushed by jwillcox@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/16468a2fc8f4 Only set prefs for `GeckoRuntimeSettings` if there was a change r=geckoview-reviewers,agi
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75

The fix that landed here made no difference to the time spent in SafeBrowsing, so I'm renaming this bug and filing a new bug to track #6193 for the SafeBrowsing issue.

No longer blocks: geckoview-startup
Summary: GeckoView startup causes SafeBrowsing to re-initialize multiple times because it flips pref after SafeBrowsing.init(), taking an extra 130ms → GeckoView re-sets some preferences unnecessarily
Whiteboard: [qf:p1:responsiveness][geckoview:m76] → [geckoview:m76]

I filed bug 1621340 on the original issue.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: