Skip to content

Commit b88572e

Browse files
bammf1claude
andcommitted
Dispatcher.ShutdownStarted stack trace + fix log sink ordering
- Subscribe to Dispatcher.UIThread.ShutdownStarted in App.axaml.cs to capture the stack trace when the dispatcher dies (the actual cause) - Move Logger.Sink assignment AFTER .LogToTrace() so it isn't overwritten - This should finally reveal what crashes Avalonia on Linux Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 064c7ae commit b88572e

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎App.axaml.cs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public override void Initialize()
3434

3535
public override void OnFrameworkInitializationCompleted()
3636
{
37+
// Capture the exact moment the dispatcher shuts down — the stack trace
38+
// reveals what code triggered it (the real crash, not the symptom).
39+
Avalonia.Threading.Dispatcher.UIThread.ShutdownStarted += (_, _) =>
40+
{
41+
Console.Error.WriteLine("=== DISPATCHER SHUTDOWN STARTED ===");
42+
Console.Error.WriteLine(Environment.StackTrace);
43+
Console.Error.Flush();
44+
};
45+
3746
try
3847
{
3948
// Global CJK font for LiveCharts2 tooltips and labels.

‎Program.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ public static void Main(string[] args)
7777
// Avalonia configuration, don't remove; also used by visual designer.
7878
public static AppBuilder BuildAvaloniaApp()
7979
{
80-
// Log Avalonia internals to stderr so Linux crashes show the real cause
81-
Avalonia.Logging.Logger.Sink = new StderrLogSink();
82-
8380
var builder = AppBuilder.Configure<App>()
8481
.UsePlatformDetect()
8582
.WithInterFont()
8683
.LogToTrace();
8784

85+
// Set AFTER .LogToTrace() so our sink takes precedence (LogToTrace may overwrite)
86+
Avalonia.Logging.Logger.Sink = new StderrLogSink();
87+
8888
// On Linux, configure X11 with software rendering fallback and disable
8989
// DBus menu to avoid Wayland dispatcher shutdown crashes (Issue #19523).
9090
// Uses reflection because Avalonia.X11 types are only available at runtime

0 commit comments

Comments
 (0)