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.
This commit is contained in:
Yu Leng
2025-12-11 12:04:54 +08:00
parent adc5a43fd4
commit abef72dc25
2 changed files with 49 additions and 21 deletions

View File

@@ -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();

View File

@@ -38,6 +38,7 @@
#include "centralized_kb_hook.h"
#include "centralized_hotkeys.h"
#include "ai_detection.h"
#include <common/utils/package.h>
#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())