Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1146d53
Initial plan
Copilot Feb 27, 2026
372f142
Fix: Silently handle InvalidCastException from WPF system resource in…
Copilot Feb 27, 2026
41d5e0a
Revert "Fix: Silently handle InvalidCastException from WPF system res…
Jack251970 Feb 28, 2026
60b92c5
Improve brush handling and resource safety in theme styles
Jack251970 Feb 28, 2026
5635783
Limit theme refresh to when color scheme is "System"
Jack251970 Feb 28, 2026
966bcdd
Refactor UI thread checks in Theme async methods
Jack251970 Feb 28, 2026
7b85574
Refactor drop shadow logic in Theme.cs for accuracy
Jack251970 Feb 28, 2026
a83da2b
Improve Theme resource handling and suppress async warnings
Jack251970 Feb 28, 2026
84ed1fa
Add null checks and fix dispatcher invocation in Theme
Jack251970 Feb 28, 2026
340f2cb
Refactor blur theme detection for accuracy
Jack251970 Mar 1, 2026
5b6b7e7
Rename themeName to theme in UpdateFonts for consistency
Jack251970 Mar 1, 2026
9943b72
Refactor drop shadow handling for window border style
Jack251970 Mar 1, 2026
3db201f
Use DispatcherPriority.Render for theme UI updates
Jack251970 Mar 1, 2026
c87f3d3
Improve theme resource access robustness
Jack251970 Mar 1, 2026
2e6fb61
Refactor blur theme logic and helper function
Jack251970 Mar 1, 2026
428a7ad
Prioritize user ColorScheme over system dark mode setting
Jack251970 Mar 1, 2026
4767b44
Optimize SolidColorBrush usage for window background
Jack251970 Mar 1, 2026
e3d71f9
Refactor window border style creation and copying
Jack251970 Mar 1, 2026
46cecb2
Improve code quality
Jack251970 Mar 1, 2026
65042d9
Update WindowBorderStyle to use global app resources
Jack251970 Mar 1, 2026
7476cdd
Simplify theme refresh logic in ActualApplicationThemeChanged
Jack251970 Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Flow.Launcher/Helper/ErrorReporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Exception;
using Flow.Launcher.Infrastructure.Logger;
using NLog;

Check warning on line 8 in Flow.Launcher/Helper/ErrorReporting.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`NLog` is not a recognized word. (unrecognized-spelling)

namespace Flow.Launcher.Helper;

Expand All @@ -14,7 +14,7 @@
private static void Report(Exception e, bool silent = false, [CallerMemberName] string methodName = "UnHandledException")
{
var logger = LogManager.GetLogger(methodName);
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));

Check warning on line 17 in Flow.Launcher/Helper/ErrorReporting.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Excpetion` is not a recognized word. (unrecognized-spelling)
if (silent) return;

// Workaround for issue https://github.com/Flow-Launcher/Flow.Launcher/issues/4016
Expand All @@ -23,8 +23,14 @@
// Many bug reports because users see the "Error report UI" after the crash with System.Runtime.InteropServices.COMException 0xD0000701 or 0x80263001.
// However, displaying this "Error report UI" during WPF crashes, especially when DWM composition is changing, is not ideal; some users reported it hangs for up to a minute before the it appears.
// This change modifies the behavior to log the exception instead of showing the "Error report UI".
if (ExceptionHelper.IsRecoverableDwmCompositionException(e)) return;

Check warning on line 26 in Flow.Launcher/Helper/ErrorReporting.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Dwm` is not a recognized word. (unrecognized-spelling)

// Workaround for a WPF issue where changing the Windows theme or accent color triggers
// SystemResources.InvalidateTreeResources, which tries to clone Color values stored in styles
// and fails with an InvalidCastException. This is a benign framework-level exception that
// does not affect Flow Launcher functionality, so we log it silently instead of showing the error dialog.
if (ExceptionHelper.IsRecoverableSystemResourceException(e)) return;

var reportWindow = new ReportWindow(e);
reportWindow.Show();
}
Expand Down
19 changes: 19 additions & 0 deletions Flow.Launcher/Helper/ExceptionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// <summary>
/// Returns true if the exception is a recoverable DWM composition exception.
/// </summary>
internal static bool IsRecoverableDwmCompositionException(Exception exception)

Check warning on line 20 in Flow.Launcher/Helper/ExceptionHelper.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Dwm` is not a recognized word. (unrecognized-spelling)

Check warning on line 20 in Flow.Launcher/Helper/ExceptionHelper.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Dwm` is not a recognized word. (unrecognized-spelling)
{
if (exception is not COMException comException)
{
Expand All @@ -37,6 +37,25 @@
// Check for common DWM composition changed patterns in the stack trace
var stackTrace = comException.StackTrace;
return !string.IsNullOrEmpty(stackTrace) &&
stackTrace.Contains("DwmCompositionChanged", StringComparison.OrdinalIgnoreCase);

Check warning on line 40 in Flow.Launcher/Helper/ExceptionHelper.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Dwm` is not a recognized word. (unrecognized-spelling)

Check warning on line 40 in Flow.Launcher/Helper/ExceptionHelper.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Dwm` is not a recognized word. (unrecognized-spelling)
}

/// <summary>
/// Returns true if the exception is a recoverable WPF system resource invalidation exception
/// that occurs when Windows changes its theme or accent colors. This is a known WPF issue where
/// <c>Color</c> values stored in styles are incorrectly cloned during resource tree invalidation.
/// </summary>
internal static bool IsRecoverableSystemResourceException(Exception exception)
{
if (exception is not InvalidCastException)
{
return false;
}

// Check for the specific Color-to-Expression cast failure originating from WPF's
// SystemResources.InvalidateTreeResources, triggered by Windows theme/accent color changes.
var stackTrace = exception.StackTrace;
Comment thread
Jack251970 marked this conversation as resolved.
Outdated
return !string.IsNullOrEmpty(stackTrace) &&
stackTrace.Contains("System.Windows.SystemResources.InvalidateTreeResources", StringComparison.Ordinal);
}
}
Loading