From b11a68220dfdafc317beffa0b99d47ea6a28aa68 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 5 Apr 2026 09:11:49 +0000 Subject: [PATCH] Handle sw renderer fallback better --- .../AppHardwareAccelerationDisableCheck.java | 27 +++++++++++++++++++ .../io/xpipe/app/platform/PlatformState.java | 23 +++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/io/xpipe/app/core/check/AppHardwareAccelerationDisableCheck.java diff --git a/app/src/main/java/io/xpipe/app/core/check/AppHardwareAccelerationDisableCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppHardwareAccelerationDisableCheck.java new file mode 100644 index 000000000..0573ea34c --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/check/AppHardwareAccelerationDisableCheck.java @@ -0,0 +1,27 @@ +package io.xpipe.app.core.check; + +import io.xpipe.app.core.AppCache; +import io.xpipe.app.issue.ErrorEventFactory; +import io.xpipe.app.util.LocalExec; +import io.xpipe.core.OsType; + +public class AppHardwareAccelerationDisableCheck { + + public static void check() { + if (OsType.ofLocal() != OsType.LINUX) { + return; + } + + var cached = AppCache.getBoolean("hardwareAccelerationDisabled", false); + if (!cached) { + return; + } + + AppCache.clear("hardwareAccelerationDisabled"); + + ErrorEventFactory.fromMessage( + "A graphics driver issue was detected and the application has been restarted. Hardware acceleration has been disabled.") + .expected() + .handle(); + } +} diff --git a/app/src/main/java/io/xpipe/app/platform/PlatformState.java b/app/src/main/java/io/xpipe/app/platform/PlatformState.java index 29ef64e5c..d31a7791b 100644 --- a/app/src/main/java/io/xpipe/app/platform/PlatformState.java +++ b/app/src/main/java/io/xpipe/app/platform/PlatformState.java @@ -1,11 +1,13 @@ package io.xpipe.app.platform; +import io.xpipe.app.core.AppCache; import io.xpipe.app.core.AppProperties; import io.xpipe.app.core.AppRestart; import io.xpipe.app.core.check.AppSystemFontCheck; import io.xpipe.app.core.mode.AppOperationMode; import io.xpipe.app.issue.ErrorEventFactory; import io.xpipe.app.prefs.AppPrefs; +import io.xpipe.app.util.GlobalTimer; import io.xpipe.app.util.ThreadHelper; import io.xpipe.core.OsType; @@ -17,6 +19,7 @@ import lombok.Setter; import lombok.SneakyThrows; import java.awt.*; +import java.time.Duration; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -31,6 +34,7 @@ public enum PlatformState { private static Throwable lastError; private static boolean expectedError; + private static boolean restartQueued; public static Throwable getLastError() { if (expectedError) { @@ -72,6 +76,10 @@ public enum PlatformState { } public static void handleStderrMessage(String msg) { + if (restartQueued) { + return; + } + // Quantum pipeline graphics driver issues are swallowed and only logged to stderr // We can still detect them by looking for them in the stderr output var l = List.of( @@ -82,10 +90,17 @@ public enum PlatformState { ); if (AppPrefs.get() != null && AppPrefs.get().canSaveLocal() && !AppPrefs.get().disableHardwareAcceleration().get() && l.stream().anyMatch(msg::contains)) { - teardown(); - AppPrefs.get().disableHardwareAcceleration().set(true); - AppPrefs.get().save(); - AppRestart.restart(); + restartQueued = true; + AppCache.update("hardwareAccelerationDisabled", true); + // Delay this to guarantee that the application starts up as much as possible + // This is to ensure that any initialization on initial startup is run + // It will get stuck at the first dialog if the graphics pipeline does not work + GlobalTimer.delay(() -> { + teardown(); + AppPrefs.get().disableHardwareAcceleration().set(true); + AppPrefs.get().save(); + AppRestart.restart(); + }, Duration.ofSeconds(5)); } }