macOS resume session support doesn't seem to work
Categories
(Core :: Widget: Cocoa, defect, P3)
Tracking
()
People
(Reporter: sam, Assigned: KrisWright)
References
Details
Attachments
(3 files)
After bug 639707, it is my understanding that Firefox should automatically restart itself if it was open when the OS restarted for an update. I use Nightly, and for both the macOS 13.3 update, and the 13.3.1 updates, I have purposefully left Nightly open thinking it would auto restart after the update. However, that has not happened in my experience. Other apps, such as Slack, do re-open themselves.
Comment 1•1 year ago
|
||
Telemetry seems to indicate that this works at least "sometimes". Now we need to figure out when this does not work and fix those situations. Could you tell us what you have set for the following settings in about:preferences?
"Open previous windows and tabs"
"Confirm before closing multiple tabs"
"Confirm before quitting with ⌘Q"
Updated•1 year ago
|
Reporter | ||
Comment 2•1 year ago
|
||
(In reply to Stephen A Pohl [:spohl] from comment #1)
Telemetry seems to indicate that this works at least "sometimes". Now we need to figure out when this does not work and fix those situations. Could you tell us what you have set for the following settings in about:preferences?
Sure!
"Open previous windows and tabs": Enabled
"Confirm before closing multiple tabs": Disabled
"Confirm before quitting with ⌘Q": Disabled
Comment 3•1 year ago
|
||
I'm going to try and gather more info about the systems that seem to successfully use this feature using telemetry. However, I need to wrap up a few other tasks first. Setting n-i to keep this on my radar.
Comment 4•1 year ago
|
||
(In reply to Sam Johnson from comment #2)
"Open previous windows and tabs": Enabled
"Confirm before closing multiple tabs": Disabled
"Confirm before quitting with ⌘Q": Disabled
I've seen the same today and my settings are the following:
- "Open previous windows and tabs": Enabled
- "Confirm before closing multiple tabs": Disabled
- "Confirm before quitting with ⌘Q": Enabled
Comment 5•1 year ago
|
||
I've restarted again with a build as started via mach run
so that it has all the default preferences. And even here it is not working. The instance doesn't get reopened after a restart.
Comment 6•1 year ago
|
||
Btw. note that Thunderbird actually perfectly gets reopened after the restart, and that already for some time.
Comment 7•1 year ago
|
||
(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #5)
I've restarted again with a build as started via
mach run
so that it has all the default preferences. And even here it is not working. The instance doesn't get reopened after a restart.
I don't believe that mach run
will be a reliable way to test this feature. The application should be launched from the dock before testing.
Comment 8•1 year ago
|
||
I see. But creating a dock icon for the eg. artifact build and starting it by clicking on that icon should make it work, right?
Comment 9•1 year ago
|
||
We don't know in what ways application identifiers may or may not interfere with this feature at the moment. It is possible that only officially branded builds work. It is also possible that only builds with the "firefox" identifier might work, rather than "nightly". Telemetry seems to indicate that it works for both, but we haven't been able to narrow down what parameters make this work and when it doesn't.
Comment 10•1 year ago
|
||
I tried with a release build of Firefox 113 and it doesn't work as well. It's not getting reopened after the startup. Note that Thunderbird works fine for already quite some time...
Updated•1 year ago
|
Reporter | ||
Comment 11•1 year ago
|
||
I just noticed this again with the 13.4 update. Is there some logging I can produce before initiating the next macOS update that would be useful for identifying the issue?
Reporter | ||
Comment 12•11 months ago
|
||
Reporting back in that Nightly did not resume after the 13.5 update either.
Comment 13•10 months ago
•
|
||
This might be a factor. @Sam and @Henrik, do you launch the browser to the profile manager to start it? i.e., you do not have a default profile that gets used by default when starting the browser.
It's unofficially documented that you can see the list of apps which will be restarted by running
$ defaults -currentHost read com.apple.loginwindow TALAppsToRelaunchAtLogin
or by looking at the loginwindow's plist file with $ plutil -p ~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist
And I noticed that Firefox doesn't get put in the list if I launch it from the dock and select my profile. If I launch it and provide the profile on the command line using the open command, it does get added to the list. Note, the open command is a way to launch/open things from the command line that is meant to be equivalent to launching/opening through the finder. You can do this with a Firefox repo using $ ./mach run --macos-open
.
So this $ open /Applications/Firefox.app/ --args -P MyReleaseProfile
populates the file with Firefox.
But this $ open /Applications/Firefox.app/
does not. I have several profiles and none of them are set to be the default.
Reporter | ||
Comment 14•10 months ago
|
||
I have a default profile and do not launch to the profile manager. However, since I use Nightly, ~every launch of the browser is from the update notification, so I am not using the dock icon either.
When I ran defaults -currentHost read com.apple.loginwindow TALAppsToRelaunchAtLogin
, Nightly was not in the list of apps, and it was last started via the update notification. Quitting Nightly and then opening it via the dock icon caused it to appear in the list.
Comment 15•10 months ago
|
||
Thanks, Sam.
After digging into this a bit more, I've found that the method we use to relaunch the browser after an update [NSTask launchedTaskWithLaunchPath:<path to the firefox executable> ...]
does not result in Firefox being added to the resume list described in comment 13. This method is deprecated as of macOS 14. The call site in updater code is here and there may be other sites.
Using the newer [[NSWorkspace sharedWorkspace] openApplicationAtURL:<path to Firefox.app> ...]
does result in the browser being added to the resume list. This method is available on 10.15+ which is now the minimum supported OS version for Release. With openApplicationAtURL, we shouldn't need to use the arch utility to launch because openApplicationAtURL uses the application's preferred architecture by default.
Assuming adopting openApplicationAtURL is the fix we use, we will want to find all the call sites where we launch the browser and change them to use the new method. Launches after updates and after profile-selection are the two that seem highest priority.
Comment 16•10 months ago
|
||
I'm always opening Firefox via the dock and yes the profile manager is always in use. This also explains comment 10 given that I have only a single profile for Thunderbird.
Comment 17•10 months ago
|
||
Comment 18•10 months ago
|
||
Additional note for anyone testing this: if an update is pending, launching from the Finder/dock will not result in the resume list being populated because the browser will be restarted at some point before becoming usable.
Assignee | ||
Comment 19•10 months ago
|
||
While this patch updates the launch code, it cannot be run on sdk versions below 10.15. In our code we still have a minimum requirement of 10.12, so to make this work we check for our sdk version using the existing @available objc call. Some changes have to be made to the way we launch to accommodate the new method, noted below.
Updated•10 months ago
|
Updated•9 months ago
|
Comment 20•9 months ago
|
||
Pushed by kwright@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f8ef3d7a6294 Update launch code to use nondeprecated APIs. r=spohl
Comment 21•9 months ago
|
||
Backed out changeset f8ef3d7a6294 (Bug 1827651) for causing NSWorkspace related assertions CLOSED TREE
Log: https://treeherder.mozilla.org/logviewer?job_id=429834317&repo=autoland&lineNumber=19075
Backout: https://hg.mozilla.org/integration/autoland/rev/c10a06cd7599f92aa4c8d3521b45f17906810138
Comment 22•8 months ago
|
||
There is an r+ patch which didn't land and no activity in this bug for 2 weeks.
:KrisWright, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.
Assignee | ||
Updated•8 months ago
|
Updated•7 months ago
|
Updated•7 months ago
|
Updated•6 months ago
|
Comment 23•3 months ago
|
||
Henrik and I briefly discussed try failures on Matrix. Adding n-i to follow up next week.
Comment 24•3 months ago
|
||
I had a look at the test TestQuitRestart.test_in_app_restart_component_prevents_shutdown
as pointed out by Stephen on Matrix. When I compared the log output by running mach marionette-test -vv --gecko-log - --setpref="remote.log.truncate=true" testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py
with just this test enabled I can see that the registered quit-application-requested
observer is no longer able to abort a quit request (returning true
), but instead Firefox just quits:
New behavior:
1709726194145 Marionette DEBUG 2 -> [0,15,"WebDriver:ExecuteScript",{"script":"Services.obs.addObserver(subject => {\n let cancelQuit = subject.QueryInterface(Ci.nsISupportsPRBool);\n cancelQuit.data = true;\n }, \"quit-application-requested\");","args":[],"newSandbox":true,"sandbox":"default","line":231,"filename":"testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py"}]
1709726194146 Marionette DEBUG 2 <- [1,15,null,{"value":null}]
1709726194146 Marionette DEBUG 2 -> [0,16,"Marionette:SetContext",{"value":"content"}]
1709726194146 Marionette DEBUG 2 <- [1,16,null,{"value":null}]
1709726194146 Marionette DEBUG 2 -> [0,17,"Marionette:GetContext",{}]
1709726194147 Marionette DEBUG 2 <- [1,17,null,{"value":"content"}]
1709726194147 Marionette DEBUG 2 -> [0,18,"Marionette:AcceptConnections",{"value":false}]
1709726194147 Marionette INFO Stopped listening on port 2828
1709726194147 Marionette DEBUG 2 <- [1,18,null,{"value":null}]
1709726194147 Marionette DEBUG 2 -> [0,19,"Marionette:Quit",{"flags":["eRestart"]}]
1709726194425 Marionette TRACE [2] MarionetteCommands actor destroyed for window id 4
1709726194462 Marionette TRACE Received observer notification quit-application
1709726194466 Marionette TRACE Received observer notification quit-application
1709726194468 Marionette DEBUG Marionette stopped listening
1709726194468 Marionette DEBUG 2 <- [1,19,null,{"cause":"restart","forced":true,"in_app":true}]
Current behavior:
1709726323700 Marionette DEBUG 2 -> [0,15,"WebDriver:ExecuteScript",{"script":"Services.obs.addObserver(subject => {\n let cancelQuit = subject.QueryInterface(Ci.nsISupportsPRBool);\n cancelQuit.data = true;\n }, \"quit-application-requested\");","args":[],"newSandbox":true,"sandbox":"default","line":231,"filename":"testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py"}]
1709726323700 Marionette DEBUG 2 <- [1,15,null,{"value":null}]
1709726323701 Marionette DEBUG 2 -> [0,16,"Marionette:SetContext",{"value":"content"}]
1709726323701 Marionette DEBUG 2 <- [1,16,null,{"value":null}]
1709726323701 Marionette DEBUG 2 -> [0,17,"Marionette:GetContext",{}]
1709726323701 Marionette DEBUG 2 <- [1,17,null,{"value":"content"}]
1709726323701 Marionette DEBUG 2 -> [0,18,"Marionette:AcceptConnections",{"value":false}]
1709726323701 Marionette INFO Stopped listening on port 2828
1709726323701 Marionette DEBUG 2 <- [1,18,null,{"value":null}]
1709726323701 Marionette DEBUG 2 -> [0,19,"Marionette:Quit",{"flags":["eRestart"]}]
1709726323915 Marionette TRACE [2] MarionetteCommands actor destroyed for window id 4
1709726323930 Marionette TRACE Received observer notification quit-application
1709726323933 Marionette TRACE Received observer notification quit-application
1709726323934 Marionette DEBUG Marionette stopped listening
1709726323934 Marionette DEBUG 2 <- [1,19,null,{"cause":"restart","forced":true,"in_app":true}]
So it looks like that we no longer check the return value of the observer and cancel a quit request?
Comment 25•3 months ago
|
||
I was probably wrong with the above statement. The difference that I can see is that with the new behavior the process might be differently forked and we maybe fail to track the correct process? Only for builds with the patches applied I can see the following output:
Child process with id "53717" has been marked as detached because it is no longer in the managed process group. Keeping reference to the process id "53715" which is the new child process.
Let me take a further look.
Comment 26•3 months ago
|
||
The actual problem is that the process mozrunner is tracking ends with an exit code of 0
and not stays running and reports None
here:
https://searchfox.org/mozilla-central/source/testing/marionette/client/marionette_driver/marionette.py#1359-1360
As such while a restarted process of Firefox is present we assume no such process is running and start another process.
Not sure if a restart could be done so that the original process still stays around and we can successfully check for the exit code of None
, or if Marionette, mozrunner, or even mozprocess needs to be updated.
Assignee | ||
Comment 27•3 months ago
|
||
Disables use of LaunchApplicationAtUrl(...) for marionette testing to limit risk of bug 1884401.
Comment 28•2 months ago
|
||
(In reply to Kris Wright :KrisWright from comment #27)
Created attachment 9391468 [details]
Bug 1827651 - Disable resume session supported API in marionette testingDisables use of LaunchApplicationAtUrl(...) for marionette testing to limit risk of bug 1884401.
That bug is fixed now. So please let us know if something else is needed like not loosing the stdout / stderr output from Firefox.
Updated•1 month ago
|
Description
•