[UWP][JS] Unexpected behavior when closing multiple views RRS feed

  • Question

  • Hello.

    I'm designing my HTML/JS UWP app to have multiple views in certain conditions, and close every created windows when the primary window has been closed('consolidated' event will be triggered). I've created the code below to achieve this scenario in test app.
    document.querySelector("#open").addEventListener("click", function () {
        var targetWindow = window.open("/extWindow.html", null, "msHideView=yes"),
            viewId = MSApp.getViewId(targetWindow),
            ViewManagement = Windows.UI.ViewManagement,
            ApplicationView = ViewManagement.ApplicationView.getForCurrentView();
        ApplicationView.addEventListener("consolidated", function () {
            ViewManagement.ViewSizePreference.default, ApplicationView.id, ViewManagement.ViewSizePreference.default);

    Clicking the close button of primary window(or, removing primary window from task view) is supposed to close all windows that has been opened before, and of course, the primary window itself too. However, the primary window is not closing, and remains look like not responding (see Figure 1 below). In this situation, Visual Studio and task manager indicates this app as suspended(see Figure 2 below), and can be resumed by switching to the app. Not just closing the app in user-friendly way, programmatically calling ApplicationView.tryConsolidateAsync at the primary window will have the same result. This happens either in debug mode or normal release.

    Since calling tryConsolidateAsync when secondary window is not present will work as expected, I'm sure this isn't an expected behavior. I'm using the workaround by calling window.close at the consolidated event handler, to make sure the primary window is closed too. Am I using the wrong method to open additional window, or is it the bug of Windows?

    [Figure 1: A task view when running the app. Left window is the secondary window, and Right window is the primary window. Closing the primary window will initiate 'consolidated' event added when opening the secondary window, so the secondary window will be closed. But the primary window will remain not closed and show the app's splash screen background color, appears like unresponding.]

    [Figure 2: Task Manager reports the closed app as suspended mode, when closing the primary window. Notice to the 'power saving' icon at the right of application's name (PangPlayground JS)]

    This was tested in Windows 10 17134.228.
    Friday, September 14, 2018 12:49 PM

All replies

  • Hi,

    I have asked another engineer to take a look at this question. There might be some time delay.

    Thank you for you patience.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 17, 2018 7:33 AM
  • Hello,

    Roy asked me to follow up with you on this. 

    Based on our research it makes sense what is happening.

    You are setting the targetWindow variable to the extended html page, so in the “consolidated” function you're only closing the ‘target window’ which would be all windows opened by the parent window. I believe this is expected behavior as “targetWindow” would not close the main, parent window. A workaround might be to call window.close() as this does not send the application into a suspended state, instead it terminates the application.

    I hope this helps,


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, October 2, 2018 10:42 PM