App freeze on call to RunAppStart as IsStarted is false (even if startup is run)
🐛 Bug Report
On first run, on a fresh install of the app, OnCreate never returns because MvxAppCompatActivity.RunAppStart hangs. App start is run once too many because IMvxAppStart.IsStarted returns false (even if the Splash Screen has been shown and the flag initially was set to true).
The strange thing is that this behaviour only occurs on first launch of an app, when navigating to the second activity. If I re-launch the app from Visual Studio, the problem is gone. If I uninstall it from the device, and then launch from Visual Studio, it is back.
I have confirmed the IsStarted state by adding logging to the OnCreated method of my activity freezing:
Log = Mvx.IoCProvider.Resolve<IMvxLogProvider>().GetLogFor(this.GetType().FullName);
if (Mvx.IoCProvider.TryResolve(out IMvxAppStart startup))
{
Log.Info($"startup is started: {startup.IsStarted}");
}
On Activity1 IsStarted is true, on Activity2 which I navigate to when pushing a button, IsStarted i false, and RunAppStart ends up beeing called (but not returning).
Could this be a variation of these issues: https://github.com/MvvmCross/MvvmCross/issues/3268 and https://github.com/MvvmCross/MvvmCross/issues/3177 or this pull request https://github.com/MvvmCross/MvvmCross/pull/3214
Expected behavior
Reproduction steps
Configuration
Version: 6.2.2
Platform:
- [ ] :iphone: iOS
- [x] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [ ] :monkey: Xamarin.Forms
After further investigation, the cause is a call to ResetStart in my AppStart class. Why this is only happening on first launch, after installation I have no idea. 🤔
The startup code of Android should be completly rewrite. It's not working in most cases. When app is opened from a notification. When app receives a push notif, either when in background, not started, or foreground, when the app is started using a service, when the app is started twice by android when a usb device is plugged and the app is associated with this usb device and the user chose 'start app on plug', when appcenter's distribute switches to chrome on first run after the first activity is created but before it is displayed (activity will pause before being able to start the app).