[CRSH] Crash on Earbud Disconnect (Avalonia "Call from invalid thread" Exception) (original) (raw)

Shortly describe what you were doing before the crash
I was using the Galaxy Buds Client while my Galaxy Buds+ were connected. The crash occurred immediately after disconnecting the buds. Prior to the disconnect, I was actively interacting with the status display (battery indicators, etc.) in the app. Disconnecting the buds triggered a chain of events (Bluetooth disconnection events and associated reactive updates) leading to an unhandled cross-thread UI update.

Event File (And Locale MetaData):
Buds.zip

Crash Dump Analysis:
CrashDumpAnalysis.txt

Additional context
Through my investigation, I've discovered that during the disconnection event the application updates UI-bound properties (for example, IsLeftOnline in the view models) from a background thread. This violates Avalonia's requirement that all UI operations be performed on the UI thread, causing the framework’s Dispatcher.VerifyAccess to throw an InvalidOperationException. The problematic code includes reactive subscriptions in the UI components—for instance, the subscription in EarbudStatusUnit calls InvalidateMeasure() without ensuring that the execution occurs on the UI thread via Dispatcher.UIThread.
I suspect that proper use of a dispatcher (or configuring ReactiveUI’s scheduler) to marshal these updates to the UI thread should resolve the crash.