You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Alessandro Preziosi (licnep)" <ls...@gmail.com> on 2012/10/30 02:00:14 UTC

firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Hi all,
I'm trying to make a drawing on a canvas, but the ontouchmove events fired
are a bit too few, it doesn't catch small movements, and if you draw a
circle fast it looks like a square.
Why is that? I'd like to fix this.
I tried adding an ontouch listener to the webview
(webView.setOnTouchListener(l)) and in fact it gets many more events than
the javascript code does. I tried passing those to javascrpt
( this.webView.sendJavascript("javascript:onHiresTouch("+e.getRawX()+","+e.GetRawY+");");
), but it's very slow and laggy, plus the coordinate system is different.
There must be a better way to handle this. Anyone has an idea? Any
source/docs i should take a look at?

cheers,
al

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Joe Bowser <bo...@gmail.com>.
On Tue, Oct 30, 2012 at 4:30 PM, Alessandro Preziosi (licnep)
<ls...@gmail.com> wrote:
>>Either way I bet if the events were buffered we could get better
>>resolution which would be a win ---- I think Joe was looking at
>>something similar last year.
> Yea that'd be great, (android already batches touch events itself
> (MotionEvent.getHistoricalX(int,int)) )
>
>>Can we get more information on this issue? For example, which version
>>of Android are you trying this out on? That might help explain what's
>>going on with touch events, since the issue I was finding was with
>>multitouch going in as two single touches on Android 2.x, not the
>>performance of the touches being passed to WebKit.
> I'm testing on an android 2.3.6 (galaxy s plus), but i've tried on
> other phones too. (btw, i think you're right about multi touch events
> and android 2.x going as a single touch). and I'm currently using
> cordova 2.0.0.

It's a fact.  Zoom is totally faked on Android's WebView.  There is a
shim that someone implemented to give Android 2.x WebView multitouch,
but we haven't seriously looked into porting it into Cordova, since it
would be an lot of work, and it may not work with our current
CordovaWebView approach.  Have you tested on an ICS or Jellybean
Android Device?

>
> There's also something strange in how the webview updates during touch
> events. For example, i have animated a loading icon (using
> window.setInterval), and if you touch the screen during the animation
> it freezes, it is not updated anymore, it only starts moving again
> when you lift your finger...

That's really odd.  It's possible that it thinks you selected it.
Does it get an orange border around it?

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Jesse <pu...@gmail.com>.
24x sounds better to me

On Wed, Oct 31, 2012 at 3:57 PM, Andrew Grieve <ag...@chromium.org> wrote:
> The 25x is based on the mobile-spec benchmark Braden mentioned. That's for
> non-synchronous plugins. There are lots of details in the bug (
> issues.cordova.io/638). The 25x is based on the PROMPT+HANGING_GET number
> in this spreadsheet<https://docs.google.com/a/google.com/spreadsheet/ccc?key=0Aq9kFRDB1QGhdEtZZENBMThLSDdRUVJfRUFzVW5LSVE#gid=0>
> on
> sheet 1 vs. the JS_OBJECT + LOAD_URL number on the last sheet. Note that
> it's actually 24x, but 25 sounds better :).
>
> Improvements to the existing benchmark, or even new benchmarks would be a
> welcome contribution :)
>
>
> On Wed, Oct 31, 2012 at 9:50 AM, Braden Shepherdson <br...@chromium.org>wrote:
>
>> We have a bridge speed test in mobile-spec already. The last entry in the
>> main screen is "Benchmark". Andrew made this a while back while working on
>> the iOS bridge, but it should let you select between all available bridges
>> on whichever platform, and measure their speed.
>>
>> Braden
>>
>>
>> On Wed, Oct 31, 2012 at 3:01 AM, Filip Maj <fi...@adobe.com> wrote:
>>
>> > Brian recently suggested incorporating some kind of baseline bridge
>> > benchmark into mobile-spec. It would be nice to track the progression of
>> a
>> > standard "bridge speed" metric into our daily commits.
>> >
>> > On 10/30/12 11:19 PM, "Lorin Beer" <lo...@gmail.com> wrote:
>> >
>> > >Hey Andrew,
>> > >
>> > >bridge speed on android is of particular interest to me, and
>> > >Pender<https://github.com/lorinbeer/pender-android>
>> > >
>> > >I have a working Pender-Cordova Plugin, and a 25x increase in bridge
>> speed
>> > >would massively affect possible usage.
>> > >Is 25x a metric, or an approximation?
>> > >Do we have a benchmark tool for Cordova Android bridge speed?
>> > >If not, would a bridge speed benchmark tool be of interest? I wrote one
>> > >about a year and a half ago, and could massage it into something useful.
>> > >
>> > >- Lorin
>> > >
>> > >
>> > >On Tue, Oct 30, 2012 at 8:48 PM, Alessandro Preziosi (licnep) <
>> > >lsnpreziosi@gmail.com> wrote:
>> > >
>> > >> >My understanding is as follows:
>> > >> >Unless you preventDefault() on the touchstart event, then dragging
>> your
>> > >> >finger will attempt to scroll the page. Once scroll mode has begun,
>> no
>> > >>JS
>> > >> >callbacks are called until you lift your finger and exit scroll mode.
>> > >> great explanation, sounds like it could be the case, thanks
>> > >>
>> >
>> >
>>



