Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e94e205403f594c33c11f9db9d2165f254f4037d
      
https://github.com/WebKit/WebKit/commit/e94e205403f594c33c11f9db9d2165f254f4037d
  Author: Chris Dumez <[email protected]>
  Date:   2022-12-09 (Fri, 09 Dec 2022)

  Changed paths:
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebKit/UIProcess/WebProcessPool.cpp
    M Source/WebKit/UIProcess/WebProcessPool.h
    M Source/WebKit/UIProcess/WebProcessPool.messages.in
    M Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.cpp

  Log Message:
  -----------
  [ macOS wk2 ] gamepad/gamepad-polling-access.html : com.apple.WebKit:  
WebKit::WebGamepadProvider::setInitialGamepads
https://bugs.webkit.org/show_bug.cgi?id=249023
rdar://103182584

Reviewed by Brady Eidson.

When the first client get added to the WebGamepadProvider, it sends a
StartedUsingGamepads IPC to the UIProcess. In turn, the UIProcess will set a
SetInitialGamepads back to initialize WebGamepadProvider's m_gamepads. This
also turns on monitoring in the UIProcess so that GamepadConnected /
GamepadDisconnected IPCs will get sent by the UIProcess to keep
WebGamepadProvider::m_gamepads up to date.

When the last client gets removed from the WebGamepadProvider, it would send a
StoppedUsingGamepads IPC to the UIProcess to stop the monitoring (and the
sending of GamepadConnected / GamepadDisconnected IPCs). However, we wouldn't
clear m_gamepads. As a result, if a new client would get added later on, we
would send the StartedUsingGamepads again to the UIProcess, which would send
up calling SetInitialGamepads() and would hit the assertion because m_gamepads
is not empty.

To address the issue, we now clear m_gamepads after sending the
StoppedUsingGamepads to the UIProcess. Note that I had to make the
StoppedUsingGamepads async with a reply so that we only clear m_gamepads once
we know that the UIProcess has stopped monitoring for us and will no longer
send GamepadConnected / GamepadDisconnected IPCs. Otherwise, we would carry the
risk of getting GamepadConnected / GamepadDisconnected IPCs after clearing
m_gamepads, which would hit assertions in those IPC handlers.

The fix is speculative since I wasn't able to reproduce the crash. This is
- I think - the most logical explanation for the crash though.

* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::stoppedUsingGamepads):
* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/UIProcess/WebProcessPool.messages.in:
* Source/WebKit/WebProcess/Gamepad/WebGamepadProvider.cpp:
(WebKit::WebGamepadProvider::stopMonitoringGamepads):

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to