Open rhaly opened 9 months ago
On that stack trace I don't see any frames with Sentry in it. Where did you spot the relationship between SentryXamarinFormsIntegration?
That said ur reasoning makes sense, @lucas-zimerman doesn't seem safe to run that code on a background thread
Environment
Xamarin.Forms - 5.0.0.2012 Sentry.Xamarin.Forms - 1.5.2
Steps to Reproduce
After integrating sentry to our solution we started to observe random crashes at app startup with the following stacktrace:
Some other exceptions are also thrown with the same stacktrace:
System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
Expected Result
Sentry should not cause random crashes ;)
Actual Result
In my opinion root cause is a race condition between creating
AppThemeBinding
and runningSentryXamarinFormsIntegration
Both of those places are subscribing forRequestedThemeChanged
event, XF code is doing this on calling thread, Sentry is running this on the background thread Under the hoodWeakEventManager
is using regularDictionary
to store list of subscribers which isn't thread safe.Maybe at least there can be api to do this subscription for
RequestedThemeChanged
optional?