-- 
@purplecabbage
risingj.com

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Andrew Grieve <ag...@chromium.org>.
The 25x is based on the mobile-spec benchmark Braden mentioned. That's for
non-synchronous plugins. There are lots of details in the bug (
issues.cordova.io/638). The 25x is based on the PROMPT+HANGING_GET number
in this spreadsheet<https://docs.google.com/a/google.com/spreadsheet/ccc?key=0Aq9kFRDB1QGhdEtZZENBMThLSDdRUVJfRUFzVW5LSVE#gid=0>
on
sheet 1 vs. the JS_OBJECT + LOAD_URL number on the last sheet. Note that
it's actually 24x, but 25 sounds better :).

Improvements to the existing benchmark, or even new benchmarks would be a
welcome contribution :)


On Wed, Oct 31, 2012 at 9:50 AM, Braden Shepherdson <br...@chromium.org>wrote:

> We have a bridge speed test in mobile-spec already. The last entry in the
> main screen is "Benchmark". Andrew made this a while back while working on
> the iOS bridge, but it should let you select between all available bridges
> on whichever platform, and measure their speed.
>
> Braden
>
>
> On Wed, Oct 31, 2012 at 3:01 AM, Filip Maj <fi...@adobe.com> wrote:
>
> > Brian recently suggested incorporating some kind of baseline bridge
> > benchmark into mobile-spec. It would be nice to track the progression of
> a
> > standard "bridge speed" metric into our daily commits.
> >
> > On 10/30/12 11:19 PM, "Lorin Beer" <lo...@gmail.com> wrote:
> >
> > >Hey Andrew,
> > >
> > >bridge speed on android is of particular interest to me, and
> > >Pender<https://github.com/lorinbeer/pender-android>
> > >
> > >I have a working Pender-Cordova Plugin, and a 25x increase in bridge
> speed
> > >would massively affect possible usage.
> > >Is 25x a metric, or an approximation?
> > >Do we have a benchmark tool for Cordova Android bridge speed?
> > >If not, would a bridge speed benchmark tool be of interest? I wrote one
> > >about a year and a half ago, and could massage it into something useful.
> > >
> > >- Lorin
> > >
> > >
> > >On Tue, Oct 30, 2012 at 8:48 PM, Alessandro Preziosi (licnep) <
> > >lsnpreziosi@gmail.com> wrote:
> > >
> > >> >My understanding is as follows:
> > >> >Unless you preventDefault() on the touchstart event, then dragging
> your
> > >> >finger will attempt to scroll the page. Once scroll mode has begun,
> no
> > >>JS
> > >> >callbacks are called until you lift your finger and exit scroll mode.
> > >> great explanation, sounds like it could be the case, thanks
> > >>
> >
> >
>

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Braden Shepherdson <br...@chromium.org>.
We have a bridge speed test in mobile-spec already. The last entry in the
main screen is "Benchmark". Andrew made this a while back while working on
the iOS bridge, but it should let you select between all available bridges
on whichever platform, and measure their speed.

