Bug 247368

Summary: Crash in gamepads in WKWebView apps that also listen to the GameController framework themselves
Product: WebKit Reporter: Brady Eidson <beidson>
Component: WebKit Misc.Assignee: Brady Eidson <beidson>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch ggaren: review+

Brady Eidson
Reported 2022-11-02 09:22:40 PDT
Crash in gamepads in WKWebView apps that also listen to the GameController framework themselves If an app's UI process uses GameController framework directly before a web page in a WKWebView does, then the GameController framework tells that app about attached controllers ahead of time. This subtlely gets WebKit's notion of attached game controllers out of sync with reality. If the user then moves a joystick on the gamepad to cause input (but not press a button to cause the gamepad to be exposed to the web page) then we crash. (And ASSERT in debug builds)
Attachments
Patch (1.92 KB, patch)
2022-11-02 10:05 PDT, Brady Eidson
ggaren: review+
Brady Eidson
Comment 1 2022-11-02 10:05:12 PDT
Brady Eidson
Comment 2 2022-11-02 10:35:06 PDT
Geoffrey Garen
Comment 3 2022-11-02 10:38:13 PDT
Comment on attachment 463363 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=463363&action=review r=me > Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp:118 > + for (size_t i = 0; i < m_gamepads.size() && i < platformGamepads.size(); ++i) { You can compute 'auto end = std::min(m_gamepads.size(), platformGamepads.size())' outside the loop. A bit clearer and a bit more efficient.
Brady Eidson
Comment 4 2022-11-02 15:03:15 PDT
EWS
Comment 5 2022-11-02 16:28:53 PDT
Committed 256255@main (809586a6b81e): <https://commits.webkit.org/256255@main> Reviewed commits have been landed. Closing PR #6054 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.