New issue
Advanced search Search tips

Issue 855630 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Gamepad: reducing .buttons array size "locks up" future values

Project Member Reported by mustaq@chromium.org, Jun 22 2018

Issue description

This bug repros only with --enable-features=UserActivationV2.

Apparently reducing the .buttons array size through gamepadController.setButtonCount() "locks up" the output (with UAv2 only).

Step 0. Starting value of buttons.
    => [pressed=true,value=1],[pressed=false,value=0]

Step 1. Setting button data works initially.
gamepadController.setButtonData(0, 0, .2);
    => [pressed=true,value=0.2],[pressed=false,value=0]

Step 2. Works after setting axis data.
gamepadController.setAxisData(0, 0, .9);
gamepadController.setButtonData(0, 0, .3);
    => [pressed=true,value=0.3],[pressed=false,value=0]

Step 3. Works after setting axis count.
gamepadController.setAxisCount(0, 1);
gamepadController.setButtonData(0, 0, .4);
    => [pressed=true,value=0.4],[pressed=false,value=0]

Step 4. *Doesn't* work after setting button count.
gamepadController.setButtonCount(0, 1);
    => [pressed=true,value=0.4],[pressed=false,value=0]

Step 5. Then even setting button data *doesn't* work.
gamepadController.setButtonData(0, 0, .5);
    => [pressed=true,value=0.4],[pressed=false,value=0]

 

Comment 1 by mustaq@chromium.org, Jun 22 2018

Blocking: 802294
As Matt suspected in a private thread, there could be an issue with old-vs-new buffers.

Comment 2 by mustaq@chromium.org, Jun 22 2018

Summary: Gamepad: reducing .buttons array size "locks up" future values (was: gamepad/gamepad-polling-access.html layouttest fails suspiciously with UAv2)
This affects gamepad/gamepad-polling-access.html layouttest with UAv2 enabled.
Owner: mattreynolds@chromium.org
I don't think this is related to the buffer reuse issue because we call getGamepads() each time instead of referring to an array returned from a previous call. 

We don't expect the number of buttons or axes to change once a gamepad is connected. There isn't a good way for Chrome to handle this for actual devices because any change to the HID report could cause all other buttons to be reordered as well, requiring a different mapping. This test should be rewritten to disconnect the gamepad before changing the button or axis counts and to wait for gamepadconnected before verifying the new button state.

On the other hand there's no reason a data fetcher couldn't change the number of buttons after the device is connected, it's just hard to imagine how this could work for typical HID gamepads. If we do not plan to support this we should at least emit a warning when it happens. We have logic in SampleGamepads that considers some fields constant for the life of a connected gamepad, but the button/axis counts are currently not considered constant. Some fields support a single change from null->non-null to allow capabilities to be initialized after the connection event; for similar reasons perhaps we should also support changes that extend the button/axis count but not decrease it.

https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc?l=91

There are gamepads that can change their HID output report without being physically disconnected (e.g., Logitech F310 with its XInput/DirectInput mode switch), but they do so by simulating a disconnection, which makes them appear as a newly-connected device to the underlying OS.

Comment 4 by mustaq@chromium.org, Jun 22 2018

Blocking: -802294
Labels: -UserActivation
UAv2 specific fixes will be done separately.
Project Member

Comment 5 by bugdroid1@chromium.org, Jun 25 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/acd5edaad3c91b394d8fae3a2984880fc571f2a2

commit acd5edaad3c91b394d8fae3a2984880fc571f2a2
Author: Mustaq Ahmed <mustaq@google.com>
Date: Mon Jun 25 15:04:32 2018

[UAv2] Add a virtual suite for gamepad/, move an existing test here.

Change-Id: I6fb5914ede0c6741284b9962afb269a8c51ff175
Bug:  852517 , 855630
Reviewed-on: https://chromium-review.googlesource.com/1099602
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570040}
[modify] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/VirtualTestSuites
[add] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/gamepad/full-screen-gamepad-expected.txt
[rename] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/gamepad/full-screen-gamepad.html
[modify] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/gamepad/gamepad-detached-no-crash-expected.txt
[modify] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/gamepad/gamepad-detached-no-crash.html
[modify] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/gamepad/gamepad-polling-access.html
[delete] https://crrev.com/413ffeb49b317213bb2350da21b19ec4607c50d0/third_party/WebKit/LayoutTests/user-activation-v2/full-screen-gamepad-expected.txt
[rename] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/virtual/user-activation-v2/gamepad/README.txt
[rename] https://crrev.com/acd5edaad3c91b394d8fae3a2984880fc571f2a2/third_party/WebKit/LayoutTests/virtual/user-activation-v2/gamepad/full-screen-gamepad-expected.txt

Status: Assigned (was: Available)

Sign in to add a comment