Skip to content
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

Fix xdg portal verison check for persist_mode #6742

Merged
merged 1 commit into from Dec 24, 2023

Conversation

linuxrider
Copy link
Contributor

fixes #6741 on Fedora 39.

  • version check mixed up ScreenCast and RemoteDesktop which added persist_mode and restore_token on versions 4 and 2, respectively.
  • injection of persist_mode and restore_token happened in a too late step of setting up the session

@rustdesk
Copy link
Owner

@fufesou

@linuxrider
Copy link
Contributor Author

@rustdesk rustdesk merged commit 57acadd into rustdesk:master Dec 24, 2023
@rustdesk
Copy link
Owner

rustdesk commented Dec 24, 2023

@linuxrider have you tested this fixes your persist_mode issue? We tested, it does not fix the issue.

@linuxrider
Copy link
Contributor Author

I have tested it for Fedora 39 Gnome 45 on wayland. With this the persistent checkbox is present in the source selection portal dialog. Furthermore after accepting with persistence option, closing rustdesk and reopening no further dialog is shown upon reconnecting and remote control works.

This is the only procedure that works for me. I have tried several other procedures. E.g. adding the restore_token in on_create_session_response, on_select_devices_response and on_select_sources_response or only the first two. But then it crashed and I got the message on the rustdesk client X11 expected.

Documentation of the portals is not that clear for me. I think this is how it is supposed to work:
The chain of action is RemoteDesktop.CreateSession -> RemoteDesktop.SelectDevices ("is called" in on_create_session_response, here restore_token needs to be provided ) -> ScreenCast.SelectSources (persistence managed by RemoteDesktop ) -> RemoteDesktop.Start (returns new token).

The RemoteDesktop portal added persist_mode on version 2 and it is stated that persistence is managed by RemoteDesktop rather than ScreenCast portal https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.ScreenCast.html#org-freedesktop-portal-screencast-selectsources

@rustdesk
Copy link
Owner

Thanks @linuxrider

@fufesou

@linuxrider
Copy link
Contributor Author

linuxrider commented Dec 24, 2023

It works also with the nightly flatpak.
I am writing this in a unattended remote session.
Really glad that it works now. Thank you.

@fufesou
Copy link
Collaborator

fufesou commented Dec 24, 2023

There're two problems of this PR.

  1. It does not fix the "restore_token" issue..
  2. persist_mode is supported until version 4 for org.freedesktop.portal.ScreenCast. https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.ScreenCast.html#:~:text=of%20this%20interface.-,persist_mode,-(u)

#6742 (comment)

1.2.3

1.2.3.mp4

master commit and this branch

persist_mode.mp4

@linuxrider
Copy link
Contributor Author

So the version checking needs to be more fine grained and in more places to cover Fedora 39 and Ubuntu 22.04.
Your point 2: Does this mean that persistence handling is done in ScreenCast.SelectSources for portal versions < 4?

@fufesou
Copy link
Collaborator

fufesou commented Dec 24, 2023

I don't know how portal handle it under version 4. I'm also testing.

Another thing is the sharing icon persists after the connection end.

In 1.2.3, the sharing icon disappears after the connection.

@fufesou
Copy link
Collaborator

fufesou commented Dec 24, 2023

So the version checking needs to be more fine grained and in more places to cover Fedora 39 and Ubuntu 22.04.

Does this PR work fine in Fedora 39?

I've tested Fedora 38, the same behavior to Ubuntu 22.04.

@linuxrider
Copy link
Contributor Author

@fufesou I have adapted the version checks and it still works for Fedora 39.
Does this work in your tests, too?
https://github.com/linuxrider/rustdesk/tree/persist_mode

@linuxrider
Copy link
Contributor Author

I don't know how portal handle it under version 4. I'm also testing.

Another thing is the sharing icon persists after the connection end.

In 1.2.3, the sharing icon disappears after the connection.

The icon staying in the system tray after connection ends is also present in Fedora 39.

@fufesou
Copy link
Collaborator

fufesou commented Dec 24, 2023

The icon staying in the system tray after connection ends is also present in Fedora 39.

So your test may be invalid.

You need to run sudo systemctl restart rustdesk after the connection.

Or you can stop rustdesk service, do the following steps:

  1. sudo systemctl stop rustdesk
  2. pkill rustdesk
  3. rustdesk
  4. connect
  5. stop rustdesk
  6. rustdesk
  7. connect

@linuxrider
Copy link
Contributor Author

