Skip to content

Commit

Permalink
Crash in gamepads in WKWebView apps that also listen to the GameContr…
Browse files Browse the repository at this point in the history
…oller framework themselves

https://bugs.webkit.org/show_bug.cgi?id=247368 and rdar://100036005

Reviewed by Geoff Garen.

No test possible for now.

* Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp:
(WebKit::UIGamepadProvider::platformGamepadInputActivity): Handle a mismatch between platform gamepads
  and established gamepads. This can happen when there's "invisible" gamepads still, and the current
  input event will not reveal them to WebContent. And it's fine: Things get resolved when an input
  even *does* reveal the gamepads to the web page.

Canonical link: https://commits.webkit.org/256255@main
  • Loading branch information
beidson committed Nov 2, 2022
1 parent f1b974f commit 809586a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,12 @@ void UIGamepadProvider::platformGamepadDisconnected(PlatformGamepad& gamepad)
void UIGamepadProvider::platformGamepadInputActivity(EventMakesGamepadsVisible eventVisibility)
{
auto platformGamepads = GamepadProvider::singleton().platformGamepads();
ASSERT(platformGamepads.size() == m_gamepads.size());

for (size_t i = 0; i < platformGamepads.size(); ++i) {
if (!platformGamepads[i]) {
ASSERT(!m_gamepads[i]);
auto end = std::min(m_gamepads.size(), platformGamepads.size());
for (size_t i = 0; i < end; ++i) {
if (!m_gamepads[i] || !platformGamepads[i])
continue;
}

ASSERT(m_gamepads[i]);
m_gamepads[i]->updateFromPlatformGamepad(*platformGamepads[i]);
}

Expand Down

0 comments on commit 809586a

Please sign in to comment.