Closed Bug 1631754 Opened 5 years ago Closed 4 years ago

PanZoomController erroneously returns INPUT_RESULT_HANDLED

Categories

(GeckoView :: IME, defect, P1)

Unspecified
All
defect

Tracking

(firefox78 fixed)

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: petru, Assigned: kats)

References

Details

(Whiteboard: [geckoview:m78])

Attachments

(1 file)

For websites which have their own event handlers GV still returns INPUT_RESULT_HANDLED in between the first returns for how an event was handled.

I don't know if this is because of the async evaluation or how the events are queued but seems to be happening with all such websites (like Twitter, Google Maps, etc).

A video of a swipe down gesture on Twitter which shows Fenix's pull down to refresh erroneously appearing - https://drive.google.com/file/d/1TgecheYMDoZ-nGlgInhwnp6BDwXs-28E/view?usp=sharing
in response to GV which returns

2020-04-21 14:13:56.277 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT
2020-04-21 14:13:56.324 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED
2020-04-21 14:13:56.341 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED
2020-04-21 14:13:56.357 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT
2020-04-21 14:13:56.389 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT
2020-04-21 14:13:56.406 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT
2020-04-21 14:13:56.472 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT
2020-04-21 14:13:56.488 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT
2020-04-21 14:13:56.592 17990-17990/org.mozilla.fenix.debug E/InputResult: INPUT_RESULT_HANDLED_CONTENT

The above logs are the result of using

// Execute event handler from parent class in all cases
inputResult = handleEvent(event)
Log.e("InputResult", when(inputResult) {
    1 -> "INPUT_RESULT_HANDLED"
    2 -> "INPUT_RESULT_HANDLED_CONTENT"
    else -> "INPUT_RESULT_UNHANDLED"
})

here - https://github.com/mozilla-mobile/android-components/blob/cd134a34c94a4419167aa55b7c09babc9b6f60d8/components/browser/engine-gecko-beta/src/main/java/mozilla/components/browser/engine/gecko/NestedGeckoView.kt#L67
and so logging the return of GV's onTouchEventForResult(event)

Petru, for the dynamic toolbar they're making the decision to move based only on the result of the first ACTION_DOWN event. I think you'll probably have better results if you try the same.

Still, this kind of behavior seems wrong. Botond, can you take a look?

Flags: needinfo?(botond)

Based on the log pasted above I would imagine that we're hitting this exit condition and that is triggering this code which is missing the result.mTargetIsRoot check that we do later. The eConsumeNoDefault codepath can be coming from either content or chrome, so we should be checking mTargetIsRoot there.

You can verify if you run with MOZ_LOG=apz.inputqueue:4 and see if you get the log about slop from here turning up for those two events.

Flags: needinfo?(botond)

Might also be this exit condition which is equivalent to the other one I linked to.

If you quickly scroll the embedded playlist on this site, you'll get what I believe is the the same issue: https://newsroom.spotify.com/2018-09-04/how-to-embed-spotifys-play-button/

The same happens on github projects like: https://github.com/mozilla-mobile/fenix/projects

Here's a demo & some logs of this happening on the Spotify embedded playlist. Note this is all on ACTION_DOWN press. Seems like fast movement seems to make it more reproducible.

https://drive.google.com/file/d/1yjgY9vZK26i2lpw0VIjlAMVeY0x5CZFQ/view?usp=sharing

apz.inputqueue:4 logs show my issue does indeed follow the steps @kats described in comment 3!

But for the scenario Sawyer described
(quick scroll in an iframe like this) I saw that we are actually returning nsEventStatus_eConsumeDoDefault from here but then we get to here where based on result.mTargetIsRoot we erroneously return INPUT_RESULT_HANDLED.

See Also: → 1633322

@petru: the links in your previous comment are kinda broken, the markdown has nested brackets.

