I am working on one Xamarin Android project which is using MvvmCross version 3.5.1. I am facing one issue which we thought might be because of MvvmCross set up failure. App is basically for both platforms Android and iOS. But, i am facing an issue specifically for Android. App is quite old and in development from last 3-4 years and never upgraded to latest released versions of MvvmCross. Updating MvvmCross is last option for me. But before that I want to fix this issue by knowing it's root cause and way to reproduce it.
Scenario:
1) App installed on Android device, Login is done.
2) App moved to background.
3) After 3-4 days, app resumed by clicking on app launcher icon and stuck on splash screen.
4) App started working again when
force stop from phone setting
I am unable to reproduce this issue without putting it in the background for more than 3-4 days. Can you please suggest a few approaches to know the root cause and steps to reproduce this issue without putting the app in background for more than 4 days.
Below Logs printed from MvvmCross and app freezes on the splash screen. log statement in bold "No view model type finder available - assuming we are looking for a splash screen - returning null" is printed 3-4 times and then app stuck on splash screen. Even though app stuck on splash screen. push notifications are received by an application.
Setup: PlatformServices start"
Setup: MvvmCross settings start"
Setup: Singleton Cache start"
"mvx": "No view model type finder available - assuming we are looking for a splash screen - returning null"
"mvx": "No view model type finder available - assuming we are looking for a splash screen - returning null"
"mvx": "No view model type finder available - assuming we are looking for a splash screen - returning null"
Please help me to know why the above log statement in bold is getting printed for 3-4 times and why logs from _setup.InitializeSecondary() are not printed, and then app stucks on splash. Looks like setup hung in between because of some deadlock or race condition. It will really help me if you have any suggestions to know possibilities to know the root cause and a way to reproduce this issue. Thanks in advance.
Updated: We are able to reproduced this scenario by commenting InitializeSecondary() call from MvxAndroidSetupSingleton->InitializeFromSplashScreen() and app stuck on Splash screen. please suggest fixing this splash screen stuck from app level code. Basically, we don't want to modify MvvmCross code and wanted to fix from app code. Your help is appreciated. As per logs, a line of code _setup.InitializeSecondary(); in below method from MvxAndroidSetupSingleton.cs is not executed. This issue is getting reproduced only after keeping the application in the background for more than 4-5 days. First i am trying to know why this is happening in this particular case and then solution for it. Thanks in advance
Note: I am using Android Foreground service in my application
public virtual void InitializeFromSplashScreen(IMvxAndroidSplashScreenActivity splashScreen) { lock (LockObject) { _currentSplashScreen = splashScreen;
if (_initializationStarted)
{
if (_initialized)
{
_currentSplashScreen.InitializationComplete();
return;
}
return;
}
_initializationStarted = true;
}
_setup.InitializePrimary();
ThreadPool.QueueUserWorkItem(ignored =>
{
_setup.InitializeSecondary();
lock (LockObject)
{
_initialized = true;
if (_currentSplashScreen != null)
_currentSplashScreen.InitializationComplete();
}
});
}