Closed Bug 1717145 Opened 3 months ago Closed 2 months ago

Recommended preferences aren't always reset during shutdown

Categories

(Remote Protocol :: Agent, defect, P2)

Firefox 89
defect
Points:
2

Tracking

(firefox91 fixed)

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: ybmzlonlttswiokwnn, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

(Whiteboard: [bidi-m1-mvp])

Attachments

(3 files)

--remote-debugging-port makes fcitx5 not usable (prefs.js changed too many)

OS = Archlinux (up-to-date)
Firefox = 89.0.1 64 bit (installed by pacman)

after I ran the following command

firefox --remote-debugging-port 9222

at this moment it's still ok with fcitx5(ctrl+space could switch the input methods)

but after I quit Firefox and re-open firefox no matter with or without the --remote-debugging-port arguments, the fcitx5 could not be activated any more.

After some digging, I found that the prefs.js is some key to the problem:

I first refresh the firefox and backupt the profile folder, and ran with --remote-debugging-port, and restore the prefs.js, then it's ok.

Then I make the prefs.js read-only with the following command:

chmod -w ~/.mozilla/firefox/ipc15uv0.default-release-1623942976332/prefs.js

this time of course the --remote-debugging-port arg not affect the fcitx5.

So, what happened? lol

Summary: --remote-debugging-port makes fcitx not usable (prefs.js changed too many) → --remote-debugging-port makes fcitx5 not usable (prefs.js changed too many)

#related softwares installed

pacman -Qs fcitx5

local/fcitx5 5.0.8-1 (fcitx5-im)
    Next generation of fcitx
local/fcitx5-chinese-addons 5.0.6-2
    Addons related to Chinese, including IME previous bundled inside fcitx4
local/fcitx5-configtool 5.0.5-1 (fcitx5-im)
    Configuration Tool for Fcitx5
local/fcitx5-gtk 5.0.7-1 (fcitx5-im)
    Fcitx5 gtk im module and glib based dbus client library
local/fcitx5-qt 5.0.6-1 (fcitx5-im)
    Fcitx5 Qt Library


pip freeze | grep selenium
selenium==3.141.0

Thanks for the report. So the preferences the Remote Agent sets are the following:
https://searchfox.org/mozilla-central/source/remote/cdp/RecommendedPreferences.jsm

But usually all of them should be reset when Firefox gets closed. Could you please check if focusmanager.testmode is still true? If that is the case does resetting this preference help?

Flags: needinfo?(ybmzlonlttswiokwnn)

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #2)

Thanks for the report. So the preferences the Remote Agent sets are the following:
https://searchfox.org/mozilla-central/source/remote/cdp/RecommendedPreferences.jsm

But usually all of them should be reset when Firefox gets closed. Could you please check if focusmanager.testmode is still true? If that is the case does resetting this preference help?

Yep I check the about:config 's focusmanager.testmode.

First I ran command firefox --remote-debugging-port, that config item is true.
I close this test session.
I open the Firefox without --remote-debugging-port args, that config item is still true.
When I manually toggle it to false, the fcitx5 is running well again with Firefox.

I guess it might be some failure of some post-tasks after firefox(the relevant version) was closed.

Flags: needinfo?(ybmzlonlttswiokwnn)

When I manually toggle it to false,
and re-open the firefox,
the fcitx5 is running well again with Firefox.

Thanks for testing that, and I finally can reproduce this behavior. As it looks like resetting the recommended preferences does not (always) work.

Julian, I can remember that you told recently that resetting the prefs in Remote Agent happens kinda late during shutdown. Maybe that is the problem and the preferences aren't accessible anymore at this time? Will this maybe fixed by your work on bug 1693803?

Status: UNCONFIRMED → NEW
Component: CDP → Agent
Ever confirmed: true
Flags: needinfo?(jdescottes)
OS: Linux → All
Hardware: Desktop → All
Summary: --remote-debugging-port makes fcitx5 not usable (prefs.js changed too many) → Recommended preferences aren't always reset during shutdown
Whiteboard: [bidi-m1-mvp]

Thanks for the ping! In its current shape, my patch for bug 1693803 doesn't fix the issue.
However I tried to additionally observe "quit-application" and cleanup preferences there, and this seems to work fine.

So I think we could try the following logic change:

  • clients (marionette/cdp/etc...) only set preferences when they start
  • clients no longer attempt to reset preferences in their close/destroy codepath
  • instead RecommendedPreferences observes "quit-application" in order to cleanup all the altered preferences correctly

This means that preferences can not be dynamically "reset" if you quit a client while Firefox is still running, but I don't think this is really a supported use case.

What do you think?

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

As discussed with Julian we will add an observer for xpcom-will-shutdown and handle resetting the recommended preferences similarly to Marionette. Right now it looks like that the RemoteAgent's close() method is simply called too late during the application shutdown, and that the preferences module isn't available anymore.

Actually xpcom-will-shutdown does not work and occurs too late as well. Therefore marionette has the exact same issue. STRs:

  • make sure you use a clean profile
  • ./mach run --marionette
  • quit Firefox
  • ./mach run
  • check the value of focusmanager.testmode in about:config

ER: Should be false (default)
AR: Is still true

Instead, using quit-application (same as devtools for instance) seems to be invoked at the correct time. I don't know if we want to fix marionette as well in this bug, but I'll split this in 2 patches in any case.

Oh wow. That is a good find! I'm happy with either approach. I wonder if there is a way to actually get this tested. I assume we would have to parse the prefs.js file given that Firefox cannot run at that time.

Points: --- → 2
Priority: -- → P3
Priority: P3 → P2
Blocks: 1719435
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1f48b7266532
[remote] Reset remote preferences on quit-application r=webdriver-reviewers,whimboo
https://hg.mozilla.org/integration/autoland/rev/f4dfcf4c7f70
[marionette] Listen to quit-application instead of xpcom-will-shutdown to uninit marionette r=webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
You need to log in before you can comment on or make changes to this bug.