[UWP] Crash when NetworkStatusChanged event occurs while app has no visible window yet #162
Description
Bug Information
Version Number of Plugin: 3.1.1 (but there seem to be no changes on the relevant line in 3.2)
Device Tested On: Dell Laptop XPS 15 9560, Parallels Windows on Mac, Latitude 5580, Surface Pro 4, probably other devices as well
Simulator Tested On: -
Version of VS: 2017 15.7.4
Version of Xamarin: 2.5.0
Versions of other things you are using: Win 10, mostly 1803
Steps to reproduce the Behavior
- Start a UWP app from the background, in our case by clicking on a push notification
- Somehow a network status changed event is triggered before the MainWindow is initialized
Expected Behavior
No crash
Actual Behavior
App crashes
Code snippet
var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
Our Crash logs (one example see crash.log) on HockeyApp always point to this line 35 in Connectivity.Plugin.UWP/ConnectivityImplementation.cs
The only time I have witnessed this crash happen myself was while starting up my app. The loading screen finished and the app closed itself without any visible feedback. But, this crash has happened lots of times in recent months on several devices (listed above, taken from HockeyApp) and we couldn't pinpoint it thus far.
We now suspect either the MainView or the CoreWindow is not yet initialized and thus the line above results in a NullReference exception (see attached crashlog).