Bug 215775 - navigator.getGamepads() returns live Gamepad objects instead of snapshots
Summary: navigator.getGamepads() returns live Gamepad objects instead of snapshots
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Safari Technology Preview
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-24 11:55 PDT by James Howard
Modified: 2020-09-22 17:46 PDT (History)
4 users (show)

See Also:


Attachments
Test page (3.05 KB, text/html)
2020-08-24 11:55 PDT, James Howard
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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>