I'm also not totally clear on what you said - it sounds like there are two problems? The first being what I described earlier, and the second being a different issue producing the scenario Sawyer described. The second one seems like maybe mTargetIsRoot is true when you're expecting it to be false. Can you confirm my interpretation is correct?

We're looking at doing a major Fennec/Fenix comparison experiment in mid-May - would this change get in? I'm sure we'll see lots of complaints from users that bottom toolbar isn't auto-hiding, taking up browsing space, etc. but we can't ship with this if the toolbar isn't going to show, bc that would be a security risk.

At the same time, I don't have a good view of what other priorities or tradeoffs are, so happy to let Emily/Jeff chime in here.

+1 prioritizing this bug. Assuming this will address the major pain points with the bottom toolbar/scroll behaviour, this is a high priority issue for Fenix.

Flags: needinfo?(etoop)

Consult with snorp about whether to move this to graphics

Rank: 5
Flags: needinfo?(etoop)
Priority: -- → P2
Whiteboard: [geckoview:m78]

(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #8)

I'm also not totally clear on what you said - it sounds like there are two problems? The first being what I described earlier, and the second being a different issue producing the scenario Sawyer described. The second one seems like maybe mTargetIsRoot is true when you're expecting it to be false. Can you confirm my interpretation is correct?

Assuming this is the case, one potential issue here may be that we are setting mTargetIsRoot based on the tentative target, before any main-thread confirmation. If we're hitting a DTC region, we may report mTargetIsRoot=true but end up scrolling a subframe that gets activated.

If GV would like us to only report mTargetIsRoot=true if we know for sure we're going to be scrolling the root element, we should adjust our computation to be "(target apzc is the root) AND (did not hit a DTC region)".

(In reply to Botond Ballo [:botond] from comment #13)

If GV would like us to only report mTargetIsRoot=true if we know for sure we're going to be scrolling the root element, we should adjust our computation to be "(target apzc is the root) AND (did not hit a DTC region)".

(Technically, only two of the DTC reasons ("irregular area" and "inactive scrollframe") mean the target is ambiguous. However, observing that GV already checks for the third reason, "APZ-aware listeners", via the sister flag mHitRegionWithApzAwareListeners, and uses it for the same purpose (returning INPUT_RESULT_HANDLED_CONTENT), we may as well just combine the two flags and check for any DTC reason.)

Assignee: nobody → snorp
Priority: P2 → P1

(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #8)

@petru: the links in your previous comment are kinda broken, the markdown has nested brackets.

I'm also not totally clear on what you said - it sounds like there are two problems? The first being what I described earlier, and the second being a different issue producing the scenario Sawyer described. The second one seems like maybe mTargetIsRoot is true when you're expecting it to be false. Can you confirm my interpretation is correct?

Indeed, to me it seems like there are two situations in which PZC returns INPUT_RESULT_HANDLED instead of INPUT_RESULT_HANDLED_CONTENT:

And, importantly there is another issue which shows the opposite, INPUT_RESULT_HANDLED_CONTENT being returned instead of the expected INPUT_RESULT_HANDLED on some specific sites - bug 1633322

Ok, thanks for explaining. The patch for the first issue here is pretty simple, as I described already in comment 3. The second one (based on Sawyers report) might be explained by what Botond said, although we should verify that. If it's not explained by that we would need to investigate a bit more. It seems suspicious to me that the speed of the panning action affects the output; the only reason I can think that might be the case would be the fast fling detection code and that would also be handled by the first patch.

At any rate, the last issue (bug 1633322) seems like a different problem and needs investigation.

In particular, the eConsumeNoDefault case also needs to check for mTargetIsRoot
and the apz aware listeners flag.

Patch seems to fix both the issue in comment 0 (tested on twitter.com) and Sawyer's issue (tested on the spotify playlist). I tested using GVE.

Pushed by kgupta@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f049c6635dc2 Improve code to distinguish between root and content handling of events. r=snorp,geckoview-reviewers
Assignee: snorp → kats
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78

Moving some input bugs to the new GeckoView::IME component.

Component: General → IME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: