It appears that with certain controls as children in a secondary window, once the window is closed and the main app is backgrounded (minimized), the main app will have long and variable delays returning to the foreground after restoring, usually on the order of minutes or even more. This is very easy to reproduce with a SplitView, though I believe other (but not all) controls exhibit this same problem. Currently targeting Platform Version 2004.
Here's a simple class to launch a window, following the basic tutorial for using ApplicationView:
internal class TestWindow
{
private ApplicationView View;
private Window window;
public TestWindow(ApplicationView view)
{
View = view;
View.Consolidated += OnConsolidated;
}
private void OnConsolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args)
{
View.Consolidated -= OnConsolidated;
window.Close();
}
public static async Task<bool> OpenWindowAsync()
{
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
var appView = ApplicationView.GetForCurrentView();
var window = new TestWindow(appView);
window.window = Window.Current;
newViewId = appView.Id;
Window.Current.Content = new WindowContent();
// You have to activate the window in order to show it later.
Window.Current.Activate();
});
var ret = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
return ret;
}
}
Here is WindowContent.xaml:
<Page
x:Class="Window_Test.WindowContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Window_Test"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<SplitView/>
</Page>
Steps to reproduce:
- Open secondary window
- Close secondary window
- Minimize main window
- Restore main window
At this point the main window will not respond to input for some time. It usually will return to normal operation eventually, though this can take many minutes. I can see the EnteredBackground event being triggered (via logs), but the LeavingBackground event does not trigger until just before the main window becomes responsive again.