Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1272442

Summary: Most running applications not remembered when auto-save-session=true
Product: Red Hat Enterprise Linux 7 Reporter: Michal Domonkos <mdomonko>
Component: gnome-sessionAssignee: Ray Strode [halfline] <rstrode>
Status: CLOSED DEFERRED QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: ggb, mboisver, mclasen, pdwyer, tpelka, vbenes
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-20 20:37:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
1) journalctl during the logout
none
2) journalctl during the subsequent login none

Description Michal Domonkos 2015-10-16 12:17:19 UTC
Description of problem:
With session autosave enabled, the only running applications that get remembered are Firefox and Evince (there may be more but I have only found these).  Other ones like Nautilus, Terminal or Clocks are not remembered.  

Note that this issue was present on 7.1 as well so it's not a regression.  However, on RHEL-6 there was no such issue.

I'm attaching two parts of the journal; one captured during the logout and one captured during the subsequent login a few seconds later.

Version-Release number of selected component (if applicable):
gnome-session-3.14.0-4.el7.x86_64
gnome-shell-3.14.4-37.el7.x86_64

How reproducible:
always

Steps to Reproduce:

1. Login to GNOME
2. Enable autosave:
   $ dconf write /org/gnome/gnome-session/auto-save-session true
3. Open up a few windows (Firefox, Evince, Nautilus, Clocks...)
4. Log out
5. Log in

Actual results:
Only Firefox and Evince start up, other apps that were running during the last session are not launched.

Expected results:
All apps that were running during the last session should be launched.

Comment 1 Michal Domonkos 2015-10-16 12:18:30 UTC
Created attachment 1083636 [details]
1) journalctl during the logout

Comment 2 Michal Domonkos 2015-10-16 12:18:57 UTC
Created attachment 1083637 [details]
2) journalctl during the subsequent login

Comment 4 Matthias Clasen 2015-10-22 12:44:19 UTC
This is not something that can be addressed as a 7.2 blocker. It has been the same way in 7.0 and 7.1, marking it as a regression towards the end of the 7.2 blocker phase seems disingenuous.

Comment 10 Ray Strode [halfline] 2019-07-15 17:05:33 UTC
*** Bug 1370250 has been marked as a duplicate of this bug. ***

Comment 13 Ray Strode [halfline] 2019-08-16 20:43:24 UTC
So i've been looking into this a bit.

- The first problem I ran into is the "save" button in properties doesn't work right.  I guess that's why comment 0 suggests turning on auto save and logging out, rather than saying to use the save button.  That problem is easy to fix though, it just a needed a small change to handle the SaveSession method.

- The second problem I ran into is that apps don't register with the session manager by default.  Gtk has code to register, but only if apps opt in with "register-session=TRUE" in their GtkApplication singleton instance, and most apps don't set it.  Fixing this requires a change in every app we care about supporting this feature.

- The third problem is gnome-session doesn't actually support saving for modern apps:

static GKeyFile *•
dbus_client_save (GsmClient *client,•
                  GsmApp    *app,•
                  GError   **error)•
{•
        g_debug ("GsmDBusClient: saving client with id %s",•
                 gsm_client_peek_id (client));•
•
        /* FIXME: We still don't support client saving for D-Bus•
         * session clients */•
•
        return NULL;•
}•

Now, I think the expectation these days is if an app wants to save state it should do it itself.  But we still need some way to make sure the app gets restarted at login...
So, I should be able to add in the implementation for this function to accomplish that goal without too much effort (the app should already have a keyfile we can look up, and return directly).

I'll look into that on monday. I can also look through the apps we ship by default and see what it would take to set register-session=TRUE for them.  should be a 10 line patch to each app.

Comment 14 Ray Strode [halfline] 2019-08-20 20:37:44 UTC
So I've done some more investigation into this... There are a number of issues:

1) Gtk exits the application as soon as the session manager enters the END_SESSION phase. In the XSMP days, the applications wouldn't die until the EXIT phase.
Unfortunately, the session gets saved at the end of the END_SESSION phase, so all applications that use Gtk for session registration, will exit before the session
is saved and not get recorded as running in the session.  We could potentially fix gtk to not quit the application in the END_SESSION phase. It already has code to quit the application in the EXIT phase, so the fix would just be code removal i think. or we could change gnome-session to save at the beginning of the end session phase instead of the end of it.  This might have implications for XSMP applications I would need to investigate.

2) in comment 13 I said the expectation these days is if an app wants to save state it should do it itself.  But that's not strictly true. Some state like workspace and window position should be handled by the window manager.  applications shouldn't care about where they are on screen.  The problem is the window manager only can restore the state of XSMP applications, not applications using Gtk's session registration functionality. This is because the window manager only saves the window positions of applications that put the SM_CLIENT_ID property on their client leader window. We could change it to save the position of all windows, but that might break XSMP applications (mutter might match the wrong window up).  Though, we could change it to save the positions of all windows of applications that aren't XSMP managed and just XSMP applications with SM_CLIENT_ID set. Or maybe we should have new dbus api that apps export and mutter uses, saying which windows should be session managed.

3) As a test, I fixed gedit to register with the session manager, and it gets restarted appropriately after my changes to gnome-session to fix the save session but and to add an implementation for dbus_client_save, but it doesn't restore it's open tabs. It used to have code to support restoring its tabs, but that code got dropped when XSMP support was dropped. Likewise nautilus doesn't open up on the same open folders.  So I said in comment 13 that the expectation these days is an app should manage its own state, but the apps don't really do that.

In summary, getting parity with RHEL 6 is tough because: 

- the save button isn't hooked up (small fix)
- the apps don't register with the session manager so the session manager can't know to restart them on login (bunch of small fixes everywhere)
- the apps don't use XSMP anymore and the session manager doesn't have support for restoring apps that use the non-XSMP api (small fix)
- the window manager doesn't know how to restore the window positions and workspaces of non-XSMP apps.
- the apps don't restore their state on their own when started (bunch of big fixes everywhere)
 
I think this outside the scope of RHEL 7 at this point in the cycle. We have a sister bug for this in RHEL 8 (bug 1701156), so let's defer to that.