Project: titanium
Issue TIMOB-20038: Android: TableView crashes when scrolling more than 29 rows
When executing the following code, if there are more than 29 rows, the app will crash when scrolling back up from the bottom of the TableView: (You may need to try more than 30 rows for the app to crash, as each device may vary this number) {code} var section = Ti.UI.createTableViewSection(); var numberOfRows = 30;	//if > 29 the app will crash when scrolling back up from the bottom for (var i=0; i < numberOfRows; i++)	{	//fill section with rows	section.add(Ti.UI.createTableViewRow({	height: 50,	width: Ti.UI.FILL,	backgroundColor: 'green',	className: 'row' + i	})); }; var table = Ti.UI.createTableView({	top: 0,	left: 0,	height: Ti.UI.FILL,	width: Ti.UI.FILL,	data: [ section ] }); var window = Ti.UI.createWindow({	fullscreen: true	}); window.add(table); window.open(); {code} *The error log from the Studio console is:* {code} [ERROR] : InputEventReceiver: Exception dispatching input event. [DEBUG] : AndroidRuntime: Shutting down VM [WARN] : dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x410532a0) [ERROR] : TiApplication: (main) [25408,25408] Sending event: exception on thread: main msg:java.lang.ArrayIndexOutOfBoundsException: length=32; index=32; Titanium 3.5.1,2015/03/05 10:08,96875c9 [ERROR] : TiApplication: java.lang.ArrayIndexOutOfBoundsException: length=32; index=32 [ERROR] : TiApplication: android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:7127) [ERROR] : TiApplication: android.widget.AbsListView.trackMotionScroll(AbsListView.java:5694) [ERROR] : TiApplication: android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3424) [ERROR] : TiApplication: android.widget.AbsListView.onTouchEvent(AbsListView.java:4099) [ERROR] : TiApplication: android.view.View.dispatchTouchEvent(View.java:7350) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2464) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2197) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2470) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2212) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2470) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2212) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2470) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2212) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2470) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2212) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2470) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2212) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2470) [ERROR] : TiApplication: android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2212) [ERROR] : TiApplication: com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2151) [ERROR] : TiApplication: com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1480) [ERROR] : TiApplication: android.app.Activity.dispatchTouchEvent(Activity.java:2469) [ERROR] : TiApplication: android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:268) [ERROR] : TiApplication: com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2099) [ERROR] : TiApplication: android.view.View.dispatchPointerEvent(View.java:7535) [ERROR] : TiApplication: android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3492) [ERROR] : TiApplication: android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3424) [ERROR] : TiApplication: android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4534) [ERROR] : TiApplication: android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4512) [ERROR] : TiApplication: android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4616) [ERROR] : TiApplication: android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171) [ERROR] : TiApplication: android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) [ERROR] : TiApplication: android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:163) [ERROR] : TiApplication: android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4584) [ERROR] : TiApplication: android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4635) [ERROR] : TiApplication: android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) [ERROR] : TiApplication: android.view.Choreographer.doCallbacks(Choreographer.java:555) [ERROR] : TiApplication: [ERROR] : TiApplication: android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) [ERROR] : TiApplication: android.os.Handler.handleCallback(Handler.java:615) [ERROR] : TiApplication: android.os.Handler.dispatchMessage(Handler.java:92) [ERROR] : TiApplication: android.os.Looper.loop(Looper.java:137) [ERROR] : TiApplication: android.app.ActivityThread.main(ActivityThread.java:4921) [ERROR] : TiApplication: java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: java.lang.reflect.Method.invoke(Method.java:511) [ERROR] : TiApplication: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) [ERROR] : TiApplication: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) [ERROR] : TiApplication: dalvik.system.NativeStart.main(Native Method) {code} I have tried removing the "className" property from the TableViewRow, which stops the crashing, but prevents Buttons and other Views inside the TableViewRow redrawing correctly, so must be left in (as indicated by the Appcelerator Platform Docs). Due to our customers using JellyBean devices, we need the fix in 3.5.1 or 3.5.2, as the devices can't be upgraded to newer Android versions. *Possible Cause:* This may be caused by an issue with 0-Based indexes used in getItemViewType() or getViewTypeCount() in titanium_mobile/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/TiListView.java
Story points: 8