-
Notifications
You must be signed in to change notification settings - Fork 472
GeckoView - InputResultDetail syncronization issues #10585
Comments
Sorry I completely missed this, I put a reminder to take a look on monday. |
I think in general we should not take 500ms to respond to a
I'm not clear exactly what that would look like, are you suggesting GeckoView would be the one displaying the throbber/dynamic toolbar? even with that I'm not sure that would fix this problem, we don't really know more than the app does at the GeckoView level (and if we do we should find a way to expose it in the API IMO, but I want to understand what your proposal is) Let me see if I'm understanding the problem: what is happening here is that when the user starts scrolling the screen we need to start the refresh throbber, if GeckoView comes back and says that the scroll action was handled, then we cancel the throbber action, is that correct? My uneducated guess here is that there's a javascript handler that's making us take a long time to respond to @hiikezoe any ideas? Am I completely off base here? |
A quick update I can tell now is;
This is not true. We have (APZ has) to wait for a reply from the main-thread (i.e. from the content's JS mainly) if there's any event listeners or some such which might be handled by APZ. For example, if the content has an event listener for touch events and the handler invokes preventDefault() then APZ shouldn't handle the event. There is a pref value how we wait for the response from the main-thread; https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/mobile/android/app/mobile.js#376 I will re-read all relevant comments later. |
This is exactly what we do in APZ. We are actully doing the short-circuit in such cases. What I am suspecting is the site in question does start listening touchmove events inside an event handler for touchstart events. Anyways, I am suspecting with the current setup in A-C there's definitely a race condition in between when we set this inputResultDetail and when we query the result. With the setup we can't tell the queried result is the corresponding result of the given input event. |
This is true. With some logs around that code for when the bug reproduces I get:
So it's quite probable there is a bug to be resolved somewhere in GV/Gecko. |
Though I don't quite understand the reason why we can't block, I am supposing we don't need to block, we can just defer it until we get the corresponding response from GV? Also I am wondering how Chrome handles those cases? |
In regards to the first part we don't really have where to block. For both the pull to refresh and the dynamic toolbar feature we are using framework apis to which we pass (or they simply get passed to) MotionEvents the same way they get passed to GeckoView. For the toolbar we're using our own This is why I was proposing for GeckoView to inform the app about the scrolls, flings, overscrolls and their distances. But since we are in the process of moving to a new toolkit for building the UI maybe we can take this opportunity to think about supporting the new much simpler API for the same general flow described above - Compose - nestedScroll official documentation & complete sample. If GeckoView would support these methods we'd probably be able to then plug (and play) any other Views we want, like a dynamic toolbar or a pull to refresh view, overscroll edge effect, etc which would entirely be driven by GeckoView - by the events and distances it informs us about. |
Thanks for the detailed explanation. I think now I understand what the underlying issue is. Though I am not sure such APIs should be in GeckoView or inside A-C, it sounds promising. Presumably it doesn't matter where the APIs are initially since it can be easily ported to A-C from GeckoView or vise versa. Anyways, to me you are the best person to implement the APIs. :) |
Would very much like to work on this! The app is only interested in how the page moved (not really in what the user gestured on screen) and would be awesome if it didn't have to try to infer this separate from GV based on the same MotionEvents. If GV would expose a stream of scroll data
) I get that is is probably a big change (although I hope all the work until now is reusable and probably all the data is already there) and this is why I wanted to first ask if something like this can be considered with implementation details to be later discussed. |
One caveat I can tell is the amount of scroll pixels is not what you want. So for example if the content is scaled by 0.5x, the scroll amount is 2x larger than the value on 1.0x scaled content in the content's coords but the delta on the screen will be same. |
Makes sense. |
I need to look into this more, but from a first glance this sounds like something I would support having in GeckoView. I agree the complexity of this whole feature is really high and it would be nice if we could hide it from AC/Fenix as much as possible. |
ouch so we wait as much as 600ms? I think that's really high, especially on powerful devices. I wonder if we could lower it a little bit |
As you may have already noticed, the value is 400ms on desktop it's not so much difference.
The delta in the screen coords can be calculated in GeckoView or AC (Fenix), you can just ignore the content scale. I am assuming you are supposing something like this;
In this case, the browser should do nothing. In other words, once after the content, or Gecko started consuming touch events, the browser should do nothing until the user leaves his fingers (or the events is interrupted by other type of events). Of course it's likely there's any edge cases I am not aware of. |
Moved to bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1795420 Change performed by the Move to Bugzilla add-on. |
Seen on mozilla-mobile/fenix#18451 (comment) - https://sortablejs.github.io/Sortable/
Having pull to refresh enabled will not allow a second reorder down of the items.
NoReorder.mp4
This is happening because with a log here in that particular scenario (that can be repeated for any number of times) the time from
ACTION_DOWN
and until we get a response from GeckoView about how that touch was handled is >100 ms (also seen ~500ms for this scenario).This is a lot more than the usual ~50 ms
(probably there is a bug to be fixed on GeckoView's side because this happens only on the second swipe down for which GV responds that it handled the touch, not the website as we'd expect)
and because we need to be preemptive about pull to refresh, that functionality will start and in such prevent dispatching any new touch events to the child view - GeckoView. (It will actually receive
ACTION_CANCEL
because the parent is handling the touch).If we are to wait until we are actually getting a response from GeckoView, like we do here #10555 then pull to refresh won't be possible to activate for that touch.
As we are dropping MotionEvents until waiting to get the response from GeckoView we'll drop some initial ones and then when trying to start the feature (based on GeckoViews response) we'd get an Got ACTION_MOVE event but don't have an active pointer id error. (That's why we need to be preemptive about it and start the feature, send it that initial
ACTION_DOWN
but then cancel the feature based on the response from pull to refresh, )if that reponse comes in a reasonable time, before actually starting to show the throbber.I think this issue (and #10555 also) show a big caveat in our implementation and the general feature as it has to work between GeckoView and clients: The same user touch is handled both in the client and in GeckoView and then both results have to be merged but any bigger delay will break pull to refresh / dynamic toolbar or even the browser (as it's a child View in the app).
Based on this and also other features linked here I'd like to start a discussion about the opportunity of rethinking these features and reimplementing them.
The direction I propose is having both the pull to refresh and the dynamic toolbar be driven by GeckoView. Similar to the edge effect and how the dynamic toolbar was implemented in Fennec. This would ensure a consistent UX with no synchronization issues.
Asking @pocmo @agi for their opinion.
┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: