diff --git a/src/main/java/org/dpsoftware/managers/PipelineManager.java b/src/main/java/org/dpsoftware/managers/PipelineManager.java index b7e79fad..c0a7be27 100644 --- a/src/main/java/org/dpsoftware/managers/PipelineManager.java +++ b/src/main/java/org/dpsoftware/managers/PipelineManager.java @@ -141,11 +141,18 @@ public static XdgStreamDetails getXdgStreamDetails() { showChooseDisplayAlert(); alertShown.set(true); } - screenCastIface.Start(receivedSessionHandle, "", Collections.emptyMap()); - CommonUtility.sleepMilliseconds(200); - if (NativeExecutor.isWayland() && restoreTokenMatch.get() == false && alertShown.get() == false) { - showChooseDisplayAlert(); + try { + screenCastIface.Start(receivedSessionHandle, "", Collections.emptyMap()); + } catch (org.freedesktop.dbus.exceptions.DBusExecutionException e) { + if (NativeExecutor.isWayland() && alertShown.get() == false) { + log.info("Screen cast restore token is invalid or expired. Requesting a new one."); + showChooseDisplayAlert(); + screenCastIface.Start(receivedSessionHandle, "", Collections.emptyMap()); + } else { + throw e; + } } + CommonUtility.sleepMilliseconds(200); var c = streamIdMaybe.thenApply(streamId -> { FileDescriptor fileDescriptor = screenCastIface.OpenPipeWireRemote(receivedSessionHandle, Collections.emptyMap()); // block until stream started before calling OpenPipeWireRemote return new XdgStreamDetails(streamId, fileDescriptor);