MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Browser processes killed on WM_QUERYENDSESSION

Open
#3,700 4 comments 0 reactions 2 assignees View on GitHub

@aluhrs13 is already working on this.

Since Aug 11, 2023.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

My application is listening for the WM_QUERYENDSESSION message. If the user has not saved his work then a shutdown reason block is set (ShutdownBlockReasonCreate) and FALSE is returned.
When the user logoff, Windows display a screen showing applications that hang with the message defined with ShutdownBlockReasonCreate. If the user cancel the end of the Windows session because he realize that he haven't saved something, then the application is reshown but the browser processes have been killed and the application show balck screen insteed of the web page.

This is reproductible with the WebView2APISample, is you modify the WM_QUERYENDSESSION with:

case WM_QUERYENDSESSION:
{
    // yes, we can shut down
    // Register how we might be restarted
    /*RegisterApplicationRestart(L"--restore", RESTART_NO_CRASH | RESTART_NO_HANG);
    *result = TRUE;
    */
    ShutdownBlockReasonCreate(m_mainWindow, L"Block");
    *result = FALSE;
    return true;
}

Before the user query the end of session:

before

After the user canceled the end of session:

After

I think that the browser process should not be terminated before the application is realy being terminated.

If I use SetProcessShutdownParameters(0x3FF, 0); in the main application to set the shutdown priority the "highest" then the problem disappear. Is this because the application receive early the WM_QUERYENDSESSION and respond FALSE and then others processes do not receive the WM_QUERYENDSESSION ?
Is this workaround will always works ?

AB#46194890

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.