Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions Dashboard/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)

private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
/* Silently swallow Hardcodet TrayToolTip race condition (issue #422).
The crash occurs in Popup.CreateWindow when showing the custom visual tooltip
and is harmless — the tooltip simply doesn't show that one time. */
if (IsTrayToolTipCrash(e.Exception))
{
Logger.Warning("Suppressed Hardcodet TrayToolTip crash (issue #422)");
e.Handled = true;
return;
}

Logger.Error("Unhandled Dispatcher Exception", e.Exception);

MessageBox.Show(
Expand All @@ -114,6 +124,16 @@ private void OnUnobservedTaskException(object? sender, UnobservedTaskExceptionEv
e.SetObserved(); // Prevent process termination
}

/// <summary>
/// Detects the Hardcodet TrayToolTip race condition crash (issue #422).
/// </summary>
private static bool IsTrayToolTipCrash(Exception ex)
{
return ex is ArgumentException
&& ex.Message.Contains("VisualTarget")
&& ex.StackTrace?.Contains("TaskbarIcon") == true;
}

private void CreateCrashDump(Exception? exception)
{
try
Expand Down
5 changes: 4 additions & 1 deletion Dashboard/Services/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public void Initialize()

bool HasLightBackground = Helpers.ThemeManager.HasLightBackground;

/* Custom tooltip styled to match current theme */
/* Custom tooltip styled to match current theme.
Note: Hardcodet TrayToolTip can rarely trigger a race condition in Popup.CreateWindow
that throws "The root Visual of a VisualTarget cannot have a parent." (issue #422).
The DispatcherUnhandledException handler silently swallows this specific crash. */
_trayIcon.TrayToolTip = new Border
{
Background = new SolidColorBrush(HasLightBackground
Expand Down
20 changes: 20 additions & 0 deletions Lite/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)

private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
/* Silently swallow Hardcodet TrayToolTip race condition (issue #422).
The crash occurs in Popup.CreateWindow when showing the custom visual tooltip
and is harmless — the tooltip simply doesn't show that one time. */
if (IsTrayToolTipCrash(e.Exception))
{
AppLogger.Warn("Dispatcher", "Suppressed Hardcodet TrayToolTip crash (issue #422)");
e.Handled = true;
return;
}

AppLogger.Error("Dispatcher", "Unhandled exception", e.Exception);
AppLogger.Flush();

Expand All @@ -344,6 +354,16 @@ private void OnUnobservedTaskException(object? sender, UnobservedTaskExceptionEv
e.SetObserved(); /* Prevent process termination */
}

/// <summary>
/// Detects the Hardcodet TrayToolTip race condition crash (issue #422).
/// </summary>
private static bool IsTrayToolTipCrash(Exception ex)
{
return ex is System.ArgumentException
&& ex.Message.Contains("VisualTarget")
&& ex.StackTrace?.Contains("TaskbarIcon") == true;
}

private static string FormatExceptionDetails(Exception? ex)
{
if (ex == null) return "Unknown error";
Expand Down
5 changes: 4 additions & 1 deletion Lite/Services/SystemTrayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public void Initialize()

bool HasLightBackground = Helpers.ThemeManager.HasLightBackground;

/* Custom tooltip styled to match current theme */
/* Custom tooltip styled to match current theme.
Note: Hardcodet TrayToolTip can rarely trigger a race condition in Popup.CreateWindow
that throws "The root Visual of a VisualTarget cannot have a parent." (issue #422).
The DispatcherUnhandledException handler silently swallows this specific crash. */
_tooltipText = new TextBlock
{
Text = "Performance Monitor Lite",
Expand Down
Loading