[TIMOB-15016] Android: TableView.headerView + swipe listener + no scrolling = crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-10-30T18:30:48.000+0000 |
Affected Version/s | Release 3.1.2 |
Fix Version/s | 2013 Sprint 22, 2013 Sprint 22 API, Release 3.2.0 |
Components | Android |
Labels | android, headerview, module_tableview, qe-testadded, swipe, tableview, triage |
Reporter | Fokke Zandbergen |
Assignee | Biju pm |
Created | 2013-08-16T07:37:41.000+0000 |
Updated | 2014-04-22T09:10:46.000+0000 |
Description
The following code causes a crash when swiping the table up and down.
To reproduce, change the number of rows (
l
) so that the table has as many rows it can take without needing to scroll.
If you remove the headerView
or the swipe
event listener, it no longer crashes.
var w = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var t = Ti.UI.createTableView();
t.headerView = Ti.UI.createView({
width: Ti.UI.FILL,
height: 50,
backgroundColor: 'red'
});
var d = [];
var l = 12;
for (var i = 0; i < l; i++) {
d.push(Ti.UI.createTableViewRow({
title: 'Row ' + i
}));
}
t.setData(d);
t.addEventListener('swipe', function () {
Ti.API.info('swipe');
});
w.add(t);
w.open();
The crash log:
08-16 09:31:41.133: E/MessageQueue-JNI(8879): java.lang.IndexOutOfBoundsException: Invalid index 12, size is 12
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at java.util.ArrayList.get(ArrayList.java:304)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at ti.modules.titanium.ui.widget.tableview.TiTableView.getItemAtPosition(TiTableView.java:411)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at ti.modules.titanium.ui.TableViewProxy.fireEvent(TableViewProxy.java:163)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at org.appcelerator.titanium.view.TiUIView.fireEvent(TiUIView.java:1476)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at org.appcelerator.titanium.view.TiUIView.fireEvent(TiUIView.java:1467)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at org.appcelerator.titanium.view.TiUIView$4.onFling(TiUIView.java:1187)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:1399)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at org.appcelerator.titanium.view.TiUIView$5.onTouch(TiUIView.java:1220)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.View.dispatchTouchEvent(View.java:7345)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2412)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2147)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2418)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2161)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2139)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1476)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.app.Activity.dispatchTouchEvent(Activity.java:2487)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2087)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.View.dispatchPointerEvent(View.java:7535)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3415)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3347)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4456)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4434)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4538)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.os.MessageQueue.nativePollOnce(Native Method)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.os.MessageQueue.next(MessageQueue.java:125)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.os.Looper.loop(Looper.java:124)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at java.lang.reflect.Method.invoke(Method.java:511)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
08-16 09:31:41.133: E/MessageQueue-JNI(8879): at dalvik.system.NativeStart.main(Native Method)
08-16 09:31:41.133: W/dalvikvm(8879): threadid=1: thread exiting with uncaught exception (group=0x412d22a0)
08-16 09:31:41.138: E/TiApplication(8879): (main) [2677,10633] Sending event: exception on thread: main msg:java.lang.IndexOutOfBoundsException: Invalid index 12, size is 12; Titanium 3.1.2,2013/08/14 12:46,5ceaff8
Reproduced on Android 4.1.2 x86 emulator with Ti SDK 3.1.2 GA. Note that it doesn't crash on Samsung Galaxy S2 Android 2.3.6.
PR:- https://github.com/appcelerator/titanium_mobile/pull/4654
Same issue exists for footerView and for TableViews that *are* long enough to require scroll. This is not a nice issue :(
Reproduced here on Nexus 4, galaxy S4 and in emulator. If you have eventhandlers (example: scroll) on a tableview AND a tableviewheader, scrolling to the end of the tableview crashes the app: [ERROR][TiApplication(11595)] (main) [191768,223392] Sending event: exception on thread: main msg:java.lang.IndexOutOfBoundsException: Invalid index 18, size is 18; Titanium 3.1.3,2013/09/18 12:01,222f4d1 [ERROR][TiApplication(11595)] java.lang.IndexOutOfBoundsException: Invalid index 18, size is 18 [ERROR][TiApplication(11595)] at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) [ERROR][TiApplication(11595)] at java.util.ArrayList.get(ArrayList.java:304) [ERROR][TiApplication(11595)] at ti.modules.titanium.ui.widget.tableview.TiTableView.getItemAtPosition(TiTableView.java:411) [ERROR][TiApplication(11595)] at ti.modules.titanium.ui.TableViewProxy.fireEvent(TableViewProxy.java:163) [ERROR][TiApplication(11595)] at org.appcelerator.titanium.view.TiUIView.fireEvent(TiUIView.java:1476) [ERROR][TiApplication(11595)] at org.appcelerator.titanium.view.TiUIView.fireEvent(TiUIView.java:1467) [ERROR][TiApplication(11595)] at org.appcelerator.titanium.view.TiUIView$5.onTouch(TiUIView.java:1246) [ERROR][TiApplication(11595)] at android.view.View.dispatchTouchEvent(View.java:5536)
same problem as TIMOB-12114
NEW PR : https://github.com/appcelerator/titanium_mobile/pull/4884
Verified and fixed on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201310312257 Titanium SDK, build: 3.2.0.v20131101115643 CLI: 3.2.2 Alloy: 1.2.2 Android Emulators: 2.3.3, 4.1.2 and 4.4 Android Devices: Samsung Galaxy Nexus 4.2.2 Swiping the table does not result in a crash. Closing.