I did the test without installation of the compiled executable directly and with the flatpak from github. Closing the flatpak removes rustdesk from memory. I also did a reboot and the session still persisted.
Here it the flatpak to flatpak Fedora 39 test.
Bildschirmaufzeichnung vom 2023-12-24, 14-58-42.webm

I could not get the rpm nor the deb to work properly in the vm.
Will try once more.

@fufesou
Copy link
Collaborator

fufesou commented Dec 24, 2023

@linuxrider I've also tested with Fedora 39. This PR works fine.

It was my fault.

The versions of org.freedesktop.portal.RemoteDesktop and org.freedesktop.portal.ScreenCast are different.

Your PR is good. 👍

Version org.freedesktop.portal.RemoteDesktop org.freedesktop.portal.ScreenCast
Ubuntu 22.04 1 4
Fedora39 2 5

image

1703427638692

@fufesou
Copy link
Collaborator

fufesou commented Dec 24, 2023

@sahilyeole FYI.

There will be compatibility issues here. persist_mode is only supported when org.freedesktop.portal.RemoteDesktop version >= 2. The latest Fedora39 is the minimum version that can meet this requirement.

And there's one left strange thing. Even after the connection ends, the shared state persists.
It is introduced in #6675 . Maybe we can improve it.

image

@sahilyeole
Copy link
Contributor

Sure, I will work on it soon.

@sahilyeole
Copy link
Contributor

@linuxrider @fufesou
Should we use persist_mode for select_sources as well?
Is it needed there too?

we can add a check there like screencast_portal::version(&portal) >= 4

@linuxrider
Copy link
Contributor Author

@sahilyeole For org.freedesktop.portal.RemoteDesktop.version >= 2 it is enough to set persist_mode fororg.freedesktop.portal.RemoteDesktop.SelectDevices. It does not work if it is also set in SelectSources. Persistence is managed in org.freedesktop.portal.RemoteDesktop (https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.ScreenCast.html).
For org.freedesktop.portal.RemoteDesktop.version < 2 it is a different story and I don't understand how it works exactly.

@fufesou
Copy link
Collaborator

fufesou commented Dec 25, 2023

we can add a check there like screencast_portal::version(&portal) >= 4

@sahilyeole I'm not sure if the restore token can be used for both RemoteDesktop and ScreenCast.

Maybe we can use "RemoteDesktop" and "uinput" together.

For org.freedesktop.portal.RemoteDesktop.version < 2 and org.freedesktop.portal.ScreenCast.version >= 4 and non-flatpak, use uinput as the input method.

Otherwise, use "RemoteDesktop" as the input method.

It's a little complicated.

What do you think?

@sahilyeole
Copy link
Contributor

sahilyeole commented Dec 25, 2023

Currently, we are only using rdp input when uinput is not available, like on flatpak.
On normal wayland we are still using uinput.
One possible solution I can think of to maintain persistence same as before my PR for normal wayland:
Skip org.freedesktop.portal.RemoteDesktop.SelectDevices in the callback chain when uinput is already available. Use persist_mode for select_sources.
This way the function request_remote_desktop will work the same as it was before my PR only when uinput is already available (on normal wayland), also same persistence as before.

But the need for such implementation comes down to how much of a big problem the unavailability of persist_mode is because during my testing I didn't see any problem so I'm not sure.
Maybe persistence for select_devices is not needed because we are already not using rdp input for normal wayland.
Let me know if we should proceed with it.

@fufesou
Copy link
Collaborator

fufesou commented Dec 25, 2023

One possible solution I can think of to maintain persistence same as before my PR for normal wayland:
Skip org.freedesktop.portal.RemoteDesktop.SelectDevices in the callback chain when uinput is already available. Use persist_mode for select_sources.

Agree. I've also confirmed with @rustdesk

@sahilyeole
Copy link
Contributor

sahilyeole commented Dec 27, 2023

After this PR wayland arch linux (with version 2) as remote is not working. It asks for input permission but the connection is not made.
It might not be stable to use yet, not sure.
So should I comment the part added in this PR for flatpak? Because for normal wayland I'm turning back pipewire.rs code to how it was before #6675 anyway (with persist_mode in select_sources).
Also, version 2 is currently only available in latest releases that too fail on arch, not tested fedora.

@rustdesk
Copy link
Owner

rustdesk commented Dec 27, 2023

After this PR wayland arch linux (with version 2) as remote is not working

I will revert this PR first.

@rustdesk
Copy link
Owner

Reverted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Persist_mode for xdg portal does not work
4 participants