[Webkit-unassigned] [Bug 284375] [visionOS] "gamepadconnected" event does not fire unless gamepad permission has already been given to Safari

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 18 19:38:52 PST 2024


https://bugs.webkit.org/show_bug.cgi?id=284375

phyllis at phys.nthu.edu.tw changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |phyllis at phys.nthu.edu.tw

--- Comment #2 from phyllis at phys.nthu.edu.tw ---
Adding more details to this issue - what happens on AVP is this:

- The first time we call `navigator.getGamepads()`, Safari prompts user for permission via a banner. The call synchronously returns an array with no meaningful elements `[null,null,null,null]`.
- If we call `navigator.getGamepads()` before permission is granted, it continues to return that array.
- There is no API for us to actively query the permission state. Neither is there a callback function to be invoked when permission is granted or denied.
- Even if the gamepad is connected via bluetooth, no `gamepadconnected` event will be emitted before permission is granted.

Below is what I feel could be a bit troublesome to deal with:

To trigger `gamepadconnected` event, **both** conditions must be met:
   a. User presses a button on the gamepad after granting permission (this is to mitigate fingerprinting, as specified in https://www.w3.org/TR/gamepad/ )
   b. `navigator.getGamepads()` is called again
When the above conditions are met, `gamepadconnected` event is emitted. Subsequent `navigator.getGamepads()` calls return an array with gamepad information.
The order of actions in steps a and b can be interchanged, but both must occur for the `gamepadconnected` event to fire. If b happens first, the event is emitted when user presses a button on the gamepad. If a happens first, the event is emitted right after the next `navigator.getGamepads()` call returns (NOT when you press the button). Which is really weird, because that is not the time gamepad is connected, not the time gamepad is invoked (via a button press), nor the time permission is granted. It just so happens to randomly emit an event and the fact that gamepadconnected event only fires after a specific API call (and therefore the timing depends on when the client calls the API) doesn't seem to make much sense...

You can use this for a repro on AVP device with VisionOS 2+: https://escapiststupor.github.io/gamepad-test

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20241219/7ddb8178/attachment.htm>


More information about the webkit-unassigned mailing list