On Thu, 29 Oct 2026 10:58:19 GMT, Thiago Milczarek Sayao <[email protected]> 
wrote:

> ## Description
> 
> On Linux/Wayland, the robot uses the XDG Desktop Portal (ScreenCast and 
> RemoteDesktop) and stores the `restore_token` returned by `Start` in 
> `~/.java/robot/remote-desktop-tokens.properties`. Later sessions send it 
> back, so the permission dialog is shown only once.
> 
> `validateToken()` in `screencast_portal.c` accepts a token only if 
> `g_uuid_string_is_valid()` returns true. The portal documentation only 
> specifies `restore_token` as a string (`s`) and does not define its format 
> ([RemoteDesktop](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.RemoteDesktop.html),
>  
> [ScreenCast](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.ScreenCast.html)).
> 
> Recent xdg-desktop-portal versions (seen with 1.22.1) no longer generate 
> UUIDs. Their tokens look like `vjebXVIEGhjtuuqCsiwYoQ`, and the frontend 
> accepts both formats (see 
> [`xdp_session_persistence_validate_restore_token()`](https://github.com/flatpak/xdg-desktop-portal/blob/1.22.1/src/xdp-session-persistence.c)).
> 
> Because the new tokens fail the UUID check, the robot never sends 
> `restore_token` in `SelectDevices` / `SelectSources`. Every new robot 
> iteration shows the permission dialog again. 
> 
> ## Steps to reproduce
> 
> 1. Fedora 44 GNOME (xdg-desktop-portal 1.22.1, xdg-desktop-portal-gnome 
> 50.0), Wayland session.
> 2. Run a system test that uses the robot, e.g. 
> `test.robot.javafx.scene.RobotTest`.
> 3. Approve the "Remote Desktop" dialog with "Allow Remote Interaction" turned 
> on.
> 4. The approval dialog will reappear
> 
> **Expected:** the session is restored from the stored token and no dialog is 
> shown.
> **Actual:** the dialog is shown on every new robot iteration.
> 
> ## Fix
> Do not assume a format for the token: accept any non-empty, valid UTF-8 strie 
> it. It still has to be valid UTF-8, since it is passed 
> to`g_variant_new_string()`.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Looks good! One question before I approve.

modules/javafx.graphics/src/main/native-glass/gtk/screencast_portal.c line 72:

> 70:     gboolean isValid = g_utf8_validate(token, -1, NULL);
> 71:     if (!isValid) {
> 72:         DEBUG_SCREENCAST("!!! restore token is not valid UTF-8\n", NULL);

IMO, wen can remove the weird triple `!!!`

Suggestion:

        DEBUG_SCREENCAST("restore token is not valid UTF-8\n", NULL);


Also, shall we still log the token? Now we would not anymore.

-------------

PR Review: https://git.openjdk.org/jfx/pull/2356#pullrequestreview-5752540790
PR Review Comment: https://git.openjdk.org/jfx/pull/2356#discussion_r4454950488

Reply via email to