-
Notifications
You must be signed in to change notification settings - Fork 229
Introduce save/restore portal #1818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
About the naming... Why |
I renamed it to make it a bit more clear
Sorry, where? It's SaveHint in all the dbus interfaces here |
Sorry, mistake.
Relative to? If you are looking for something meaningful, I think |
29e6746 to
189855a
Compare
Whoops didn't finish typing my comment. |
|
CC @davidedmundson and @technobaboo as the two folks from other desktops who I've interacted with in the discussion This is the real API I ended up implementing. PTAL and let me know if there's some blocker to getting something like this working in your desktop, or you see something missing, or etc. For your reference, here's GNOME's implementation of this portal's backend: https://gitlab.gnome.org/GNOME/gnome-session/-/blob/avovk/session-save-portal/gnome-session/gsm-session-save.c |
|
wait how does the app get the instance ID and know to restore its data using that ID? afaik there's no standard key name for it or such in the registration map it gets as a return arg for registering |
It's there - it's the first arg called I'm guessing you might have been looking at |
|
okay that's nice to know, so if it's required why isn't it an argument instead of inside the map? |
|
What's the goal of:
to allow identify crash exits vs clean application shutdowns? Do any other portal impls gain anything from this? If not, we would be better off with a bespoke signal just on the session restore before Close. |
swick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looked through the PR to understand what is being proposed here and found a bunch of things.
src/xdp-session.c
Outdated
| else | ||
| xdp_dbus_impl_session_call_close_sync (session->impl_session, | ||
| NULL, &error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| else | |
| xdp_dbus_impl_session_call_close_sync (session->impl_session, | |
| NULL, &error); | |
| else | |
| { | |
| xdp_dbus_impl_session_call_close_sync (session->impl_session, | |
| NULL, &error); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue in multiple places
src/save-restore.c
Outdated
| { | ||
| XdpDbusImplSaveRestore *impl_proxy = XDP_DBUS_IMPL_SAVE_RESTORE (source_object); | ||
| g_autofree RegisterData *data = user_data; | ||
| g_autoptr (GError) error = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In xdp and flatpak for some reason the autoptr style is g_autoptr(GError).
This lets the impl differentiate between a session that's closing because the app voluntarily called `Close()`, or because the app disconnected from the bus / some other reason.
189855a to
0677ad5
Compare
| 3 seconds of receiving this signal. The app may be transparently restarted | ||
| by the system at a later date. | ||
| --> | ||
| <signal name="Quit"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so I'm not really sure that this is actually necessary...
Instead of asking the app to quit, we can just put it in a cgroup freezer. This removes it from the run queue. We could then adjust the memory limits on the cgroup, which as far as I understand will force the app's memory out to swap and out of RAM. At that point, is there really any point to actually shutting down the app? We can leave the app "running", just frozen in a cgroup freezer and swapped out to disk. If the goal is to free up resources like memory and CPU, we've achieved that.
We can use something like SaveHint to ask the app to save its state just in case it somehow gets killed while in the freezer.
Alternatively, apps should just save their state immediately before quitting in response to something like SIGTERM. Then we could handle this simply by sending SIGTERM to the apps, rather than having them subscribe to this signal.
| #define XDP_TYPE_SAVE_RESTORE (xdp_save_restore_get_type ()) | ||
| G_DECLARE_FINAL_TYPE (XdpSaveRestore, | ||
| xdp_save_restore, | ||
| XDP, SAVE_RESTORE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so the USB portal names itself XdpUsb, but apparently most every other portal doesn't have an Xdp prefix. And apparently that was intentional
So, IDK am I supposed to rename this portal to just SaveRestore?
Perhaps if we want to maintain a separation, we could have a Portal prefix, so that all the portals are PortalAccounts, PortalSaveRestore, PortalUsb, etc and the utility classes/functions can keep XdpSession, XdpContext, etc
|
|
||
| G_DEFINE_TYPE (XdpSaveRestoreSession, | ||
| xdp_save_restore_session, | ||
| xdp_session_get_type ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XDP_TYPE_SESSION?
| { | ||
| XdpSaveRestoreSession *save_restore_session = XDP_SAVE_RESTORE_SESSION (session); | ||
|
|
||
| save_restore_session->closed = TRUE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a couple of the session implementations do nothing but keep track of this closed variable.
Maybe that should move up into the XdpSession object?
On the other hand, this class separation actually lets us check that the caller is giving us a session path to a session of a type we expect. So we'd need to have a subclass anyway. Or at the very least some sort of accounting of what portal created any given session
| XdpDbusImplSaveRestore *impl = XDP_DBUS_IMPL_SAVE_RESTORE (source_object); | ||
| g_autoptr(RegisterData) data = user_data; | ||
| g_autoptr(GError) error = NULL; | ||
| g_autoptr(GVariant) out_restore = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this to registration
| g_autoptr(GError) error = NULL; | ||
|
|
||
| impl_config = xdp_portal_config_find (config, SAVE_RESTORE_DBUS_IMPL_IFACE); | ||
| if (impl_config != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is backwards.
Implements the portal proposed in #1698
Links to other MRs: