[webkit-changes] [WebKit/WebKit] d39017: [macOS] `-[WKWebView acceptsFirstMouse:]` deadlock...

Aditya Keerthi noreply at github.com
Thu May 11 16:59:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d390171291c8e77d5d90ab818b200f5601f84c17
      https://github.com/WebKit/WebKit/commit/d390171291c8e77d5d90ab818b200f5601f84c17
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-05-11 (Thu, 11 May 2023)

  Changed paths:
    M Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

  Log Message:
  -----------
  [macOS] `-[WKWebView acceptsFirstMouse:]` deadlocks when launching the GPU process
https://bugs.webkit.org/show_bug.cgi?id=256618
rdar://108567032

Reviewed by Wenson Hsieh.

Following the enablement of the GPU process on macOS, an increased number of
hangs are being observed in `-[WKWebView acceptsFirstMouse:]`.

`acceptsFirstMouse` synchronously waits on IPC from the Web process. This is
necessary as the return value depends on the web content that is being clicked
on, and the AppKit API is synchronous. Specifically, returning true allows the
user to click on a view in an inactive window and activate it with a single
click. Returning false means that the user would have to click twice: once to
make the window active, and then to interact with the web view. WebKit only
returns true when the event might begin a drag.

The deadlock observed here is similar to a deadlock that was observed on iOS,
and fixed in 252568 at main. The Web process may be attempting to launch the GPU
process at the same time `RequestAcceptsFirstMouse` is received.  This results
in a sync wait under ``RemoteRenderingBackendProxy::DidInitialize`. While that
method allows for interruptions due to receiving sync messages, the
`RequestAcceptsFirstMouse` message itself is not sync, it is async, and paired
with `HandleAcceptsFirstMouse` (see 240322 at main for more details on that design).

Similar to 252568 at main, the UI process is then unable to initialize the GPU
process, since the message will be added to `m_pendingMessages` on
`AuxiliaryProcessProxy` while waiting for the GPU process to launch. These
messages are dispatched asynchronously, but there is no chance to do so, as the
UI process is waiting for `HandleAcceptsFirstMouse` from the blocked Web process.

To fix, simply return false from `acceptsFirstMouse` when the GPU process has
yet to be initialized. This is low risk, since there would not be any painted
content to interact with if the GPU process does not exist.

* Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::acceptsFirstMouse):

Leverage the helper method added 252568 at main to detect this scenario.

Canonical link: https://commits.webkit.org/263992@main




More information about the webkit-changes mailing list