From abef72dc25bb939384a1a54fc8980b9f00804ea3 Mon Sep 17 00:00:00 2001 From: Yu Leng Date: Thu, 11 Dec 2025 12:04:54 +0800 Subject: [PATCH] Disable AI Super Resolution on Windows 10 Add explicit checks to prevent AI Super Resolution features from initializing or running on Windows 10. AI detection and initialization are now skipped on Windows 10, and the AI state is set to NotSupported. AI capability detection in the runner is only started on Windows 11 or later. This ensures AI Super Resolution is only available on supported Windows versions. --- src/modules/imageresizer/ui/App.xaml.cs | 57 ++++++++++++++++--------- src/runner/main.cpp | 13 +++++- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/modules/imageresizer/ui/App.xaml.cs b/src/modules/imageresizer/ui/App.xaml.cs index 74e918c60c..ab0f59b779 100644 --- a/src/modules/imageresizer/ui/App.xaml.cs +++ b/src/modules/imageresizer/ui/App.xaml.cs @@ -84,30 +84,40 @@ namespace ImageResizer return; } - // Load AI availability from cache (written by Runner's background detection) - var cachedState = Services.AiAvailabilityCacheService.LoadCache(); - - if (cachedState.HasValue) + // AI Super Resolution is not supported on Windows 10 - skip cache check entirely + if (OSVersionHelper.IsWindows10()) { - AiAvailabilityState = cachedState.Value; - Logger.LogInfo($"AI state loaded from cache: {AiAvailabilityState}"); - } - else - { - // No valid cache - default to NotSupported (Runner will detect and cache for next startup) AiAvailabilityState = AiAvailabilityState.NotSupported; - Logger.LogInfo("No AI cache found, defaulting to NotSupported"); - } - - // If AI is potentially available, start background initialization (non-blocking) - if (AiAvailabilityState == AiAvailabilityState.Ready) - { - _ = InitializeAiServiceAsync(); // Fire and forget - don't block UI + ResizeBatch.SetAiSuperResolutionService(Services.NoOpAiSuperResolutionService.Instance); + Logger.LogInfo("AI Super Resolution not supported on Windows 10"); } else { - // AI not available - set NoOp service immediately - ResizeBatch.SetAiSuperResolutionService(Services.NoOpAiSuperResolutionService.Instance); + // Load AI availability from cache (written by Runner's background detection) + var cachedState = Services.AiAvailabilityCacheService.LoadCache(); + + if (cachedState.HasValue) + { + AiAvailabilityState = cachedState.Value; + Logger.LogInfo($"AI state loaded from cache: {AiAvailabilityState}"); + } + else + { + // No valid cache - default to NotSupported (Runner will detect and cache for next startup) + AiAvailabilityState = AiAvailabilityState.NotSupported; + Logger.LogInfo("No AI cache found, defaulting to NotSupported"); + } + + // If AI is potentially available, start background initialization (non-blocking) + if (AiAvailabilityState == AiAvailabilityState.Ready) + { + _ = InitializeAiServiceAsync(); // Fire and forget - don't block UI + } + else + { + // AI not available - set NoOp service immediately + ResizeBatch.SetAiSuperResolutionService(Services.NoOpAiSuperResolutionService.Instance); + } } var batch = ResizeBatch.FromCommandLine(Console.In, e?.Args); @@ -130,6 +140,15 @@ namespace ImageResizer { Logger.LogInfo("Running AI detection mode..."); + // AI Super Resolution is not supported on Windows 10 + if (OSVersionHelper.IsWindows10()) + { + Logger.LogInfo("AI detection skipped: Windows 10 does not support AI Super Resolution"); + Services.AiAvailabilityCacheService.SaveCache(AiAvailabilityState.NotSupported); + Environment.Exit(0); + return; + } + // Perform detection (reuse existing logic) var state = CheckAiAvailability(); diff --git a/src/runner/main.cpp b/src/runner/main.cpp index 27cea414f8..ab2847c741 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -38,6 +38,7 @@ #include "centralized_kb_hook.h" #include "centralized_hotkeys.h" #include "ai_detection.h" +#include #if _DEBUG && _WIN64 #include "unhandled_exception_handler.h" @@ -210,9 +211,17 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow PeriodicUpdateWorker(); } }.detach(); - // Start AI capability detection in background + // Start AI capability detection in background (Windows 11+ only) + // AI Super Resolution is not supported on Windows 10 // This calls ImageResizer --detect-ai which writes result to cache file - DetectAiCapabilitiesAsync(); + if (package::IsWin11OrGreater()) + { + DetectAiCapabilitiesAsync(); + } + else + { + Logger::info(L"AI capability detection skipped: Windows 10 does not support AI Super Resolution"); + } std::thread{ [] { if (updating::uninstall_previous_msix_version_async().get())