Bug 215775

Summary: navigator.getGamepads() returns live Gamepad objects instead of snapshots
Product: WebKit Reporter: James Howard <jameshoward>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: beidson, jameshoward, juberti, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: All   
Attachments:
Description Flags
Test page none

Description James Howard 2020-08-24 11:55:06 PDT
Created attachment 407119 [details]
Test page

navigator.getGamepads() returns live Gamepad objects instead of snapshots

According to the HTML5 Gamepad spec[1], each gamepad object returned from navigator.getGamepads() is to be a snapshot of the gamepad state:

> getGamepads()
> Retrieve a snapshot of the data for the the currently connected and interacted-with gamepads.

Attached is a small test page that saves the result of Gamepad objects returned from getGamepads() each animation tick, and checks to see if they are snapshots or if they are live objects, by comparing with a manually created snapshot object. Testing this page with a gamepad in Safari will show a number of mismatch errors in the top line of the textarea on the page -- errors being when the saved Gamepad object doesn't match up with the manual snapshot because it changed since getGamepads() was called.

Steps to reproduce:
1. Load attached test page
2. Press buttons on an attached gamepad
3. Count mismatch errors shown on test page

Reproduces in:
Version/14.0 Safari/605.1.15 (macOS 10.15.6)
Version/14.0 Safari/605.1.15 (iPadOS 14 Beta 5 (18A5351d))
Version/13.1.2 Safari/604.1 (iOS 13.6)

Does not reproduce in:
Chrome Version 84.0.4147.135 (macOS 10.15.6)


[^1] https://w3c.github.io/gamepad/#navigator-interface-extension
Comment 1 Radar WebKit Bug Importer 2020-08-24 16:52:17 PDT
<rdar://problem/67707022>