virtual void OnInputEvent(const RenderWidgetHost& host,
const blink::WebInputEvent& event,
const InputEventSource& source) {}I am wondering if this is the best approach here. Ideally I would like to avoid making changes to the content public API for this, since we would now be exposing input observer implementers of this extra detail.
Given the current scope, where InputTransferHandlerAndroid which is already owned by RenderWidgetHostViewAndroid, we can go with an alternate approach where InputTransferHandlerAndroid is directly notified about ResetGestureDetection.
WDYT?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
virtual void OnInputEvent(const RenderWidgetHost& host,
const blink::WebInputEvent& event,
const InputEventSource& source) {}I am wondering if this is the best approach here. Ideally I would like to avoid making changes to the content public API for this, since we would now be exposing input observer implementers of this extra detail.
Given the current scope, where InputTransferHandlerAndroid which is already owned by RenderWidgetHostViewAndroid, we can go with an alternate approach where InputTransferHandlerAndroid is directly notified about ResetGestureDetection.
WDYT?
Some of the locations in the browser-side input pipeline where a kTouchCancel event is generated or dispatched, are as follows:
1. [TouchEmulatorImpl::CancelTouch()](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/input/touch_emulator_impl.cc;l=487;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
2. [TouchTimeoutHandler::ConfirmTouchEvent()](https://source.chromium.org/chromium/chromium/src/+/main:components/input/touch_timeout_handler.cc;l=104;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
which calls [PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent()](https://source.chromium.org/chromium/chromium/src/+/main:components/input/passthrough_touch_event_queue.cc;l=87;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
4. [AndroidInputHelper::ResetGestureDetection()](https://source.chromium.org/chromium/chromium/src/+/main:components/input/android_input_helper.cc;l=84;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
5. [RenderWidgetHostViewIOS::OnTouchEvent()](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_ios_uiview.mm;l=237;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
6. [SyntheticGestureTargetAndroid::DispatchInputEvent()](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/input/synthetic_gesture_target_android.cc;l=111;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
Crucially, paths like TouchTimeoutHandler (which handles unresponsive renderers) do not trigger ResetGestureDetection. Thus simply notifying InputTransferHandlerAndroid about ResetGestureDetection might not be enough. In contrast, InputEventObserver is the centralized point for all input dispatch. By adding InputEventSource, we gain a robust consistent way to distinguish Browser vs. Viz events for
all current and future observers, not just this one handler. The 'cost' of the API change buys us long-term reliability.
The existing OnInputEventAck method already includes a
blink::mojom::InputEventResultSource parameter to indicate where the ack came from setting a precedent for this kind of distinction.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
virtual void OnInputEvent(const RenderWidgetHost& host,
const blink::WebInputEvent& event,
const InputEventSource& source) {}Aman VermaI am wondering if this is the best approach here. Ideally I would like to avoid making changes to the content public API for this, since we would now be exposing input observer implementers of this extra detail.
Given the current scope, where InputTransferHandlerAndroid which is already owned by RenderWidgetHostViewAndroid, we can go with an alternate approach where InputTransferHandlerAndroid is directly notified about ResetGestureDetection.
WDYT?
Some of the locations in the browser-side input pipeline where a kTouchCancel event is generated or dispatched, are as follows:
1. [TouchEmulatorImpl::CancelTouch()](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/input/touch_emulator_impl.cc;l=487;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
2. [TouchTimeoutHandler::ConfirmTouchEvent()](https://source.chromium.org/chromium/chromium/src/+/main:components/input/touch_timeout_handler.cc;l=104;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
which calls [PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent()](https://source.chromium.org/chromium/chromium/src/+/main:components/input/passthrough_touch_event_queue.cc;l=87;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
4. [AndroidInputHelper::ResetGestureDetection()](https://source.chromium.org/chromium/chromium/src/+/main:components/input/android_input_helper.cc;l=84;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
5. [RenderWidgetHostViewIOS::OnTouchEvent()](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_widget_host_view_ios_uiview.mm;l=237;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
6. [SyntheticGestureTargetAndroid::DispatchInputEvent()](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/input/synthetic_gesture_target_android.cc;l=111;drc=42c8b2a872d3c9322dba3eacbcc090618e923979)
Crucially, paths like TouchTimeoutHandler (which handles unresponsive renderers) do not trigger ResetGestureDetection. Thus simply notifying InputTransferHandlerAndroid about ResetGestureDetection might not be enough. In contrast, InputEventObserver is the centralized point for all input dispatch. By adding InputEventSource, we gain a robust consistent way to distinguish Browser vs. Viz events for
all current and future observers, not just this one handler. The 'cost' of the API change buys us long-term reliability.
The existing OnInputEventAck method already includes a
blink::mojom::InputEventResultSource parameter to indicate where the ack came from setting a precedent for this kind of distinction.
1. TouchEmulatorImpl::CancelTouch()
2. TouchTimeoutHandler::ConfirmTouchEvent()
which calls PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent()
3. AndroidInputHelper::ResetGestureDetection()
4. RenderWidgetHostViewIOS::OnTouchEvent()
5. SyntheticGestureTargetAndroid::DispatchInputEvent()
Thanks for digging into this more, 1,4, 5 doesn't seem to be directly related to InputVizard(for Android) use case.
For 2: `PassthroughTouchEventQueue::SendTouchCancelEventForTouchEvent` do we want it to affect InputTransferHandlerAndroid? i.e. a touch cancel generated due to an unresponsive renderer(few seconds ago) shouldn't probably impact processing a new touch sequence later?
Stepping back, what's the reason we think all the cancels generated on Browser should cause InputTransferHandler to reset state?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
touch cancel generated due to an unresponsive renderer(few seconds ago) shouldn't probably impact processing a new touch sequence later?
This mostly comes from how we are planning to handle forwarding of touch events/sequences when we are `kConsumeUntilCancel` state in `InputTransferHandlerAndroid` as part of this bug: https://crbug.com/383307455
virtual void OnInputEvent(const RenderWidgetHost& host,1,4, 5 doesn't seem to be directly related to InputVizard(for Android) use case.
This is correct, however InputEventObserver allows for a generic solution.
As discussed offline, I have added a condition in `InputTransferHandlerAndroid::InputObserver::OnInputEvent` to check if it's a relevant CANCEL event using
```
event.TimeStamp() >=
transfer_handler_->cached_transferred_sequence_down_time_ms_
```
to call Reset. In general, I think with this condition, using InputEventObserver decouples the inner working of InputTransferHandlerAndroid from RenderWidgetHostViewAndroid/GestureProvider's implementation and future proofs this code of missing relevant CANCEL events.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
// browser process or from the Viz process.s/from/in/, seems a little in-consistent with `in` used earlier in the sentence.
class InputTransferHandlerTest : public RenderViewHostTestHarness {Just wondering what is this required for?
const InputEventSource& source) {}We don't need to pass this by reference. We can just do `InputEventSource source`.
https://abseil.io/tips/234#pass-by-value:
```
Specifically, the types listed below should usually be passed by value:
Numeric and enumeration types (including protobuf enums).
```
virtual void OnInputEvent(const RenderWidgetHost& host,
const blink::WebInputEvent& event,
const InputEventSource& source) {}Thanks, with updated timestamp check and precedence of informing observers about ack input event source, the change LGTM.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
s/from/in/, seems a little in-consistent with `in` used earlier in the sentence.
Done
class InputTransferHandlerTest : public RenderViewHostTestHarness {Just wondering what is this required for?
This supports testing OnInputEvent which requires a RenderWidgetHost (obtained via rvh()->GetWidget()). This seemed to be the easiest way to satisfy the API's requirement for a valid reference without resorting to fragile hacks or the significant overhead of manually mocking a RenderWidgetHost.
const InputEventSource& source) {}We don't need to pass this by reference. We can just do `InputEventSource source`.
https://abseil.io/tips/234#pass-by-value:
```
Specifically, the types listed below should usually be passed by value:Numeric and enumeration types (including protobuf enums).
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
virtual ~InputEventObserver() {}Please fix this WARNING reported by ClangTidy: check: modernize-use-equals-default
use '= default' to define a trivial destruc...
check: modernize-use-equals-default
use '= default' to define a trivial destructor (https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html)
(Note: You can add `Skip-Clang-Tidy-Checks: modernize-use-equals-default` footer to the CL description to skip the check)
(Lint observed on `linux-clang-tidy-rel`, but not on `android-clang-tidy-rel`)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |