• Christopher Cameron's avatar
    RemoteMacViews: Fix hang at command-Q · 464fae69
    Christopher Cameron authored
    When we call -[NSApp terminate] in the app shim process, this does
    not immediately terminate. Rather, it
     0. Sends the message appShimController_->host()->QuitApp() and waits
        for a reply before actually terminating.
     1. In the browser, this call hits ExtensionAppShimHandler::
        CloseBrowsersForApp
     2. Which will end up calling NativeWidgetMac::Close
     3. Which will then politely request that the app shim process close
        the corresponding window via
        views_bridge_mac::mojom::BridgedNativeWidget::CloseWindow
     4. Which will send an ack back to the browser via
        views_bridge_mac::mojom::BridgedNativeWidgetHost::OnWindowHasClosed
     5. Whereupon the browser window will be registered as closed, and a
        close message will be sent to the app shim, and the wait for
        termination will break
    
    This ends up not working at step 3. Our suspended terminate ends up
    running a nested message loop inside a mojo message handler, and so
    it will never execute the CloseWindow message, and therefore never
    close.
    
    Change the logic at [0] to send the QuitApp message, and then
    immediately terminate the application.
    
    Bug: 902583
    Change-Id: I60fd7b5fdf9f145369d06219e8ebef36cdcd0f44
    Reviewed-on: https://chromium-review.googlesource.com/c/1364220Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
    Commit-Queue: ccameron <ccameron@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#614922}
    464fae69
app_shim_delegate.h 1.3 KB