Braden


On Wed, Oct 31, 2012 at 3:01 AM, Filip Maj <fi...@adobe.com> wrote:

> Brian recently suggested incorporating some kind of baseline bridge
> benchmark into mobile-spec. It would be nice to track the progression of a
> standard "bridge speed" metric into our daily commits.
>
> On 10/30/12 11:19 PM, "Lorin Beer" <lo...@gmail.com> wrote:
>
> >Hey Andrew,
> >
> >bridge speed on android is of particular interest to me, and
> >Pender<https://github.com/lorinbeer/pender-android>
> >
> >I have a working Pender-Cordova Plugin, and a 25x increase in bridge speed
> >would massively affect possible usage.
> >Is 25x a metric, or an approximation?
> >Do we have a benchmark tool for Cordova Android bridge speed?
> >If not, would a bridge speed benchmark tool be of interest? I wrote one
> >about a year and a half ago, and could massage it into something useful.
> >
> >- Lorin
> >
> >
> >On Tue, Oct 30, 2012 at 8:48 PM, Alessandro Preziosi (licnep) <
> >lsnpreziosi@gmail.com> wrote:
> >
> >> >My understanding is as follows:
> >> >Unless you preventDefault() on the touchstart event, then dragging your
> >> >finger will attempt to scroll the page. Once scroll mode has begun, no
> >>JS
> >> >callbacks are called until you lift your finger and exit scroll mode.
> >> great explanation, sounds like it could be the case, thanks
> >>
>
>

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Filip Maj <fi...@adobe.com>.
Brian recently suggested incorporating some kind of baseline bridge
benchmark into mobile-spec. It would be nice to track the progression of a
standard "bridge speed" metric into our daily commits.

On 10/30/12 11:19 PM, "Lorin Beer" <lo...@gmail.com> wrote:

>Hey Andrew,
>
>bridge speed on android is of particular interest to me, and
>Pender<https://github.com/lorinbeer/pender-android>
>
>I have a working Pender-Cordova Plugin, and a 25x increase in bridge speed
>would massively affect possible usage.
>Is 25x a metric, or an approximation?
>Do we have a benchmark tool for Cordova Android bridge speed?
>If not, would a bridge speed benchmark tool be of interest? I wrote one
>about a year and a half ago, and could massage it into something useful.
>
>- Lorin
>
>
>On Tue, Oct 30, 2012 at 8:48 PM, Alessandro Preziosi (licnep) <
>lsnpreziosi@gmail.com> wrote:
>
>> >My understanding is as follows:
>> >Unless you preventDefault() on the touchstart event, then dragging your
>> >finger will attempt to scroll the page. Once scroll mode has begun, no
>>JS
>> >callbacks are called until you lift your finger and exit scroll mode.
>> great explanation, sounds like it could be the case, thanks
>>


Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Lorin Beer <lo...@gmail.com>.
Hey Andrew,

bridge speed on android is of particular interest to me, and
Pender<https://github.com/lorinbeer/pender-android>

I have a working Pender-Cordova Plugin, and a 25x increase in bridge speed
would massively affect possible usage.
Is 25x a metric, or an approximation?
Do we have a benchmark tool for Cordova Android bridge speed?
If not, would a bridge speed benchmark tool be of interest? I wrote one
about a year and a half ago, and could massage it into something useful.

- Lorin


On Tue, Oct 30, 2012 at 8:48 PM, Alessandro Preziosi (licnep) <
lsnpreziosi@gmail.com> wrote:

> >My understanding is as follows:
> >Unless you preventDefault() on the touchstart event, then dragging your
> >finger will attempt to scroll the page. Once scroll mode has begun, no JS
> >callbacks are called until you lift your finger and exit scroll mode.
> great explanation, sounds like it could be the case, thanks
>

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by "Alessandro Preziosi (licnep)" <ls...@gmail.com>.
>My understanding is as follows:
>Unless you preventDefault() on the touchstart event, then dragging your
>finger will attempt to scroll the page. Once scroll mode has begun, no JS
>callbacks are called until you lift your finger and exit scroll mode.
great explanation, sounds like it could be the case, thanks

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Andrew Grieve <ag...@chromium.org>.
On Tue, Oct 30, 2012 at 8:28 PM, Alessandro Preziosi (licnep) <
lsnpreziosi@gmail.com> wrote:

