[Gamepad] Implement renderer-side dispatch of Raw Input Change Event API [chromium/src : main]

0 views
Skip to first unread message

Sneha Agarwal (Gerrit)

unread,
Sep 4, 2025, 12:51:16 PMSep 4
to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
Attention needed from Gabriel Brito and Michael Tang

Sneha Agarwal added 1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Sneha Agarwal . resolved

Hi Gabriel and Michael,

Please review this CL when you get a chance. I am working on fixing the CI errors on the unit test (this CL takes a dependency on the browser-side changes). If you could ignore that for now and just review the core renderer logic, I would really appreciate it.

Thanks

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Michael Tang
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
Gerrit-Change-Number: 6897875
Gerrit-PatchSet: 3
Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
Gerrit-Comment-Date: Thu, 04 Sep 2025 16:51:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Tang (Gerrit)

unread,
Sep 11, 2025, 9:06:43 PMSep 11
to Sneha Agarwal, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
Attention needed from Gabriel Brito and Sneha Agarwal

Michael Tang added 13 comments

Patchset-level comments
File-level comment, Patchset 13 (Latest):
Michael Tang . resolved

Sorry for the delay! Here's a first pass, I'll take a close look at your tests tomorrow!

File content/child/runtime_features.cc
Line 291, Patchset 13 (Latest): raw_ref(features::kWebIdentityDigitalCredentials), kDefault},
Michael Tang . unresolved

nit: Is this change required?

File content/web_test/renderer/gamepad_controller.cc
Line 114, Patchset 13 (Latest): return gin::Wrappable<GamepadControllerBindings>::GetObjectTemplateBuilder(
isolate)
.SetMethod("connect", &GamepadControllerBindings::Connect)
.SetMethod("dispatchConnected",
&GamepadControllerBindings::DispatchConnected)
.SetMethod("disconnect", &GamepadControllerBindings::Disconnect)
.SetMethod("setId", &GamepadControllerBindings::SetId)
.SetMethod("setButtonCount", &GamepadControllerBindings::SetButtonCount)
.SetMethod("setButtonData", &GamepadControllerBindings::SetButtonData)
.SetMethod("setAxisCount", &GamepadControllerBindings::SetAxisCount)
.SetMethod("setAxisData", &GamepadControllerBindings::SetAxisData)
.SetMethod("setDualRumbleVibrationActuator",
&GamepadControllerBindings::SetDualRumbleVibrationActuator)
.SetMethod("setTriggerRumbleVibrationActuator",
&GamepadControllerBindings::SetTriggerRumbleVibrationActuator)
.SetMethod("setTouchCount", &GamepadControllerBindings::SetTouchCount)
.SetMethod("setTouchData", &GamepadControllerBindings::SetTouchData)
.SetMethod("dispatchRawInputChanged",
&GamepadControllerBindings::DispatchRawInputChanged);
Michael Tang . unresolved
```suggestion
return gin::Wrappable<GamepadControllerBindings>::GetObjectTemplateBuilder(
isolate)
.SetMethod("connect", &GamepadControllerBindings::Connect)
.SetMethod("dispatchConnected",
&GamepadControllerBindings::DispatchConnected)
.SetMethod("disconnect", &GamepadControllerBindings::Disconnect)
.SetMethod("dispatchRawInputChanged",
&GamepadControllerBindings::DispatchRawInputChanged)
.SetMethod("setId", &GamepadControllerBindings::SetId)
.SetMethod("setButtonCount", &GamepadControllerBindings::SetButtonCount)
.SetMethod("setButtonData", &GamepadControllerBindings::SetButtonData)
.SetMethod("setAxisCount", &GamepadControllerBindings::SetAxisCount)
.SetMethod("setAxisData", &GamepadControllerBindings::SetAxisData)
.SetMethod("setDualRumbleVibrationActuator",
&GamepadControllerBindings::SetDualRumbleVibrationActuator)
.SetMethod("setTriggerRumbleVibrationActuator",
&GamepadControllerBindings::SetTriggerRumbleVibrationActuator)
.SetMethod("setTouchCount", &GamepadControllerBindings::SetTouchCount)
.SetMethod("setTouchData", &GamepadControllerBindings::SetTouchData);
```
style nit: Consistent ordering
Line 145, Patchset 13 (Latest):void GamepadControllerBindings::DispatchRawInputChanged(int index) {
if (controller_) {
controller_->DispatchRawInputChanged(index);
}
}

