Intent to Ship: replace GamepadList with sequence<Gamepad?> for navigator.getGamepads() return value

71 views
Skip to first unread message

François Beaufort 🇫🇷

unread,
Dec 9, 2021, 3:39:27 AM12/9/21
to blink-dev

Contact emails

fbea...@chromium.org

mattre...@chromium.org


Specification

https://www.w3.org/TR/gamepad/#extensions-to-the-navigator-interface


Summary

We intend to replace GamepadList with sequence<Gamepad?> for navigator.getGamepads() return value to follow the spec and match current Gecko and WebKit implementations.


Blink component

Blink>GamepadAPI


Motivation

The W3C Gamepad spec defines the value returned by navigator.getGamepads() as a sequence<Gamepad?>, but Chrome is the only browser to implement it as a GamepadList. It has a similar interface (as it provides an operator[] getter and length attribute) but is not identical as it also provides an .item() accessor. Because of that, web developers tend to use [...navigator.getGamepads()] when they could simply use the Array returned by navigator.getGamepads().


TAG review

As Gecko and WebKit already implement this spec, a TAG review doesn't seem required.


Risks

I've scanned the httparchive.response_bodies.2021_11_01_desktop table and found 995 URLs that contain “.getGamepads()” and “.item(“. Roughly half of them are from the A-Frame, TDV Player, and ArcGIS libraries and don’t use the Gamepad API “.item()” accessor. I’ve looked at 20 randomly picked URLs and didn’t find a single one using the Gamepad API “.item()” accessor. They are used for other APIs like NodeList or TouchList, and not the return value of navigator.getGamepads().

 

Results are publicly available at https://docs.google.com/spreadsheets/d/e/2PACX-1vSFs3guk11lnMMIyvt6pFR586oRYxO0ap20uF1i7U7CZW8aRDS7kJYw05MQCZ3CcijT-Zxq2HFgQcOC/pubhtml

 

Interoperability and Compatibility

 

Gecko: Spec compliant already

WebKit: Spec compliant already

Web developers: Positive (https://www.youtube.com/watch?v=pIIHJ-NIyes&t=527s)

 

Debuggability

No specific DevTools changes are required. This feature is treated like any other JS event/attribute.


Is this feature fully tested by web-platform-tests?

Yes. See https://wpt.fyi/results/gamepad


Tracking bug

https://crbug.com/708201


Estimated milestones

M99


Link to entry on the Chrome Platform Status

https://www.chromestatus.com/feature/5693119438782464


Yoav Weiss

unread,
Dec 9, 2021, 4:08:43 AM12/9/21
to François Beaufort 🇫🇷, blink-dev
LGTM1
Thanks for fixing this papercut!

On Thu, Dec 9, 2021 at 9:39 AM 'François Beaufort 🇫🇷' via blink-dev <blin...@chromium.org> wrote:

Contact emails

fbea...@chromium.org

mattre...@chromium.org


Specification

https://www.w3.org/TR/gamepad/#extensions-to-the-navigator-interface


Summary

We intend to replace GamepadList with sequence<Gamepad?> for navigator.getGamepads() return value to follow the spec and match current Gecko and WebKit implementations.


Blink component

Blink>GamepadAPI


Motivation

The W3C Gamepad spec defines the value returned by navigator.getGamepads() as a sequence<Gamepad?>, but Chrome is the only browser to implement it as a GamepadList. It has a similar interface (as it provides an operator[] getter and length attribute) but is not identical as it also provides an .item() accessor. Because of that, web developers tend to use [...navigator.getGamepads()] when they could simply use the Array returned by navigator.getGamepads().


TAG review

As Gecko and WebKit already implement this spec, a TAG review doesn't seem required.


Risks

I've scanned the httparchive.response_bodies.2021_11_01_desktop table and found 995 URLs that contain “.getGamepads()” and “.item(“. Roughly half of them are from the A-Frame, TDV Player, and ArcGIS libraries and don’t use the Gamepad API “.item()” accessor. I’ve looked at 20 randomly picked URLs and didn’t find a single one using the Gamepad API “.item()” accessor. They are used for other APIs like NodeList or TouchList, and not the return value of navigator.getGamepads().


Given that HA contains 5776330 pages for this run, that's 0.017% of HA origins. But given the fact that there are other explanations to the presence of `item()`, and that out of a random sample you found none that would actually break is reassuring.
It's also reassuring that any page that would break after this change is one that's already broken in Gecko and WebKit.
 

 

Results are publicly available at https://docs.google.com/spreadsheets/d/e/2PACX-1vSFs3guk11lnMMIyvt6pFR586oRYxO0ap20uF1i7U7CZW8aRDS7kJYw05MQCZ3CcijT-Zxq2HFgQcOC/pubhtml

 

Interoperability and Compatibility

 

Gecko: Spec compliant already

WebKit: Spec compliant already

Web developers: Positive (https://www.youtube.com/watch?v=pIIHJ-NIyes&t=527s)

 

Debuggability

No specific DevTools changes are required. This feature is treated like any other JS event/attribute.


Is this feature fully tested by web-platform-tests?

Yes. See https://wpt.fyi/results/gamepad


Tracking bug

https://crbug.com/708201


Estimated milestones

M99


Link to entry on the Chrome Platform Status

https://www.chromestatus.com/feature/5693119438782464


--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAPpwU5K7%2BajfRH0LOxOnitYwG0Hkn5W3M5GevxaOL-CpacCpCA%40mail.gmail.com.

Mike West

unread,
Dec 9, 2021, 4:23:19 AM12/9/21
to Yoav Weiss, François Beaufort 🇫🇷, blink-dev
LGTM2 to match other vendors and the spec. Thanks for cleaning this up.

-mike


Daniel Bratell

unread,
Dec 9, 2021, 9:03:20 AM12/9/21
to Mike West, Yoav Weiss, François Beaufort 🇫🇷, blink-dev
Reply all
Reply to author
Forward
0 new messages