> >>There's also something strange in how the webview updates during touch
> >>events. For example, i have animated a loading icon (using
> >>window.setInterval), and if you touch the screen during the animation
> >>it freezes, it is not updated anymore, it only starts moving again
> >>when you lift your finger...
> >
> >That's really odd.  It's possible that it thinks you selected it.
> >Does it get an orange border around it?
> it doesn't, it looks like a system wide problem, it also happens with
> my browser (dolphin browser) and the default one. If you try to go on
> pages with animations (eg: http://fx.inetcat.com/  or
> http://jsanim.com/ ), you can that see the animations stop if you put
> your finger on the screen and start moving it around (if you just
> touch the problem doesn't happen, only if you 'drag'). It's a bit of
> an annoying issue when trying to build native looking apps... hope it
> gets fixed, or a workaround is found
>

My understanding is as follows:
Unless you preventDefault() on the touchstart event, then dragging your
finger will attempt to scroll the page. Once scroll mode has begun, no JS
callbacks are called until you lift your finger and exit scroll mode.

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by "Alessandro Preziosi (licnep)" <ls...@gmail.com>.
>>There's also something strange in how the webview updates during touch
>>events. For example, i have animated a loading icon (using
>>window.setInterval), and if you touch the screen during the animation
>>it freezes, it is not updated anymore, it only starts moving again
>>when you lift your finger...
>
>That's really odd.  It's possible that it thinks you selected it.
>Does it get an orange border around it?
it doesn't, it looks like a system wide problem, it also happens with
my browser (dolphin browser) and the default one. If you try to go on
pages with animations (eg: http://fx.inetcat.com/  or
http://jsanim.com/ ), you can that see the animations stop if you put
your finger on the screen and start moving it around (if you just
touch the problem doesn't happen, only if you 'drag'). It's a bit of
an annoying issue when trying to build native looking apps... hope it
gets fixed, or a workaround is found

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by "Alessandro Preziosi (licnep)" <ls...@gmail.com>.
>Either way I bet if the events were buffered we could get better
>resolution which would be a win ---- I think Joe was looking at
>something similar last year.
Yea that'd be great, (android already batches touch events itself
(MotionEvent.getHistoricalX(int,int)) )

>Can we get more information on this issue? For example, which version
>of Android are you trying this out on? That might help explain what's
>going on with touch events, since the issue I was finding was with
>multitouch going in as two single touches on Android 2.x, not the
>performance of the touches being passed to WebKit.
I'm testing on an android 2.3.6 (galaxy s plus), but i've tried on
other phones too. (btw, i think you're right about multi touch events
and android 2.x going as a single touch). and I'm currently using
cordova 2.0.0.

There's also something strange in how the webview updates during touch
events. For example, i have animated a loading icon (using
window.setInterval), and if you touch the screen during the animation
it freezes, it is not updated anymore, it only starts moving again
when you lift your finger...

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by "Alessandro Preziosi (licnep)" <ls...@gmail.com>.
>The Android bridge is about 25X faster in the 2.2.0 release candidate.
>2.2.0 final should be released in the next couple of days, so I'd try your
>test again with that. I'd definitely like to know if piping the events
>through yourself ends up being faster than the browser events.

Interesting news, thanks. I'll try that.

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Joe Bowser <bo...@gmail.com>.
Can we get more information on this issue? For example, which version
of Android are you trying this out on? That might help explain what's
going on with touch events, since the issue I was finding was with
multitouch going in as two single touches on Android 2.x, not the
performance of the touches being passed to WebKit.

On Tue, Oct 30, 2012 at 10:56 AM, Brian LeRoux <b...@brian.io> wrote:
> Either way I bet if the events were buffered we could get beter
> resolution which would be a win ---- I think Joe was looking at
> something similar last year.
>
>
> On Tue, Oct 30, 2012 at 9:02 AM, Andrew Grieve <ag...@chromium.org> wrote:
>> The Android bridge is about 25X faster in the 2.2.0 release candidate.
>> 2.2.0 final should be released in the next couple of days, so I'd try your
>> test again with that. I'd definitely like to know if piping the events
>> through yourself ends up being faster than the browser events.
>>
>>
>> On Mon, Oct 29, 2012 at 9:00 PM, Alessandro Preziosi (licnep) <
>> lsnpreziosi@gmail.com> wrote:
>>
>>> Hi all,
>>> I'm trying to make a drawing on a canvas, but the ontouchmove events fired
>>> are a bit too few, it doesn't catch small movements, and if you draw a
>>> circle fast it looks like a square.
>>> Why is that? I'd like to fix this.
>>> I tried adding an ontouch listener to the webview
>>> (webView.setOnTouchListener(l)) and in fact it gets many more events than
>>> the javascript code does. I tried passing those to javascrpt
>>> (
>>> this.webView.sendJavascript("javascript:onHiresTouch("+e.getRawX()+","+e.GetRawY+");");
>>> ), but it's very slow and laggy, plus the coordinate system is different.
>>> There must be a better way to handle this. Anyone has an idea? Any
>>> source/docs i should take a look at?
>>>
>>> cheers,
>>> al
>>>

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Brian LeRoux <b...@brian.io>.
Either way I bet if the events were buffered we could get beter
resolution which would be a win ---- I think Joe was looking at
something similar last year.


On Tue, Oct 30, 2012 at 9:02 AM, Andrew Grieve <ag...@chromium.org> wrote:
> The Android bridge is about 25X faster in the 2.2.0 release candidate.
> 2.2.0 final should be released in the next couple of days, so I'd try your
> test again with that. I'd definitely like to know if piping the events
> through yourself ends up being faster than the browser events.
>
>
> On Mon, Oct 29, 2012 at 9:00 PM, Alessandro Preziosi (licnep) <
> lsnpreziosi@gmail.com> wrote:
>
>> Hi all,
>> I'm trying to make a drawing on a canvas, but the ontouchmove events fired
>> are a bit too few, it doesn't catch small movements, and if you draw a
>> circle fast it looks like a square.
>> Why is that? I'd like to fix this.
>> I tried adding an ontouch listener to the webview
>> (webView.setOnTouchListener(l)) and in fact it gets many more events than
>> the javascript code does. I tried passing those to javascrpt
>> (
>> this.webView.sendJavascript("javascript:onHiresTouch("+e.getRawX()+","+e.GetRawY+");");
>> ), but it's very slow and laggy, plus the coordinate system is different.
>> There must be a better way to handle this. Anyone has an idea? Any
>> source/docs i should take a look at?
>>
>> cheers,
>> al
>>

Re: firing more ontouchmove javascript events on android? Higher resolution / precision for ontouchmove?

Posted by Andrew Grieve <ag...@chromium.org>.
The Android bridge is about 25X faster in the 2.2.0 release candidate.
2.2.0 final should be released in the next couple of days, so I'd try your
test again with that. I'd definitely like to know if piping the events
through yourself ends up being faster than the browser events.


On Mon, Oct 29, 2012 at 9:00 PM, Alessandro Preziosi (licnep) <
lsnpreziosi@gmail.com> wrote:

> Hi all,
> I'm trying to make a drawing on a canvas, but the ontouchmove events fired
> are a bit too few, it doesn't catch small movements, and if you draw a
> circle fast it looks like a square.
> Why is that? I'd like to fix this.
> I tried adding an ontouch listener to the webview
> (webView.setOnTouchListener(l)) and in fact it gets many more events than
> the javascript code does. I tried passing those to javascrpt
> (
> this.webView.sendJavascript("javascript:onHiresTouch("+e.getRawX()+","+e.GetRawY+");");
> ), but it's very slow and laggy, plus the coordinate system is different.
> There must be a better way to handle this. Anyone has an idea? Any
> source/docs i should take a look at?
>
> cheers,
> al
>