void GamepadControllerBindings::Disconnect(int index) {
if (controller_)
controller_->Disconnect(index);
}
Michael Tang . unresolved
```suggestion
void GamepadControllerBindings::Disconnect(int index) {
if (controller_)
controller_->Disconnect(index);
}
void GamepadControllerBindings::DispatchRawInputChanged(int index) {
if (controller_) {
controller_->DispatchRawInputChanged(index);
}
}
```
style nit: Consistent ordering.
Line 414, Patchset 13 (Latest):void GamepadController::DispatchRawInputChanged(int index) {
Michael Tang . unresolved

style nit: move above `GamepadController::SetId` for consistent ordering of methods

File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
Line 1, Patchset 13 (Latest):
Michael Tang . unresolved

```suggestion
```

nit: remove empty line

File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.cc
Line 1, Patchset 13 (Latest):
Michael Tang . unresolved

nit: remove empty line

File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event_init.idl
Line 5, Patchset 13 (Latest):dictionary GamepadRawInputChangeEventInit : EventInit {
Michael Tang . unresolved

Where do we use this type?

File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
Line 364, Patchset 13 (Latest): DidRemoveGamepadEventListeners();
Michael Tang . unresolved

Is this effectively the same as `DidRemoveAllEventListeners`?

Line 399, Patchset 13 (Latest): if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
compare_all_axes = has_input_changed_event_listener_;
compare_all_buttons = has_input_changed_event_listener_;
}
Michael Tang . unresolved

Should we compare all axes/buttons even when there is no raw input change event listener attached?

Line 494, Patchset 13 (Latest): Vector<int> buttons_pressed = compare_result.GetButtonsPressed(index);
Vector<int> buttons_released = compare_result.GetButtonsReleased(index);
Michael Tang . unresolved

Are these excluded from the early exit below because encode the change in `buttons_value_changed`, which is already captured by the latter?

If so, can we move them after the early exit and add a comment describe why?

File third_party/blink/renderer/platform/runtime_enabled_features.json5
Line 2505, Patchset 13 (Latest): {
Michael Tang . unresolved
```suggestion
{
```
nit: trailing whitespace
File third_party/blink/web_tests/gamepad/gamepad-raw-input-change-event.html
Line 1, Patchset 13 (Latest):
Michael Tang . unresolved

nit: remove this line and clean up trailing whitespace in this file.

Open in Gerrit

Related details

Attention is currently required from:
  • Gabriel Brito
  • Sneha Agarwal
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
    Gerrit-Change-Number: 6897875
    Gerrit-PatchSet: 13
    Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
    Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Comment-Date: Fri, 12 Sep 2025 01:06:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Gabriel Brito (Gerrit)

    unread,
    Sep 12, 2025, 12:51:38 AMSep 12
    to Sneha Agarwal, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
    Attention needed from Sneha Agarwal

    Gabriel Brito added 11 comments

    Patchset-level comments
    Gabriel Brito . resolved

    Did a quick first pass today. Will do another one tomorrow.

    File content/child/runtime_features.cc
    Line 291, Patchset 13 (Latest): raw_ref(features::kWebIdentityDigitalCredentials), kDefault},
    Michael Tang . unresolved

    nit: Is this change required?

    Gabriel Brito

    Maybe `git cl format` did it when Sneha modified the file before. I think that, if reverted, `format` won't complain since we won't have touched this file.

    File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
    Line 266, Patchset 13 (Latest):bool GamepadStateCompareResult::CompareTouches(Gamepad* old_gamepad,
    File third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.cc
    Line 87, Patchset 13 (Latest): NotifyControllers();
    Gabriel Brito . unresolved

    I think that this isn't the mechanism we want to use to trigger the event dispatching, right? Should we add a TODO comment here linking to https://issues.chromium.org/issues/438906421?

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
    Line 15, Patchset 13 (Latest):class GamepadRawInputChangeEvent : public Event {
    Gabriel Brito . unresolved

    Is there any reason for this to not inherit from `GamepadEvent`?

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.cc
    Line 48, Patchset 13 (Latest):GamepadRawInputChangeEvent::~GamepadRawInputChangeEvent() = default;
    Gabriel Brito . unresolved

    super nit: add blank line

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event_init.idl
    Line 5, Patchset 13 (Latest):dictionary GamepadRawInputChangeEventInit : EventInit {
    Michael Tang . unresolved

    Where do we use this type?

    Gabriel Brito

    Although we don't use it directly in the code, I think that this is exposed to pages via js if they want to create `GamepadRawInputChangeEvent`s themselves?

    File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
    Line 452, Patchset 13 (Latest): if (has_input_changed_event_listener_ && !is_connected &&
    !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
    Gabriel Brito . unresolved

    This is a confusing condition. How can `is_connected` and `is_disconnected` be both false for us to fire the event? What is the purpose of checking `gamepads_back_[i]`?

    Line 504, Patchset 13 (Latest): UseCounter::Count(context, WebFeature::kGamepadRawInputChangeEventListener);
    Gabriel Brito . unresolved

    Should we move this to where the event handler is added to avoid calling it unnecessarily every time an event is to be dispatched?

    File third_party/blink/renderer/platform/runtime_enabled_features.json5
    Line 2507, Patchset 13 (Latest): settable_from_internals: true,
    Gabriel Brito . unresolved

    Why do we need `settable_from_internals` and `public`?

    File third_party/blink/web_tests/gamepad/gamepad-raw-input-change-event.html
    Line 19, Patchset 13 (Latest):
    Gabriel Brito . unresolved

    nit: delete the white spaces in this file (pink squares in Gerrit)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Sneha Agarwal
    Gerrit-Comment-Date: Fri, 12 Sep 2025 04:51:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Michael Tang <ta...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Sneha Agarwal (Gerrit)

    unread,
    Sep 29, 2025, 7:02:18 PMSep 29
    to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
    Attention needed from Gabriel Brito and Michael Tang

    Sneha Agarwal added 21 comments

    Patchset-level comments
    File-level comment, Patchset 16 (Latest):
    Sneha Agarwal . resolved

    Hi Michael and Gabriel,
    I have addressed your feedback.
    Thanks

    File content/child/runtime_features.cc
    Line 291, Patchset 13: raw_ref(features::kWebIdentityDigitalCredentials), kDefault},
    Michael Tang . resolved

    nit: Is this change required?

    Gabriel Brito

    Maybe `git cl format` did it when Sneha modified the file before. I think that, if reverted, `format` won't complain since we won't have touched this file.

    Sneha Agarwal

    Done

    File content/web_test/renderer/gamepad_controller.cc
    Line 114, Patchset 13: return gin::Wrappable<GamepadControllerBindings>::GetObjectTemplateBuilder(

    isolate)
    .SetMethod("connect", &GamepadControllerBindings::Connect)
    .SetMethod("dispatchConnected",
    &GamepadControllerBindings::DispatchConnected)
    .SetMethod("disconnect", &GamepadControllerBindings::Disconnect)
    .SetMethod("setId", &GamepadControllerBindings::SetId)
    .SetMethod("setButtonCount", &GamepadControllerBindings::SetButtonCount)
    .SetMethod("setButtonData", &GamepadControllerBindings::SetButtonData)
    .SetMethod("setAxisCount", &GamepadControllerBindings::SetAxisCount)
    .SetMethod("setAxisData", &GamepadControllerBindings::SetAxisData)
    .SetMethod("setDualRumbleVibrationActuator",
    &GamepadControllerBindings::SetDualRumbleVibrationActuator)
    .SetMethod("setTriggerRumbleVibrationActuator",
    &GamepadControllerBindings::SetTriggerRumbleVibrationActuator)
    .SetMethod("setTouchCount", &GamepadControllerBindings::SetTouchCount)
    .SetMethod("setTouchData", &GamepadControllerBindings::SetTouchData)
    .SetMethod("dispatchRawInputChanged",
    &GamepadControllerBindings::DispatchRawInputChanged);
    Michael Tang . resolved
    ```suggestion
    return gin::Wrappable<GamepadControllerBindings>::GetObjectTemplateBuilder(
    isolate)
    .SetMethod("connect", &GamepadControllerBindings::Connect)
    .SetMethod("dispatchConnected",
    &GamepadControllerBindings::DispatchConnected)
    .SetMethod("disconnect", &GamepadControllerBindings::Disconnect)
    .SetMethod("dispatchRawInputChanged",
    &GamepadControllerBindings::DispatchRawInputChanged)
    .SetMethod("setId", &GamepadControllerBindings::SetId)
    .SetMethod("setButtonCount", &GamepadControllerBindings::SetButtonCount)
    .SetMethod("setButtonData", &GamepadControllerBindings::SetButtonData)
    .SetMethod("setAxisCount", &GamepadControllerBindings::SetAxisCount)
    .SetMethod("setAxisData", &GamepadControllerBindings::SetAxisData)
    .SetMethod("setDualRumbleVibrationActuator",
    &GamepadControllerBindings::SetDualRumbleVibrationActuator)
    .SetMethod("setTriggerRumbleVibrationActuator",
    &GamepadControllerBindings::SetTriggerRumbleVibrationActuator)
    .SetMethod("setTouchCount", &GamepadControllerBindings::SetTouchCount)
    .SetMethod("setTouchData", &GamepadControllerBindings::SetTouchData);
    ```
    style nit: Consistent ordering
    Sneha Agarwal

    Done

    Line 145, Patchset 13:void GamepadControllerBindings::DispatchRawInputChanged(int index) {

    if (controller_) {
    controller_->DispatchRawInputChanged(index);
    }
    }

    void GamepadControllerBindings::Disconnect(int index) {
    if (controller_)
    controller_->Disconnect(index);
    }
    Michael Tang . resolved
    ```suggestion
    void GamepadControllerBindings::Disconnect(int index) {
    if (controller_)
    controller_->Disconnect(index);
    }
    void GamepadControllerBindings::DispatchRawInputChanged(int index) {
    if (controller_) {
    controller_->DispatchRawInputChanged(index);
    }
    }
    ```
    style nit: Consistent ordering.
    Sneha Agarwal

    Done

    Line 414, Patchset 13:void GamepadController::DispatchRawInputChanged(int index) {
    Michael Tang . resolved

    style nit: move above `GamepadController::SetId` for consistent ordering of methods

    Sneha Agarwal

    Done

    File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
    Line 266, Patchset 13:bool GamepadStateCompareResult::CompareTouches(Gamepad* old_gamepad,
    Gabriel Brito . resolved
    Sneha Agarwal

    Done

    File third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.cc
    Line 87, Patchset 13: NotifyControllers();
    Gabriel Brito . resolved

    I think that this isn't the mechanism we want to use to trigger the event dispatching, right? Should we add a TODO comment here linking to https://issues.chromium.org/issues/438906421?

    Sneha Agarwal

    Done

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
    Line 15, Patchset 13:class GamepadRawInputChangeEvent : public Event {
    Gabriel Brito . resolved

    Is there any reason for this to not inherit from `GamepadEvent`?

    Sneha Agarwal

    We only expose the gamepadSnapshot property and do not use or expose the standard gamepad attribute from GamepadEvent. Since this event is focused on providing a snapshot of the gamepad state at the time of the event, inheriting from Event is more appropriate than inheriting from GamepadEvent

    Line 1, Patchset 13:
    Michael Tang . resolved

    ```suggestion
    ```

    nit: remove empty line

    Sneha Agarwal

    Done

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.cc
    Line 1, Patchset 13:
    Michael Tang . resolved

    nit: remove empty line

    Sneha Agarwal

    Done

    Line 48, Patchset 13:GamepadRawInputChangeEvent::~GamepadRawInputChangeEvent() = default;
    Gabriel Brito . resolved

    super nit: add blank line

    Sneha Agarwal

    Done

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event_init.idl
    Line 5, Patchset 13:dictionary GamepadRawInputChangeEventInit : EventInit {
    Michael Tang . resolved

    Where do we use this type?

    Gabriel Brito

    Although we don't use it directly in the code, I think that this is exposed to pages via js if they want to create `GamepadRawInputChangeEvent`s themselves?

    Sneha Agarwal

    Yes, that is correct.
    FrozenArray<long> in the dictionary is exposed to JavaScript, so web developers can create their own GamepadRawInputChangeEvent objects and pass arrays for these properties.

    File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
    Line 364, Patchset 13: DidRemoveGamepadEventListeners();
    Michael Tang . resolved

    Is this effectively the same as `DidRemoveAllEventListeners`?

    Sneha Agarwal

    yes it is functionally equivalent to calling DidRemoveAllEventListeners.

    Line 399, Patchset 13: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {

    compare_all_axes = has_input_changed_event_listener_;
    compare_all_buttons = has_input_changed_event_listener_;
    }
    Michael Tang . resolved

    Should we compare all axes/buttons even when there is no raw input change event listener attached?

    Sneha Agarwal

    No we should not compare all axes and buttons when no listener is attached. I have improved the name of the variables and added a comment.

    Line 452, Patchset 13: if (has_input_changed_event_listener_ && !is_connected &&

    !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
    Gabriel Brito . resolved

    This is a confusing condition. How can `is_connected` and `is_disconnected` be both false for us to fire the event? What is the purpose of checking `gamepads_back_[i]`?

    Sneha Agarwal

    Yes, both is_connected and is_disconnected are false when the gamepad's connection state did not change. It's present in both samples. This condition ensures we only dispatch a raw input change event for input changes (not connection/disconnection). The comment above makes that clear. The checks for gamepads_[i] and gamepads_back_[i] confirm the gamepad exists in both the current and previous states, so we don't fire input change events for gamepads that just appeared or disappeared. I have improved the comment to make the intent clearer.

    Line 494, Patchset 13: Vector<int> buttons_pressed = compare_result.GetButtonsPressed(index);

    Vector<int> buttons_released = compare_result.GetButtonsReleased(index);
    Michael Tang . resolved

    Are these excluded from the early exit below because encode the change in `buttons_value_changed`, which is already captured by the latter?

    If so, can we move them after the early exit and add a comment describe why?

    Sneha Agarwal

    Sure, thanks for the suggestion, I have moved it and added comment.

    Line 504, Patchset 13: UseCounter::Count(context, WebFeature::kGamepadRawInputChangeEventListener);
    Gabriel Brito . resolved

    Should we move this to where the event handler is added to avoid calling it unnecessarily every time an event is to be dispatched?

    Sneha Agarwal

    I think It should stay here as the counter metrics should record the actual feature usage and not just feature availability. If we move it to the event handler registration, it will count even if no events are ever dispatched, which would inflate the metric and not reflect real usage.

    File third_party/blink/renderer/platform/runtime_enabled_features.json5
    Line 2505, Patchset 13: {
    Michael Tang . resolved
    ```suggestion
    {
    ```
    nit: trailing whitespace
    Sneha Agarwal

    Done

    Line 2507, Patchset 13: settable_from_internals: true,
    Gabriel Brito . resolved

    Why do we need `settable_from_internals` and `public`?

    Sneha Agarwal

    Removed Settable_from_internals, but keeping public: true, so the feature is accessible to web content

    File third_party/blink/web_tests/gamepad/gamepad-raw-input-change-event.html
    Line 1, Patchset 13:
    Michael Tang . resolved

    nit: remove this line and clean up trailing whitespace in this file.

    Sneha Agarwal

    Done

    Line 19, Patchset 13:
    Gabriel Brito . resolved

    nit: delete the white spaces in this file (pink squares in Gerrit)

    Sneha Agarwal

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Gabriel Brito
    • Michael Tang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
    Gerrit-Change-Number: 6897875
    Gerrit-PatchSet: 16
    Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
    Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Attention: Michael Tang <ta...@microsoft.com>
    Gerrit-Comment-Date: Mon, 29 Sep 2025 23:02:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
    Comment-In-Reply-To: Michael Tang <ta...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Gabriel Brito (Gerrit)

    unread,
    Oct 1, 2025, 10:09:59 PMOct 1
    to Sneha Agarwal, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
    Attention needed from Michael Tang and Sneha Agarwal

    Gabriel Brito added 7 comments

    Patchset-level comments
    File-level comment, Patchset 20 (Latest):
    Gabriel Brito . resolved

    I had very little time to review it today. Hope to be able to give more meaningful feedback about the tests soon.

    File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
    Line 282, Patchset 17: if (!new_touches || !old_touches) {
    return true;
    }
    Gabriel Brito . unresolved

    Should we add a test for this condition?

    Line 282, Patchset 17: if (!new_touches || !old_touches) {
    return true;
    }
    Gabriel Brito . unresolved
    ```suggestion
    if (!new_touches != !old_touches) {
    return true;
    }
    ```
    Line 300, Patchset 17: Compare(new_touch->position().Get(), old_touch->position().Get())) {
    Gabriel Brito . unresolved

    Are we testing this condition?

    File third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc
    Line 616, Patchset 17:// Tests that a touch disappearing (gamepad with touch vs empty gamepad)
    Gabriel Brito . unresolved

    What do you mean with this? It's not clear to me.

    File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
    Line 15, Patchset 13:class GamepadRawInputChangeEvent : public Event {
    Gabriel Brito . unresolved

    Is there any reason for this to not inherit from `GamepadEvent`?

    Sneha Agarwal

    We only expose the gamepadSnapshot property and do not use or expose the standard gamepad attribute from GamepadEvent. Since this event is focused on providing a snapshot of the gamepad state at the time of the event, inheriting from Event is more appropriate than inheriting from GamepadEvent

    Gabriel Brito

    Marked as unresolved.

    I don't see this "standard gamepad attribute" in [GamepadEvent](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/gamepad/gamepad_event.idl). I suggest leaving this unresolved for now until Matt also have a look.

    At the time of writing the explainer, we went with inheriting directly from `Event` because the gamepad object liveness issue had not been set yet. Now that we know that the event contains a snapshot and that the event target is the window (just like `GamepadEvent`), I don't see a reason for not doing this.

    File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
    Line 504, Patchset 13: UseCounter::Count(context, WebFeature::kGamepadRawInputChangeEventListener);
    Gabriel Brito . unresolved

    Should we move this to where the event handler is added to avoid calling it unnecessarily every time an event is to be dispatched?

    Sneha Agarwal

    I think It should stay here as the counter metrics should record the actual feature usage and not just feature availability. If we move it to the event handler registration, it will count even if no events are ever dispatched, which would inflate the metric and not reflect real usage.

    Gabriel Brito

    Marked as unresolved.

    UseCounters are not UMA histograms. We are just interested in recording whether a web page is adopting the Gamepad Raw events API. For this, if a web page voluntarily adds an event listener for `rawgamepadchange`, this means that feature is being adopted and accounted for. In this sense, only the first call to `UseCounter::Count` during a navigation matters and is the one that will be recorded. All the following ones are not counted and are additional overhead that should be avoided.

    Since RawInput events are dispatched with high frequency, this could be impactful. Ideally, we should be recording this only when a new raw input event listener is added.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Tang
    • Sneha Agarwal
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
      Gerrit-Change-Number: 6897875
      Gerrit-PatchSet: 20
      Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
      Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
      Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
      Gerrit-Attention: Michael Tang <ta...@microsoft.com>
      Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
      Gerrit-Comment-Date: Thu, 02 Oct 2025 02:09:47 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
      Comment-In-Reply-To: Sneha Agarwal <sneha...@microsoft.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Sneha Agarwal (Gerrit)

      unread,
      Oct 2, 2025, 1:20:03 PMOct 2
      to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
      Attention needed from Gabriel Brito and Michael Tang

      Sneha Agarwal voted and added 7 comments

      Votes added by Sneha Agarwal

      Commit-Queue+1

      7 comments

      Patchset-level comments
      File-level comment, Patchset 21 (Latest):
      Sneha Agarwal . resolved

      Hi Gabriel,

      I have addressed some comments, currently working on the remaining one related to counter.
      Thanks

      File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
      Line 282, Patchset 17: if (!new_touches || !old_touches) {
      return true;
      }
      Gabriel Brito . resolved

      Should we add a test for this condition?

      Sneha Agarwal

      the Touch "disappear" test is the one for this condition. checks the case where one gamepad has touches and the other does not. I have improved the name of the test.

      Line 282, Patchset 17: if (!new_touches || !old_touches) {
      return true;
      }
      Gabriel Brito . resolved
      ```suggestion
      if (!new_touches != !old_touches) {
      return true;
      }
      ```
      Sneha Agarwal

      Done

      Line 300, Patchset 17: Compare(new_touch->position().Get(), old_touch->position().Get())) {
      Gabriel Brito . resolved

      Are we testing this condition?

      Sneha Agarwal

      Yes there was a pre-existing test "CompareDifferentSurfaceTouch" for this condition.

      File third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc
      Line 616, Patchset 17:// Tests that a touch disappearing (gamepad with touch vs empty gamepad)
      Gabriel Brito . resolved

      What do you mean with this? It's not clear to me.

      Sneha Agarwal

      Means the gamepad that previously reported one or more touch events now reports no touches at all. I have improved the comment.

      File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
      Line 15, Patchset 13:class GamepadRawInputChangeEvent : public Event {
      Gabriel Brito . unresolved

      Is there any reason for this to not inherit from `GamepadEvent`?

      Sneha Agarwal

      We only expose the gamepadSnapshot property and do not use or expose the standard gamepad attribute from GamepadEvent. Since this event is focused on providing a snapshot of the gamepad state at the time of the event, inheriting from Event is more appropriate than inheriting from GamepadEvent

      Gabriel Brito

      Marked as unresolved.

      I don't see this "standard gamepad attribute" in [GamepadEvent](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/gamepad/gamepad_event.idl). I suggest leaving this unresolved for now until Matt also have a look.

      At the time of writing the explainer, we went with inheriting directly from `Event` because the gamepad object liveness issue had not been set yet. Now that we know that the event contains a snapshot and that the event target is the window (just like `GamepadEvent`), I don't see a reason for not doing this.

      Sneha Agarwal

      Sure I will leave this open for Matt to Chime in.

      File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
      Line 504, Patchset 13: UseCounter::Count(context, WebFeature::kGamepadRawInputChangeEventListener);
      Gabriel Brito . unresolved

      Should we move this to where the event handler is added to avoid calling it unnecessarily every time an event is to be dispatched?

      Sneha Agarwal

      I think It should stay here as the counter metrics should record the actual feature usage and not just feature availability. If we move it to the event handler registration, it will count even if no events are ever dispatched, which would inflate the metric and not reflect real usage.

      Gabriel Brito

      Marked as unresolved.

      UseCounters are not UMA histograms. We are just interested in recording whether a web page is adopting the Gamepad Raw events API. For this, if a web page voluntarily adds an event listener for `rawgamepadchange`, this means that feature is being adopted and accounted for. In this sense, only the first call to `UseCounter::Count` during a navigation matters and is the one that will be recorded. All the following ones are not counted and are additional overhead that should be avoided.

      Since RawInput events are dispatched with high frequency, this could be impactful. Ideally, we should be recording this only when a new raw input event listener is added.

      Sneha Agarwal

      Ok I see your point. I can try your suggestion. thanks

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gabriel Brito
      • Michael Tang
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
      Gerrit-Change-Number: 6897875
      Gerrit-PatchSet: 21
      Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
      Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
      Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
      Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Attention: Michael Tang <ta...@microsoft.com>
      Gerrit-Comment-Date: Thu, 02 Oct 2025 17:19:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Gabriel Brito (Gerrit)

      unread,
      Oct 2, 2025, 7:25:18 PMOct 2
      to Sneha Agarwal, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
      Attention needed from Michael Tang and Sneha Agarwal

      Gabriel Brito added 10 comments

      Patchset-level comments
      Gabriel Brito . resolved

      Left a couple more of comments. Need to look at the tests next.

      File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
      Line 282, Patchset 17: if (!new_touches || !old_touches) {
      return true;
      }
      Gabriel Brito . unresolved

      Should we add a test for this condition?

      Sneha Agarwal

      the Touch "disappear" test is the one for this condition. checks the case where one gamepad has touches and the other does not. I have improved the name of the test.

      Gabriel Brito

      Marked as unresolved.

      Are you sure that we are not returning early in the check below? Maybe all the elements in the list created with `CreateEmptyGamepadList()` are `nullptr`? It looks like your test is simulating a disconnection instead of a touch-up. See [here](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc;l=321;drc=6b98c207facca73446d15164ad3f9a62f4b41d11;bpv=1;bpt=1?q=CreateEmptyGamepadList&ss=chromium%2Fchromium%2Fsrc) for an example.

      ```
      bool GamepadStateCompareResult::CompareTouches(Gamepad* old_gamepad,
      Gamepad* new_gamepad,
      size_t gamepad_index) {
      if (!new_gamepad) {
      return false;
      }
      [...]
      ```
      File third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc
      Line 571, Patchset 21 (Latest):TEST_F(GamepadComparisonsTest, CompareTouchCountMismatch) {
      Gabriel Brito . unresolved

      In all these tests, shouldn't we also check the comparison results via `GamepadStateCompareResult::GetChangedTouches`?

      File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
      Line 399, Patchset 21 (Latest): if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
      Gabriel Brito . unresolved

      Shouldn't we check for `has_input_changed_event_listener_` instead?
      ```
      if (has_input_changed_event_listener_) {
      ```

      Line 458, Patchset 21 (Latest): if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
      Gabriel Brito . unresolved

      if we are not firing "raw input" and "connection/disconnection" events in the same update, shouldn't this be an `else`?

      Line 459, Patchset 21 (Latest): if (has_input_changed_event_listener_ && !is_connected &&

      !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
      Gabriel Brito . unresolved

      There is one case that your conditional is not capturing: if the gamepad has just connected (`is_connected == true`) but there are no connection event listeners, shouldn't we fire a rawinputevent?

      Line 461, Patchset 21 (Latest): is_gamepads_back_exposed = true;
      Gabriel Brito . unresolved

      This does not seem correct. We are not exposing the back buffer. Remove?

      Line 498, Patchset 21 (Latest): // Detect raw input changes for this gamepad index.
      Gabriel Brito . unresolved

      nit: This comment seems redundant. Remove?

      Line 502, Patchset 21 (Latest): // Early exit if there are no axis, button value, or touch changes.
      Gabriel Brito . unresolved

      nit: ditto

      Line 514, Patchset 21 (Latest): ExecutionContext* context = DomWindow();
      Gabriel Brito . unresolved

      nit: Just call `DomWindow()` directly in `UseCounter::Count` and remove the extra variable `context`.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Tang
      • Sneha Agarwal
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
        Gerrit-Change-Number: 6897875
        Gerrit-PatchSet: 21
        Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
        Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
        Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
        Gerrit-Attention: Michael Tang <ta...@microsoft.com>
        Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
        Gerrit-Comment-Date: Thu, 02 Oct 2025 23:25:08 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sneha Agarwal (Gerrit)

        unread,
        Oct 3, 2025, 6:57:43 PMOct 3
        to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org

        Sneha Agarwal abandoned this change

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: abandon
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sneha Agarwal (Gerrit)

        unread,
        Oct 6, 2025, 1:39:48 PMOct 6
        to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org

        Sneha Agarwal restored this change

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: restore
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sneha Agarwal (Gerrit)

        unread,
        Oct 6, 2025, 8:07:10 PMOct 6
        to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
        Attention needed from Gabriel Brito

        Sneha Agarwal added 11 comments

        Patchset-level comments
        File-level comment, Patchset 23 (Latest):
        Sneha Agarwal . resolved

        Hi Gabriel,
        Please take a look at the comments I addressed.
        Thanks

        File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
        Line 282, Patchset 17: if (!new_touches || !old_touches) {
        return true;
        }
        Gabriel Brito . resolved

        Should we add a test for this condition?

        Sneha Agarwal

        the Touch "disappear" test is the one for this condition. checks the case where one gamepad has touches and the other does not. I have improved the name of the test.

        Gabriel Brito

        Marked as unresolved.

        Are you sure that we are not returning early in the check below? Maybe all the elements in the list created with `CreateEmptyGamepadList()` are `nullptr`? It looks like your test is simulating a disconnection instead of a touch-up. See [here](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc;l=321;drc=6b98c207facca73446d15164ad3f9a62f4b41d11;bpv=1;bpt=1?q=CreateEmptyGamepadList&ss=chromium%2Fchromium%2Fsrc) for an example.

        ```
        bool GamepadStateCompareResult::CompareTouches(Gamepad* old_gamepad,
        Gamepad* new_gamepad,
        size_t gamepad_index) {
        if (!new_gamepad) {
        return false;
        }
        [...]
        ```
        Sneha Agarwal

        thanks, updated the test to simulate touch up

        File third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc
        Line 571, Patchset 21:TEST_F(GamepadComparisonsTest, CompareTouchCountMismatch) {
        Gabriel Brito . resolved

        In all these tests, shouldn't we also check the comparison results via `GamepadStateCompareResult::GetChangedTouches`?

        Sneha Agarwal

        Sure we can do that

        File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
        Line 399, Patchset 21: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
        Gabriel Brito . resolved

        Shouldn't we check for `has_input_changed_event_listener_` instead?
        ```
        if (has_input_changed_event_listener_) {
        ```

        Sneha Agarwal

        Yes, we can do that.

        Line 458, Patchset 21: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
        Gabriel Brito . resolved

        if we are not firing "raw input" and "connection/disconnection" events in the same update, shouldn't this be an `else`?

        Sneha Agarwal

        Done

        Line 459, Patchset 21: if (has_input_changed_event_listener_ && !is_connected &&

        !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
        Gabriel Brito . unresolved

        There is one case that your conditional is not capturing: if the gamepad has just connected (`is_connected == true`) but there are no connection event listeners, shouldn't we fire a rawinputevent?

        Sneha Agarwal

        I am not sure if I understand this comment. Please clarify. The raw input change event should not depend on whether or not connection event listeners are there. the connection event listener should be checked by the logic that dispatches the connection event.

        Line 461, Patchset 21: is_gamepads_back_exposed = true;
        Gabriel Brito . resolved

        This does not seem correct. We are not exposing the back buffer. Remove?

        Sneha Agarwal

        Done

        Line 498, Patchset 21: // Detect raw input changes for this gamepad index.
        Gabriel Brito . resolved

        nit: This comment seems redundant. Remove?

        Sneha Agarwal

        Done

        Line 502, Patchset 21: // Early exit if there are no axis, button value, or touch changes.
        Gabriel Brito . resolved

        nit: ditto

        Sneha Agarwal

        Done

        Line 504, Patchset 13: UseCounter::Count(context, WebFeature::kGamepadRawInputChangeEventListener);
        Gabriel Brito . resolved

        Should we move this to where the event handler is added to avoid calling it unnecessarily every time an event is to be dispatched?

        Sneha Agarwal

        I think It should stay here as the counter metrics should record the actual feature usage and not just feature availability. If we move it to the event handler registration, it will count even if no events are ever dispatched, which would inflate the metric and not reflect real usage.

        Gabriel Brito

        Marked as unresolved.

        UseCounters are not UMA histograms. We are just interested in recording whether a web page is adopting the Gamepad Raw events API. For this, if a web page voluntarily adds an event listener for `rawgamepadchange`, this means that feature is being adopted and accounted for. In this sense, only the first call to `UseCounter::Count` during a navigation matters and is the one that will be recorded. All the following ones are not counted and are additional overhead that should be avoided.

        Since RawInput events are dispatched with high frequency, this could be impactful. Ideally, we should be recording this only when a new raw input event listener is added.

        Sneha Agarwal

        Ok I see your point. I can try your suggestion. thanks

        Sneha Agarwal

        Done

        Line 514, Patchset 21: ExecutionContext* context = DomWindow();
        Gabriel Brito . resolved

        nit: Just call `DomWindow()` directly in `UseCounter::Count` and remove the extra variable `context`.

        Sneha Agarwal

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Gabriel Brito
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
        Gerrit-Change-Number: 6897875
        Gerrit-PatchSet: 23
        Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
        Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
        Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
        Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Comment-Date: Tue, 07 Oct 2025 00:07:00 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sneha Agarwal (Gerrit)

        unread,
        Oct 7, 2025, 1:45:47 PMOct 7
        to Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org

        Sneha Agarwal abandoned this change

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: abandon
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I971275de50618057d520360f42bb7683228739ea
        Gerrit-Change-Number: 7009010
        Gerrit-PatchSet: 3
        Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sneha Agarwal (Gerrit)

        unread,
        Oct 7, 2025, 5:21:46 PMOct 7
        to Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, ipc-securi...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org

        Sneha Agarwal restored this change

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: restore
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Michael Tang (Gerrit)

        unread,
        Oct 7, 2025, 10:13:17 PMOct 7
        to Sneha Agarwal, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
        Attention needed from Gabriel Brito, Michael Tang and Sneha Agarwal

        Michael Tang added 5 comments

        Patchset-level comments
        File-level comment, Patchset 24 (Latest):
        Michael Tang . resolved

        Hi! Sorry for the delay-- I only have minor nits on the implementation. I will review the tests more thoroughly tomorrow!

        File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
        Line 282, Patchset 24 (Latest): if (!new_touches != !old_touches) {
        Michael Tang . unresolved
        nit: I think these are equivalent.
        ```suggestion
        if (new_touches != old_touches) {
        ```
        File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
        Line 403, Patchset 24 (Latest): if (has_input_changed_event_listener_) {
        // Only compare all axes/buttons if a raw input change event listener is
        // present. This avoids unnecessary comparisons when no listener is
        // attached.
        should_compare_all_axes = has_input_changed_event_listener_;
        should_compare_all_buttons = has_input_changed_event_listener_;
        }
        Michael Tang . unresolved

        Thanks for the comment.

        nit: functionally identical
        ```suggestion
        // Only compare all axes/buttons if a raw input change event listener is
        // present. This avoids unnecessary comparisons when no listener is
        // attached.
        should_compare_all_axes = has_input_changed_event_listener_;
        should_compare_all_buttons = has_input_changed_event_listener_;
        ```
        or:
        ```suggestion
        if (has_input_changed_event_listener_) {
        // Only compare all axes/buttons if a raw input change event listener is
        // present. This avoids unnecessary comparisons when no listener is
        // attached.
        should_compare_all_axes = true;
        should_compare_all_buttons = true;
        }
        ```
        Line 463, Patchset 24 (Latest): !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
        Michael Tang . unresolved

        Is this redundant with checking for `!is_connected && !is_disconnected`? IIUC, `is_connected == (!gamepads_back_[i] && gamepads_[i])`, while `is_disconnected == (gamepads_back_[i] && !gamepads_[i])`. Is this correct?

        File third_party/blink/web_tests/gamepad/gamepad-raw-input-change-event.html
        Line 1, Patchset 24 (Latest):
        Michael Tang . unresolved

        nit: Remove extra new line

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Gabriel Brito
        • Michael Tang
        • Sneha Agarwal
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 24
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Michael Tang <ta...@microsoft.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Wed, 08 Oct 2025 02:12:50 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Gabriel Brito (Gerrit)

          unread,
          Oct 8, 2025, 1:23:29 PMOct 8
          to Sneha Agarwal, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Michael Tang and Sneha Agarwal

          Gabriel Brito added 1 comment

          File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
          Line 282, Patchset 24 (Latest): if (!new_touches != !old_touches) {
          Michael Tang . unresolved
          nit: I think these are equivalent.
          ```suggestion
          if (new_touches != old_touches) {
          ```
          Gabriel Brito

          Quick comment. I don't think these are equivalent. The `operator!` is there to coerce a conversion to `bool` - i.e. to tell us whether the pointer is `nullptr` or not. The way it is written now is basically a xor operation where the operands are "is the pointer nullptr" so it will return `true` whenever one of the pointer is `nullptr` and the other isn't.

          If we compare the pointers directly, won't we be comparing only the pointer addresses? I imagine it would return `true` if both pointers are valid but point to different memory addresses.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Tang
          • Sneha Agarwal
          Gerrit-Attention: Michael Tang <ta...@microsoft.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Wed, 08 Oct 2025 17:23:07 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Michael Tang <ta...@microsoft.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Michael Tang (Gerrit)

          unread,
          Oct 8, 2025, 2:00:29 PMOct 8
          to Sneha Agarwal, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Michael Tang and Sneha Agarwal

          Michael Tang added 1 comment

          File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
          Line 282, Patchset 24 (Latest): if (!new_touches != !old_touches) {
          Michael Tang . unresolved
          nit: I think these are equivalent.
          ```suggestion
          if (new_touches != old_touches) {
          ```
          Gabriel Brito

          Quick comment. I don't think these are equivalent. The `operator!` is there to coerce a conversion to `bool` - i.e. to tell us whether the pointer is `nullptr` or not. The way it is written now is basically a xor operation where the operands are "is the pointer nullptr" so it will return `true` whenever one of the pointer is `nullptr` and the other isn't.

          If we compare the pointers directly, won't we be comparing only the pointer addresses? I imagine it would return `true` if both pointers are valid but point to different memory addresses.

          Michael Tang

          You're totally right. I wonder if, for clarity, we should have this (and the above condition) use `*_gamepad->HasTouchEvents()` instead and then follow up with `CHECK`s that `*_touches` are non-null.

          What you have here is otherwise fine. Please feel free to close with no action.

          Gerrit-Comment-Date: Wed, 08 Oct 2025 18:00:06 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sneha Agarwal (Gerrit)

          unread,
          Oct 8, 2025, 2:09:18 PMOct 8
          to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Michael Tang

          Sneha Agarwal added 5 comments

          Patchset-level comments
          File-level comment, Patchset 24:
          Sneha Agarwal . resolved

          Hi Michael,
          I have addressed your comments. Thanks

          File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
          Line 282, Patchset 24: if (!new_touches != !old_touches) {
          Michael Tang . resolved
          nit: I think these are equivalent.
          ```suggestion
          if (new_touches != old_touches) {
          ```
          Sneha Agarwal

          I think this change is not correct for this context.
          !new_touches != !old_touches specifically checks if one pointer is null and the other is not, which means one gamepad has touches and the other does not.

          new_touches != old_touches would also be true if both are non-null but point to different objects, which is not the intent here.

          The original code is more precise for detecting the case where only one side has touches.

          File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
          Line 403, Patchset 24: if (has_input_changed_event_listener_) {

          // Only compare all axes/buttons if a raw input change event listener is
          // present. This avoids unnecessary comparisons when no listener is
          // attached.
          should_compare_all_axes = has_input_changed_event_listener_;
          should_compare_all_buttons = has_input_changed_event_listener_;
          }
          Michael Tang . resolved

          Thanks for the comment.

          nit: functionally identical
          ```suggestion
          // Only compare all axes/buttons if a raw input change event listener is
          // present. This avoids unnecessary comparisons when no listener is
          // attached.
          should_compare_all_axes = has_input_changed_event_listener_;
          should_compare_all_buttons = has_input_changed_event_listener_;
          ```
          or:
          ```suggestion
          if (has_input_changed_event_listener_) {
          // Only compare all axes/buttons if a raw input change event listener is
          // present. This avoids unnecessary comparisons when no listener is
          // attached.
          should_compare_all_axes = true;
          should_compare_all_buttons = true;
          }
          ```
          Sneha Agarwal

          Done

          Line 463, Patchset 24: !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
          Michael Tang . resolved

          Is this redundant with checking for `!is_connected && !is_disconnected`? IIUC, `is_connected == (!gamepads_back_[i] && gamepads_[i])`, while `is_disconnected == (gamepads_back_[i] && !gamepads_[i])`. Is this correct?

          Sneha Agarwal

          No, the check !is_connected && !is_disconnected && gamepads_[i] && gamepads_back_[i] is not redundant. This logic considers both connection state and ID changes, not just pointer presence. They are computed by comparing the connection state and ID of the gamepads in the previous and current samples.

          The proposed equivalence:


          is_connected == (!gamepads_back_[i] && gamepads_[i])

          is_disconnected == (gamepads_back_[i] && !gamepads_[i])

          is not correct.
          The actual logic considers both connection state and ID changes, not just pointer presence.

          The current logic is necessary to distinguish between connection/disconnection events and continuous input changes.

          File third_party/blink/web_tests/gamepad/gamepad-raw-input-change-event.html
          Line 1, Patchset 24:
          Michael Tang . resolved

          nit: Remove extra new line

          Sneha Agarwal

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Tang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 25
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Michael Tang <ta...@microsoft.com>
          Gerrit-Comment-Date: Wed, 08 Oct 2025 18:08:55 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Michael Tang <ta...@microsoft.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Gabriel Brito (Gerrit)

          unread,
          Oct 8, 2025, 9:23:35 PMOct 8
          to Sneha Agarwal, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Michael Tang and Sneha Agarwal

          Gabriel Brito added 6 comments

          Patchset-level comments
          File-level comment, Patchset 25 (Latest):
          Gabriel Brito . resolved

          Still need to review device/gamepad/gamepad_service_unittest.cc. Also please don't forget to dry run the latest patchset. Always upload a new one with `git cl upload -d`.

          File third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc
          Line 571, Patchset 21:TEST_F(GamepadComparisonsTest, CompareTouchCountMismatch) {
          Gabriel Brito . unresolved

          In all these tests, shouldn't we also check the comparison results via `GamepadStateCompareResult::GetChangedTouches`?

          Sneha Agarwal

          Sure we can do that

          Gabriel Brito

          Marked as unresolved.

          For all these tests, shouldn't we also check that what is being reported as changed is what we expect?

          Line 589, Patchset 25 (Latest): const auto& changed_touches = compareResult.GetChangedTouches(0);
          EXPECT_FALSE(changed_touches.empty());
          Gabriel Brito . unresolved
          ```suggestion
          EXPECT_FALSE(compareResult.GetChangedTouches(0).empty());
          ```
          I don't think you need to create these variables. Please apply this to the other test cases too.
          Line 629, Patchset 25 (Latest): EXPECT_TRUE(changed_touches.empty());
          Gabriel Brito . unresolved

          Shouldn't we expect to see at least one change?

          File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
          Line 400, Patchset 25 (Latest): bool should_compare_all_axes = false;
          bool should_compare_all_buttons = false;


          if (has_input_changed_event_listener_) {
          // Only compare all axes/buttons if a raw input change event listener is
          // present. This avoids unnecessary comparisons when no listener is
          // attached.
          should_compare_all_axes = true;
          should_compare_all_buttons = true;
          }

          GamepadStateCompareResult compare_result = GamepadComparisons::Compare(
          gamepads_, gamepads_back_, should_compare_all_axes,
          should_compare_all_buttons);
          Gabriel Brito . unresolved

          Do we need to have 2 different arguments for `GamepadComparisons::Compare`? Can't we merge them into one `should_compare_all_inputs`?

          Line 458, Patchset 21: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
          Gabriel Brito . unresolved

          if we are not firing "raw input" and "connection/disconnection" events in the same update, shouldn't this be an `else`?

          Sneha Agarwal

          Done

          Gabriel Brito

          Marked as unresolved.

          The `else if` does not feel correct to me. IIUC, if a connection/disconnection event is fired, we don't need to fire a rawinput event in the same cycle. Otherwise, we are firing an extra and unnecessary event as connection/disconnection event also contain a gamepad snapshot. What I mean is:

          ```
          if should fire connect or disconnect event:
          fire events
          else if should fire raw input event:
          fire raw input event
          ```
          This should also simplify the conditions checked in 
          ```
          if (has_input_changed_event_listener_ && !is_connected &&
          !is_disconnected && gamepads_[i] && gamepads_back_[i])
          ```
          cc: @ta...@microsoft.com
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Tang
          • Sneha Agarwal
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Thu, 09 Oct 2025 01:23:11 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sneha Agarwal (Gerrit)

          unread,
          Oct 10, 2025, 1:30:34 PMOct 10
          to Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Gabriel Brito and Michael Tang

          Sneha Agarwal added 6 comments

          Patchset-level comments
          File-level comment, Patchset 27:
          Sneha Agarwal . resolved

          HI Gabriel, Please, take a look at the change/comments. Thanks

          File third_party/blink/renderer/modules/gamepad/gamepad_comparisons_test.cc
          Line 571, Patchset 21:TEST_F(GamepadComparisonsTest, CompareTouchCountMismatch) {
          Gabriel Brito . resolved

          In all these tests, shouldn't we also check the comparison results via `GamepadStateCompareResult::GetChangedTouches`?

          Sneha Agarwal

          Sure we can do that

          Gabriel Brito

          Marked as unresolved.

          For all these tests, shouldn't we also check that what is being reported as changed is what we expect?

          Sneha Agarwal

          I can only add that for the tests that have some property changed at an index not for the ones that detect the number of touches changed.

          Line 589, Patchset 25: const auto& changed_touches = compareResult.GetChangedTouches(0);
          EXPECT_FALSE(changed_touches.empty());
          Gabriel Brito . resolved
          ```suggestion
          EXPECT_FALSE(compareResult.GetChangedTouches(0).empty());
          ```
          I don't think you need to create these variables. Please apply this to the other test cases too.
          Sneha Agarwal

          Done

          Line 629, Patchset 25: EXPECT_TRUE(changed_touches.empty());
          Gabriel Brito . resolved

          Shouldn't we expect to see at least one change?

          Sneha Agarwal

          No, in this test, the position of the touch does not change. The test is about the removal of a touch event (the touch count goes from 1 to 0), not about a change in the properties (such as position) of an existing touch.

          If the position were to change, both gamepad states would still have a touch at the same index, and GetChangedTouches(0) would contain that index, indicating a property change. In this test, since the touch is removed entirely, there is no touch in the second state to compare positions with, and GetChangedTouches(0) should be empty.

          File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
          Line 400, Patchset 25: bool should_compare_all_axes = false;

          bool should_compare_all_buttons = false;

          if (has_input_changed_event_listener_) {
          // Only compare all axes/buttons if a raw input change event listener is
          // present. This avoids unnecessary comparisons when no listener is
          // attached.
          should_compare_all_axes = true;
          should_compare_all_buttons = true;
          }

          GamepadStateCompareResult compare_result = GamepadComparisons::Compare(
          gamepads_, gamepads_back_, should_compare_all_axes,
          should_compare_all_buttons);
          Gabriel Brito . resolved

          Do we need to have 2 different arguments for `GamepadComparisons::Compare`? Can't we merge them into one `should_compare_all_inputs`?

          Sneha Agarwal

          I think we should keep it as it maintains clarity in the code. Passing a generic compare_all_inputs flag to CompareAxes and CompareButtons can be confusing, since those functions expect a flag specific to their domain (axes or buttons)

          Also avoiding unnecessary refactoring in SampleAndCompareGamepadState method - as future event queuing change will be getting rid of this method.

          Line 458, Patchset 21: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
          Gabriel Brito . unresolved

          if we are not firing "raw input" and "connection/disconnection" events in the same update, shouldn't this be an `else`?

          Sneha Agarwal

          Done

          Gabriel Brito

          Marked as unresolved.

          The `else if` does not feel correct to me. IIUC, if a connection/disconnection event is fired, we don't need to fire a rawinput event in the same cycle. Otherwise, we are firing an extra and unnecessary event as connection/disconnection event also contain a gamepad snapshot. What I mean is:

          ```
          if should fire connect or disconnect event:
          fire events
          else if should fire raw input event:
          fire raw input event
          ```
          This should also simplify the conditions checked in 
          ```
          if (has_input_changed_event_listener_ && !is_connected &&
          !is_disconnected && gamepads_[i] && gamepads_back_[i])
          ```
          cc: @ta...@microsoft.com
          Sneha Agarwal

          Functionally, both statements cannot execute at the same time because the conditions being checked are mutually exclusive. Adding else does not change the behavior, since the explicit conditions already prevent double-firing. I prefer to check the conditions explicitly for clarity and safety. At this point, I think this is a matter of style rather than correctness.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Gabriel Brito
          • Michael Tang
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 28
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Michael Tang <ta...@microsoft.com>
          Gerrit-Comment-Date: Fri, 10 Oct 2025 17:30:12 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Gabriel Brito (Gerrit)

          unread,
          Oct 10, 2025, 5:36:26 PMOct 10
          to Sneha Agarwal, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Michael Tang and Sneha Agarwal

          Gabriel Brito added 6 comments

          Patchset-level comments
          File-level comment, Patchset 28 (Latest):
          Gabriel Brito . resolved

          I think that it seems good to me overall % open questions

          File device/gamepad/gamepad_service_unittest.cc
          Line 585, Patchset 28 (Latest): base::UnguessableToken SetupRawInputGamepad(
          Gabriel Brito . unresolved
          You can make this method simpler like this:
          ```
          base::UnguessableToken SetupRawInputGamepad(
          MockGamepadConsumer* consumer,
          SimulatedGamepadParams params) {
          params.name = "Raw input test gamepad";
          [...]
          };
          ```
          Then use it like:
          ```
          SimulatedGamepadParams params = {
          .button_bounds = {std::nullopt, std::nullopt},
          .axis_bounds = {GamepadLogicalBounds(-1.0, 1.0)}
          };
          auto token = SetupRawInputGamepad(consumer, std::move(params));
          ```
          Line 616, Patchset 28 (Latest): // Helper to expect and verify a raw input change callback.
          template <typename VerifyFunction>
          auto ExpectRawInputChange(MockGamepadConsumer* consumer,
          VerifyFunction verify_func) {
          auto raw_input_future =
          std::make_shared<TestFuture<uint32_t, const Gamepad&>>();
          EXPECT_CALL(*consumer, OnGamepadRawInputChanged)
          .WillOnce(InvokeFuture(*raw_input_future));

          // Return a lambda that captures the shared_ptr by value
          return [raw_input_future, verify_func]() {
          EXPECT_EQ(raw_input_future->Get<0>(), 0u);
          verify_func(raw_input_future->Get<1>());
          };
          }
          Gabriel Brito . unresolved

          Is it being used?

          Line 639, Patchset 28 (Latest): EXPECT_EQ(disconnected_future.Get<0>(), 0u);
          Gabriel Brito . unresolved

          Similarly to `SetupRawInputGamepad` should we also `EXPECT_FALSE(connected_future.Get<1>().connected)`?

          File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
          Line 458, Patchset 21: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
          Gabriel Brito . unresolved

          if we are not firing "raw input" and "connection/disconnection" events in the same update, shouldn't this be an `else`?

          Sneha Agarwal

          Done

          Gabriel Brito

          Marked as unresolved.

          The `else if` does not feel correct to me. IIUC, if a connection/disconnection event is fired, we don't need to fire a rawinput event in the same cycle. Otherwise, we are firing an extra and unnecessary event as connection/disconnection event also contain a gamepad snapshot. What I mean is:

          ```
          if should fire connect or disconnect event:
          fire events
          else if should fire raw input event:
          fire raw input event
          ```
          This should also simplify the conditions checked in 
          ```
          if (has_input_changed_event_listener_ && !is_connected &&
          !is_disconnected && gamepads_[i] && gamepads_back_[i])
          ```
          cc: @ta...@microsoft.com
          Sneha Agarwal

          Functionally, both statements cannot execute at the same time because the conditions being checked are mutually exclusive. Adding else does not change the behavior, since the explicit conditions already prevent double-firing. I prefer to check the conditions explicitly for clarity and safety. At this point, I think this is a matter of style rather than correctness.

          Gabriel Brito
          Although the conditions might be mutually exclusive and work as expected, I am trying to say that this `if` condition looks unnecessarily complicated and the mutual exclusivity is not trivial to perceive. For example, the checks below are mutually exclusive:
          ```
          if (a && !b && !c && d):
          Do TaskA
          if (!a || b || c || !d):
          Do TaskB
          ```
          But they could be simplified by means of an `else`:
          ```
          if (a && !b && !c && d):
          Do TaskA
          else:
          Do TaskB
          ```

          Can't we rewrite it in a clearer way? If it is true that "_if a connection/disconnection event is fired, we don't need to fire a rawinput event in the same cycle_", then can't we use this information to simplify the rawinput event check?

          I suggest leaving this open for now so that Matt can give his opinion as an editor of the specification.

          Line 459, Patchset 21: if (has_input_changed_event_listener_ && !is_connected &&
          !is_disconnected && gamepads_[i] && gamepads_back_[i]) {
          Gabriel Brito . resolved

          There is one case that your conditional is not capturing: if the gamepad has just connected (`is_connected == true`) but there are no connection event listeners, shouldn't we fire a rawinputevent?

          Sneha Agarwal

          I am not sure if I understand this comment. Please clarify. The raw input change event should not depend on whether or not connection event listeners are there. the connection event listener should be checked by the logic that dispatches the connection event.

          Gabriel Brito

          Sure. There must be a raw input event listener too. The case that I am referring to is:

          • Gamepad has just connected; and
          • `has_input_changed_event_listener_ = true`
          • `has_connection_event_listener_ = false`
          • `is_connected = true`

          Let's sidetrack this for now since we haven't committed to a specification yet (also what I asked about might not be desired).

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Tang
          • Sneha Agarwal
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 28
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Michael Tang <ta...@microsoft.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Fri, 10 Oct 2025 21:36:01 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sneha Agarwal (Gerrit)

          unread,
          Oct 13, 2025, 2:31:40 PMOct 13
          to Matt Reynolds, Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Matt Reynolds

          Sneha Agarwal added 4 comments

          Patchset-level comments
          File-level comment, Patchset 29 (Latest):
          Sneha Agarwal . resolved

          Hi Matt,
          When you have a chance please take a look at this change. There are a couple open comments that could use your inputs.
          Thanks

          File device/gamepad/gamepad_service_unittest.cc
          Line 585, Patchset 28: base::UnguessableToken SetupRawInputGamepad(
          Gabriel Brito . unresolved
          You can make this method simpler like this:
          ```
          base::UnguessableToken SetupRawInputGamepad(
          MockGamepadConsumer* consumer,
          SimulatedGamepadParams params) {
          params.name = "Raw input test gamepad";
          [...]
          };
          ```
          Then use it like:
          ```
          SimulatedGamepadParams params = {
          .button_bounds = {std::nullopt, std::nullopt},
          .axis_bounds = {GamepadLogicalBounds(-1.0, 1.0)}
          };
          auto token = SetupRawInputGamepad(consumer, std::move(params));
          ```
          Sneha Agarwal

          I will try it out thanks

          Line 616, Patchset 28: // Helper to expect and verify a raw input change callback.

          template <typename VerifyFunction>
          auto ExpectRawInputChange(MockGamepadConsumer* consumer,
          VerifyFunction verify_func) {
          auto raw_input_future =
          std::make_shared<TestFuture<uint32_t, const Gamepad&>>();
          EXPECT_CALL(*consumer, OnGamepadRawInputChanged)
          .WillOnce(InvokeFuture(*raw_input_future));

          // Return a lambda that captures the shared_ptr by value
          return [raw_input_future, verify_func]() {
          EXPECT_EQ(raw_input_future->Get<0>(), 0u);
          verify_func(raw_input_future->Get<1>());
          };
          }
          Gabriel Brito . resolved

          Is it being used?

          Sneha Agarwal

          Yes, the ExpectRawInputChange helper is used in the test

          Line 639, Patchset 28: EXPECT_EQ(disconnected_future.Get<0>(), 0u);
          Gabriel Brito . resolved

          Similarly to `SetupRawInputGamepad` should we also `EXPECT_FALSE(connected_future.Get<1>().connected)`?

          Sneha Agarwal

          Done

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Matt Reynolds
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 29
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Comment-Date: Mon, 13 Oct 2025 18:31:17 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Matt Reynolds (Gerrit)

          unread,
          Oct 14, 2025, 7:11:27 PMOct 14
          to Sneha Agarwal, Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Sneha Agarwal

          Matt Reynolds added 4 comments

          File android_webview/test/data/web_tests/webexposed/global-interface-listing-expected.txt
          File-level comment, Patchset 31 (Parent):
          Matt Reynolds . unresolved

          I think there should also be a new event listener attribute window.ongamepadrawinputchange. We recently added these for ongamepadconnected and ongamepaddisconnected but they haven't launched yet: https://crrev.com/c/6984681 ongamepadrawinputchange should also be added in window_gamepad.idl but we'll need to fix the RuntimeEnabled attributes so it isn't gated on GamepadWindowEventHandlers.

          File content/web_test/renderer/gamepad_controller.cc
          Line 282, Patchset 31 (Latest): // Record that there wasn't an observer to get the GamepadRawInputChanged
          // RPC so we can send it when SetObserver gets called.
          missed_dispatches_.set(index);
          Matt Reynolds . unresolved

          `missed_dispatches_` should only be set in DispatchConnected. I don't think we need similar behavior for GamepadRawInputChanged.

          File device/gamepad/gamepad_service_unittest.cc
          Line 618, Patchset 31 (Latest): auto ExpectRawInputChange(MockGamepadConsumer* consumer,
          Matt Reynolds . unresolved

          ExpectRawInputChange appears unused, please remove

          Line 1293, Patchset 31 (Latest): base::RunLoop loop;
          EXPECT_CALL(*consumer, OnGamepadRawInputChanged)
          .WillOnce([&](uint32_t, const Gamepad& gamepad) {
          EXPECT_EQ(gamepad.buttons_length, 1u);
          EXPECT_EQ(gamepad.buttons[0].value, 0.5);
          loop.Quit();
          });
          Matt Reynolds . unresolved

          Prefer using `base::test::TestFuture` to capture callback parameters instead of nesting expectations inside the callback.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Sneha Agarwal
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 31
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Tue, 14 Oct 2025 23:11:01 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Gabriel Brito (Gerrit)

          unread,
          Oct 17, 2025, 5:33:57 PMOct 17
          to Sneha Agarwal, Matt Reynolds, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Sneha Agarwal

          Gabriel Brito added 1 comment

          File third_party/blink/renderer/platform/runtime_enabled_features.json5
          Line 2630, Patchset 34 (Latest): name: "GamepadWindowRawInputChangeEventHandler",
          Gabriel Brito . unresolved

          We should probably reuse the `GamepadRawInputChangeEvent` runtime flag instead of creating a new one.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Sneha Agarwal
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 34
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 21:33:48 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sneha Agarwal (Gerrit)

          unread,
          Oct 17, 2025, 6:11:40 PMOct 17
          to Matt Reynolds, Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Gabriel Brito and Matt Reynolds

          Sneha Agarwal added 8 comments

          Patchset-level comments
          File-level comment, Patchset 34 (Latest):
          Sneha Agarwal . resolved

          Hi Matt and Gabriel,

          I have addressed your comments.

          Matt there is an open comment that needs your attention please.
          FYI: Merge conflict is in the enum.xml file which updates frequently, I will do a rebase soon to fix that. Please ignore that for now.

          Thanks

          File android_webview/test/data/web_tests/webexposed/global-interface-listing-expected.txt
          Matt Reynolds . resolved

          I think there should also be a new event listener attribute window.ongamepadrawinputchange. We recently added these for ongamepadconnected and ongamepaddisconnected but they haven't launched yet: https://crrev.com/c/6984681 ongamepadrawinputchange should also be added in window_gamepad.idl but we'll need to fix the RuntimeEnabled attributes so it isn't gated on GamepadWindowEventHandlers.

          Sneha Agarwal

          Done

          File content/web_test/renderer/gamepad_controller.cc
          Line 282, Patchset 31: // Record that there wasn't an observer to get the GamepadRawInputChanged

          // RPC so we can send it when SetObserver gets called.
          missed_dispatches_.set(index);
          Matt Reynolds . resolved

          `missed_dispatches_` should only be set in DispatchConnected. I don't think we need similar behavior for GamepadRawInputChanged.

          Sneha Agarwal

          Done

          File device/gamepad/gamepad_service_unittest.cc
          Line 585, Patchset 28: base::UnguessableToken SetupRawInputGamepad(
          Gabriel Brito . resolved
          You can make this method simpler like this:
          ```
          base::UnguessableToken SetupRawInputGamepad(
          MockGamepadConsumer* consumer,
          SimulatedGamepadParams params) {
          params.name = "Raw input test gamepad";
          [...]
          };
          ```
          Then use it like:
          ```
          SimulatedGamepadParams params = {
          .button_bounds = {std::nullopt, std::nullopt},
          .axis_bounds = {GamepadLogicalBounds(-1.0, 1.0)}
          };
          auto token = SetupRawInputGamepad(consumer, std::move(params));
          ```
          Sneha Agarwal

          I will try it out thanks

          Sneha Agarwal

          Done

          Line 618, Patchset 31: auto ExpectRawInputChange(MockGamepadConsumer* consumer,
          Matt Reynolds . resolved

          ExpectRawInputChange appears unused, please remove

          Sneha Agarwal

          Done

          Line 616, Patchset 28: // Helper to expect and verify a raw input change callback.
          template <typename VerifyFunction>
          auto ExpectRawInputChange(MockGamepadConsumer* consumer,
          VerifyFunction verify_func) {
          auto raw_input_future =
          std::make_shared<TestFuture<uint32_t, const Gamepad&>>();
          EXPECT_CALL(*consumer, OnGamepadRawInputChanged)
          .WillOnce(InvokeFuture(*raw_input_future));

          // Return a lambda that captures the shared_ptr by value
          return [raw_input_future, verify_func]() {
          EXPECT_EQ(raw_input_future->Get<0>(), 0u);
          verify_func(raw_input_future->Get<1>());
          };
          }
          Gabriel Brito . resolved

          Is it being used?

          Sneha Agarwal

          Yes, the ExpectRawInputChange helper is used in the test

          Sneha Agarwal

          Actually it was being used in an older iteration but not anymore, so I will delete it. Thanks

          Line 1293, Patchset 31: base::RunLoop loop;

          EXPECT_CALL(*consumer, OnGamepadRawInputChanged)
          .WillOnce([&](uint32_t, const Gamepad& gamepad) {
          EXPECT_EQ(gamepad.buttons_length, 1u);
          EXPECT_EQ(gamepad.buttons[0].value, 0.5);
          loop.Quit();
          });
          Matt Reynolds . resolved

          Prefer using `base::test::TestFuture` to capture callback parameters instead of nesting expectations inside the callback.

          Sneha Agarwal

          Done

          File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
          Line 15, Patchset 13:class GamepadRawInputChangeEvent : public Event {
          Gabriel Brito . unresolved

          Is there any reason for this to not inherit from `GamepadEvent`?

          Sneha Agarwal

          We only expose the gamepadSnapshot property and do not use or expose the standard gamepad attribute from GamepadEvent. Since this event is focused on providing a snapshot of the gamepad state at the time of the event, inheriting from Event is more appropriate than inheriting from GamepadEvent

          Gabriel Brito

          Marked as unresolved.

          I don't see this "standard gamepad attribute" in [GamepadEvent](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/gamepad/gamepad_event.idl). I suggest leaving this unresolved for now until Matt also have a look.

          At the time of writing the explainer, we went with inheriting directly from `Event` because the gamepad object liveness issue had not been set yet. Now that we know that the event contains a snapshot and that the event target is the window (just like `GamepadEvent`), I don't see a reason for not doing this.

          Sneha Agarwal

          Sure I will leave this open for Matt to Chime in.

          Sneha Agarwal

          @mattre...@chromium.org Please share your input. Thanks

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Gabriel Brito
          • Matt Reynolds
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 22:11:29 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
          Comment-In-Reply-To: Matt Reynolds <mattre...@chromium.org>
          Comment-In-Reply-To: Sneha Agarwal <sneha...@microsoft.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Matt Reynolds (Gerrit)

          unread,
          Oct 28, 2025, 4:17:03 PM (5 days ago) Oct 28
          to Sneha Agarwal, Michael Tang, Gabriel Brito, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Gabriel Brito and Sneha Agarwal

          Matt Reynolds added 7 comments

          File device/gamepad/gamepad_service_unittest.cc
          Line 1270, Patchset 37 (Latest): base::test::TestFuture<uint32_t, const Gamepad&> future;
          Matt Reynolds . unresolved

          nit: this file has `using base::test::TestFuture` at the top so we can omit the `base::test::` prefix here and below.

          Line 1279, Patchset 37 (Latest): auto [id, gamepad] = future.Take();
          Matt Reynolds . unresolved

          nit: Prefer const auto& for structured bindings to avoid unnecessary copies

          ```suggestion
          const auto& [id, gamepad] = future.Take();
          ```
          File third_party/blink/renderer/modules/gamepad/gamepad_comparisons.cc
          Line 135, Patchset 37 (Latest): DCHECK_LT(pad_index, device::Gamepads::kItemsLengthCap);
          DCHECK_LT(touch_index, device::Gamepad::kTouchEventsLengthCap);
          Matt Reynolds . unresolved

          In new code, prefer CHECK over DCHECK.

          ```suggestion
          CHECK_LT(pad_index, device::Gamepads::kItemsLengthCap);
          CHECK_LT(touch_index, device::Gamepad::kTouchEventsLengthCap);
          ```
          File third_party/blink/renderer/modules/gamepad/gamepad_listener.h
          Line 34, Patchset 37 (Latest): virtual void ButtonOrAxisDidChange(uint32_t index,
          Matt Reynolds . unresolved

          ButtonOrAxisDidChange is unused (implemented by GamepadDispatcher but never called) and was missed when I cleaned up the previous implementation. Please remove ButtonOrAxisDidChange in this CL to avoid confusion.

          File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
          Line 15, Patchset 13:class GamepadRawInputChangeEvent : public Event {
          Gabriel Brito . unresolved

          Is there any reason for this to not inherit from `GamepadEvent`?

          Sneha Agarwal

          We only expose the gamepadSnapshot property and do not use or expose the standard gamepad attribute from GamepadEvent. Since this event is focused on providing a snapshot of the gamepad state at the time of the event, inheriting from Event is more appropriate than inheriting from GamepadEvent

          Gabriel Brito

          Marked as unresolved.

          I don't see this "standard gamepad attribute" in [GamepadEvent](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/gamepad/gamepad_event.idl). I suggest leaving this unresolved for now until Matt also have a look.

          At the time of writing the explainer, we went with inheriting directly from `Event` because the gamepad object liveness issue had not been set yet. Now that we know that the event contains a snapshot and that the event target is the window (just like `GamepadEvent`), I don't see a reason for not doing this.

          Sneha Agarwal

          Sure I will leave this open for Matt to Chime in.

          Sneha Agarwal

          @mattre...@chromium.org Please share your input. Thanks

          Matt Reynolds

          Sorry for the delay. If the .gamepadSnapshot is equivalent to .gamepad on other gamepad events (I think this is true) then it should be renamed to match. I agree with Gabriel, I don't see any reason not to inherit from GamepadEvent.

          File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
          Line 458, Patchset 21: if (RuntimeEnabledFeatures::GamepadRawInputChangeEventEnabled()) {
          Gabriel Brito . unresolved

          if we are not firing "raw input" and "connection/disconnection" events in the same update, shouldn't this be an `else`?

          Sneha Agarwal

          Done

          Gabriel Brito

          Marked as unresolved.

          The `else if` does not feel correct to me. IIUC, if a connection/disconnection event is fired, we don't need to fire a rawinput event in the same cycle. Otherwise, we are firing an extra and unnecessary event as connection/disconnection event also contain a gamepad snapshot. What I mean is:

          ```
          if should fire connect or disconnect event:
          fire events
          else if should fire raw input event:
          fire raw input event
          ```
          This should also simplify the conditions checked in 
          ```
          if (has_input_changed_event_listener_ && !is_connected &&
          !is_disconnected && gamepads_[i] && gamepads_back_[i])
          ```
          cc: @ta...@microsoft.com
          Sneha Agarwal

          Functionally, both statements cannot execute at the same time because the conditions being checked are mutually exclusive. Adding else does not change the behavior, since the explicit conditions already prevent double-firing. I prefer to check the conditions explicitly for clarity and safety. At this point, I think this is a matter of style rather than correctness.

          Gabriel Brito
          Although the conditions might be mutually exclusive and work as expected, I am trying to say that this `if` condition looks unnecessarily complicated and the mutual exclusivity is not trivial to perceive. For example, the checks below are mutually exclusive:
          ```
          if (a && !b && !c && d):
          Do TaskA
          if (!a || b || c || !d):
          Do TaskB
          ```
          But they could be simplified by means of an `else`:
          ```
          if (a && !b && !c && d):
          Do TaskA
          else:
          Do TaskB
          ```

          Can't we rewrite it in a clearer way? If it is true that "_if a connection/disconnection event is fired, we don't need to fire a rawinput event in the same cycle_", then can't we use this information to simplify the rawinput event check?

          I suggest leaving this open for now so that Matt can give his opinion as an editor of the specification.

          Matt Reynolds

          My preference would be to factor out a method that processes changes for a single gamepad. The method could use early exits to guarantee that only one event is dispatched. (Chromium style generally prefers early exits over nested code blocks.)

          File third_party/blink/renderer/modules/gamepad/window_gamepad.idl
          Line 17, Patchset 37 (Latest): attribute EventHandler ongamepadrawinputchanged;
          Matt Reynolds . unresolved

          Instead of adding another partial interface, let's merge them into one partial interface and move the `RuntimeEnabled`s to the attribute level.

          ```
          [
          ImplementedAs=DOMWindowGamepad
          ] partial interface mixin WindowEventHandlers {
          [RuntimeEnabled=GamepadWindowEventHandlers] attribute EventHandler ongamepadconnected;
          [RuntimeEnabled=GamepadWindowEventHandlers] attribute EventHandler ongamepaddisconnected;
          [RuntimeEnabled=GamepadRawInputChangeEvent] attribute EventHandler ongamepadrawinputchanged;
          };
          ```
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Gabriel Brito
          • Sneha Agarwal
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 37
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Tue, 28 Oct 2025 20:16:52 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Gabriel Brito <gabrie...@microsoft.com>
          Comment-In-Reply-To: Sneha Agarwal <sneha...@microsoft.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Gabriel Brito (Gerrit)

          unread,
          Oct 31, 2025, 5:45:55 PM (2 days ago) Oct 31
          to Sneha Agarwal, Matt Reynolds, Michael Tang, Chromium LUCI CQ, AyeAye, Chromium Metrics Reviews, chromium...@chromium.org, Kentaro Hara, Raphael Kubo da Costa, edgecapab...@microsoft.com, android-web...@chromium.org, ashleynewson+w...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, mattreyno...@chromium.org
          Attention needed from Sneha Agarwal

          Gabriel Brito added 8 comments

          File device/gamepad/gamepad_service_unittest.cc
          Line 1263, Patchset 41 (Latest): // auto token = SetupRawInputGamepad(consumer);
          Gabriel Brito . unresolved

          nit: delete?

          Line 1279, Patchset 41 (Latest): const auto [id, gamepad] = future.Take();
          Gabriel Brito . unresolved

          Shouldn't it be `const auto&`? Same for the other occurrences

          File third_party/blink/renderer/modules/gamepad/gamepad_raw_input_change_event.h
          Line 73, Patchset 41 (Latest): // Stores an immutable (frozen) snapshot of the gamepad state at the time the
          // event was created.
          Gabriel Brito . unresolved

          nit: seems out of place now. Remove?

          Line 10, Patchset 41 (Latest):#include "third_party/blink/renderer/modules/gamepad/gamepad.h"
          Gabriel Brito . unresolved

          nit: not needed? You can get away with forward declaring `Gamepad`

          Line 8, Patchset 41 (Latest):#include "third_party/blink/renderer/bindings/modules/v8/v8_gamepad_raw_input_change_event_init.h"
          Gabriel Brito . unresolved

          nit: not needed? You can get away with forward declaring `GamepadRawInputChangeEventInit`.

          File third_party/blink/renderer/modules/gamepad/navigator_gamepad.cc
          Line 442, Patchset 41 (Latest):void NavigatorGamepad::DispatchGamepadEvent(
          Gabriel Brito . unresolved

          I don't think that creating this new method helps with the confusing logic in the `if` statement. I would revert it. Also, it is not clear that this method is called only if `compare_result.IsDifferent()` is true.

          Line 481, Patchset 41 (Latest): gamepads_[index] && gamepads_back_[index]) {
          Gabriel Brito . unresolved

          Is it really necessary to check for `gamepads_[index]` and `gamepads_back_[index]` in the `if` statement above since we know that `compare_result.IsDifferent()` is true?

          Are there any other scenarios besides connection where this would be true? See how we are already not firing it if either `is_connected` or `is_disconnected` are true? maybe we can remove the `gamepads_[index] && gamepads_back_[index]` check altogether?
          ```
          // The gamepad exists in both the current and previous samples
          // This ensures we only report input changes for gamepads that are
          // continuously present
          ```
          Line 482, Patchset 41 (Latest): is_gamepads_exposed_ = true;
          Gabriel Brito . unresolved

          Where are we exposing `gamepads_back_` to set this to true?

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Sneha Agarwal
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I022d6e79279f9fdeec41d6af1cc3520343f37a68
          Gerrit-Change-Number: 6897875
          Gerrit-PatchSet: 41
          Gerrit-Owner: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Reviewer: Michael Tang <ta...@microsoft.com>
          Gerrit-Reviewer: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-CC: Kentaro Hara <har...@chromium.org>
          Gerrit-CC: Raphael Kubo da Costa <ku...@igalia.com>
          Gerrit-Attention: Sneha Agarwal <sneha...@microsoft.com>
          Gerrit-Comment-Date: Fri, 31 Oct 2025 21:45:46 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages