[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 PM (6 days ago) Sep 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 PM (4 days ago) Oct 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 PM (4 days ago) Oct 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 PM (3 days ago) Oct 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 PM (2 days ago) Oct 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
        Reply all
        Reply to author
        Forward
        0 new messages