Closed Bug 2066531 Opened 3 months ago Closed 2 months ago

Recommended preferences are restored too late on shutdown to be persisted

Categories

(Remote Protocol :: Agent, defect, P3)

defect

Tracking

(firefox-esr140 unaffected, firefox-esr153 wontfix, firefox154 wontfix, firefox155 wontfix, firefox156 wontfix, firefox157 fixed)

RESOLVED FIXED
157 Branch
Tracking Status
firefox-esr140 --- unaffected
firefox-esr153 --- wontfix
firefox154 --- wontfix
firefox155 --- wontfix
firefox156 --- wontfix
firefox157 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [webdriver:m21] [webdriver:external][webdriver:relnote] )

Attachments

(1 external file)

(suggested by Claude, will check later)

RecommendedPreferences restores the preferences it applied on xpcom-shutdown, but the preference service stops accepting writes before that:

  • profile-before-change -> async SavePrefFile (Preferences.cpp:4997)
  • profile-before-change-telemetry -> SavePrefFileBlocking(), then mProfileShutdown = true (Preferences.cpp:5006)
  • xpcom-shutdown -> restoreAllPreferences() -> clearUserPref() -> HandleDirty() returns early with "Setting user pref after profile shutdown." (Preferences.cpp:4002)

So the preferences are cleared in memory after the last write, and prefs.js keeps the automation values permanently. Once stuck there, applyPreferences skips them forever after because of the prefHasUserValue check, so later automation runs silently do not get them either.

This was invisible while automation only ever used throwaway profiles. Bug 2066518 made it visible: dynamic start applies these preferences to a profile users keep.

Suggested fix: restore on profile-before-change instead of xpcom-shutdown.

This regressed by bug 2028422 which landed in Firefox 151. We originally reset the preferences in the quit-application phase. Lets check that we do not regress other use cases with this change to profile-before-change.

Keywords: regression
Regressed by: 2028422

Set release status flags based on info from the regressing bug 2028422

:hbenl, since you are the author of the regressor, bug 2028422, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

(need to repro in isolation, should not impact mcp workflow anymore)

Severity: -- → S3
Flags: needinfo?(jdescottes)
Priority: -- → P3
Whiteboard: [webdriver:backlog]

I confirm the bug and the fix.

During the triage meeting there was some discussion about the type of restart needed, but here we are not really concerned about restarts. The issue (at least on my machine!) occurs on shutdown.

STRs:

  • open the Browser Console and execute:
ChromeUtils.importESModule(
  "chrome://remote/content/shared/RecommendedPreferences.sys.mjs"
).RecommendedPreferences.applyPreferences();
  • quit the browser (I used cmd+Q FWIW)
  • start the browser with the same profile

ER: Preferences should have been restored
AR: Recommended preferences are still applied. Eg open a new tab, instead of about:newtab, you will get about:blank.

Note: I use the Browser Console here to trigger this, but you could swap it for anything that applies recommended preferences on a profile that can be reused.

And I confirm that switching from xpcom-shutdown to profile-before-change fixes this issue.

Flags: needinfo?(jdescottes)
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

Julian, good to see that we have steps now. Is that reproducible with a Marionette test? Here we do not set the recommended prefs by default but we could turn it on for just a single test. Then we could trigger an in-app quit and verify that after the restart with no recommended prefs applied these are reset. Maybe we just check some prefs, which should probably be enough.

Flags: needinfo?(jdescottes)
Attachment #9632799 - Attachment description: WIP: Bug 2066531 - [remote] Restore recommended preferences on profile-before-change phase → Bug 2066531 - [remote] Restore recommended preferences on profile-before-change phase

Added a test

Flags: needinfo?(jdescottes)

I am landing this because it blocks a firefox-devtools-mcp work, but it's fine to count it as external.

Whiteboard: [webdriver:backlog] → [webdriver:m21] [webdriver:external]
Pushed by jdescottes@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ba5bc763027f https://hg.mozilla.org/integration/autoland/rev/9d9d5b041fac [remote] Restore recommended preferences on profile-before-change phase r=Sasha,hbenl
Flags: needinfo?(hbenl)
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch

The patch landed in nightly and beta is affected, along with ESR.
:jdescottes, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(jdescottes)

I don't think we need to uplift anything here, usually we use throwaway profiles for automation. This mostly becomes relevant for ai-assisted browsing or tooling, but those flows are Nightly-only at the moment.

Regressions: 2070193
Whiteboard: [webdriver:m21] [webdriver:external] → [webdriver:m21] [webdriver:external][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: