ahmedeng165 / flot-android-chart

Automatically exported from code.google.com/p/flot-android-chart
0 stars 0 forks source link

Android 3.1 gesture crash #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
How to reproduce
1. Load any Flot graph on a 3.1 device.
2. Randomly tap the screen with many fingers or attempt a pinch gesture.
3. MotionEvent::getX(int i) or MotionEvent::getY(int i) will throw
java.lang.IllegalArgumentException: pointerIndex out of range

This is due to api changes in 3.1. See 
http://code.google.com/p/android/issues/detail?id=16836

Using the Samsung Galaxy Tap 10.1.

Fix

Add bounds check for every call to get(XY) 

For example in FlotChartContainer.java line 134

replace 

final float x1 = ev.getX(pointerIndex);
final float y1 = ev.getY(pointerIndex);

mLastTouchX = x1;
mLastTouchY = y1;

with 

if ( pointerIndex > 0 && 
      pointerIndex < ev.getPointerCount() )
{

    final float x1 = ev.getX(pointerIndex);
    final float y1 = ev.getY(pointerIndex);

    mLastTouchX = x1;
    mLastTouchY = y1;
}

Original issue reported on code.google.com by nab...@gmail.com on 23 Jun 2011 at 8:07

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have same problem, and the exception is like below.
I am using Android 2.2.
I touched the screen with many fingers.

06-28 02:39:47.959: ERROR/AndroidRuntime(27959): FATAL EXCEPTION: main
06-28 02:39:47.959: ERROR/AndroidRuntime(27959): 
java.lang.ArrayIndexOutOfBoundsException
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.MotionEvent.getX(MotionEvent.java:779)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
com.flotandroidchart.flot.FlotChartContainer$1.onTouch(FlotChartContainer.java:1
33)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.View.dispatchTouchEvent(View.java:3762)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(P
honeWindow.java:1677)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow
.java:1107)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.app.Activity.dispatchTouchEvent(Activity.java:2086)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneW
indow.java:1661)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.os.Looper.loop(Looper.java:123)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
android.app.ActivityThread.main(ActivityThread.java:4627)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
java.lang.reflect.Method.invokeNative(Native Method)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
java.lang.reflect.Method.invoke(Method.java:521)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-28 02:39:47.959: ERROR/AndroidRuntime(27959):     at 
dalvik.system.NativeStart.main(Native Method)

Original comment by kyungin....@gmail.com on 28 Jun 2011 at 6:40

GoogleCodeExporter commented 8 years ago
If you like you can try my build with the fix I wrote about.
See attached file.

Original comment by nab...@gmail.com on 28 Jun 2011 at 1:16

Attachments:

GoogleCodeExporter commented 8 years ago
wawoo~ nab~ you fixed that bug! Thank you so much~~~~
However, I need more kind of chart such as radar chart...
So I tried to use Google chart API.
http://code.google.com/intl/pl-PL/apis/chart/image/docs/making_charts.html
I hope more chart types can be offered in this library~ =) ASAP~

Original comment by kyungin....@gmail.com on 1 Jul 2011 at 7:21

GoogleCodeExporter commented 8 years ago
confirm, it crashes on android 2.3.5:

02-08 12:34:18.549: ERROR/AndroidRuntime(28378): FATAL EXCEPTION: main
        java.lang.ArrayIndexOutOfBoundsException
        at android.view.MotionEvent.getX(MotionEvent.java:889)
        at com.flotandroidchart.flot.FlotChartContainer$1.onTouch(FlotChartContainer.java:135)
        at android.view.View.dispatchTouchEvent(View.java:3881)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1750)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1135)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1734)
        at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2216)
        at android.view.ViewRoot.handleMessage(ViewRoot.java:1887)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3687)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
        at dalvik.system.NativeStart.main(Native Method)

I suppose it does not depend on android version.

Original comment by d...@antonsmirnov.name on 8 Feb 2012 at 6:35