I have an UWP app with a lot of errors in dev center console during launch such as this: em_watchdog_timeout_deada444_514cabuxamapache.391043fc20bb3_fa4730peekfge!lockscreenimages.exe_timeout_expired:_event_type_=_targetstatechanged,_timeout_modifier_type_=_none,_server_task_currentstate_=_navigatingto,targetstate=_active. I suspect it's due to Cortana or Analitycs activation in "App.cs":
private async Task SetupVoiceCommands()
{
try
{
StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"Commands.xml");
await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
}
}
private void InitAnalyticsTracker()
{
GoogleAnalyticsTracker = AnalyticsManager.Current.CreateTracker("UA-XXXXXXXX");
AnalyticsManager.Current.ReportUncaughtExceptions = true;
AnalyticsManager.Current.AutoAppLifetimeMonitoring = true;
AnalyticsManager.Current.IsDebug = false;
}
This code is executed in:
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
Window.Current.Content = rootFrame;
}
if (e.PrelaunchActivated == false)
{
await SetupVoiceCommands();
if (rootFrame.Content == null)
{
InitAnalyticsTracker();
rootFrame.Navigate(typeof(Shell), e.Arguments);
}
else
{
var page = rootFrame.Content as Shell;
page?.OnLaunchedEvent(e.Arguments);
}
Window.Current.Activate();
CustomizeStatusBar();
}
}
A lot of users say the app does not even start... Any ideas please?
The call await SetupVoiceCommands();
blocks the rest of the code in the OnLaunched
method: until the execution of SetupVoiceCommands()
is finished the main page of the app won't be displayed (which is supposed to happen within a short period of time after the app launch, otherwise the system will shut down your app as not responding).
Consider moving the await SetupVoiceCommands();
closer to the end of the OnLaunched
method, e.g. after CustomizeStatusBar();
.
To get a better understanding of how it affects the flow of execution and the launch time of the app, you could replace the call await SetupVoiceCommands();
with await Task.Delay(5000);
to imitate the delay and then try moving it around the OnLaunched
method as suggested.