Hi everybody, I have a TableView on the index / main screen of my app. It's populated with 10 rows when app is opened. In case user changes the option of a Picker the content of the TableView is refreshed (current rows are removed, new rows are added). The amount of rows in the TableView doesn't exceed 20.
For iOS everythings works well. For Android the app crashes (message: App has stopped) when the app is opened and user presses the androidback button or when app is running and user changes the selection of the Picker and presses immediately afterwards the androidback button. Sometimes it's enough to hit the androidback button only once, but most often at least a double click is needed to let the app crash.
I tested the behaviour for a while. It seems that it only happens when the androidback button is pressed while the TableView is populated or its content is changed. I also tested with a default ScrollView instead of a TableView and added the TableViewRows as normal Views to the ScrollView. But the app still crashes for the scenarios described above. Maybe it's a more general problem?
I debugged the TableView and ScrollView solution with adb logcat and found the following stack traces:
TableView:
D/AndroidRuntime( 9419): Shutting down VM W/dalvikvm( 9419): threadid=1: thread exiting with uncaught exception (group=0x41751c08) D/InputDispatcher( 575): Waiting for application to become ready for input: xxxx Reason: Waiting because the focused window has not finished processing the input events that were previously delivered to it. I/InputDispatcher( 575): Delivering key to: action: 0x1 (0) D/Launcher.Workspace( 897): exitWidgetResizeMode State: NORMAL, newDragStarted: false E/AndroidRuntime( 9419): FATAL EXCEPTION: main E/AndroidRuntime( 9419): Process: --.----------, PID: 9419 E/AndroidRuntime( 9419): java.lang.NullPointerException E/AndroidRuntime( 9419): at android.view.ViewConfiguration.get(ViewConfiguration.java:333) E/AndroidRuntime( 9419): at android.view.View.<init>(View.java:3571) E/AndroidRuntime( 9419): at android.view.ViewGroup.<init>(ViewGroup.java:469) E/AndroidRuntime( 9419): at android.widget.FrameLayout.<init>(FrameLayout.java:93) E/AndroidRuntime( 9419): at ti.modules.titanium.ui.widget.tableview.TiTableView.<init>(TiTableView.java:277) E/AndroidRuntime( 9419): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:111) E/AndroidRuntime( 9419): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1209) E/AndroidRuntime( 9419): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:502) E/AndroidRuntime( 9419): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:493) E/AndroidRuntime( 9419): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:471) E/AndroidRuntime( 9419): at ti.modules.titanium.ui.TableViewProxy.getTableView(TableViewProxy.java:150) E/AndroidRuntime( 9419): at ti.modules.titanium.ui.TableViewProxy.handleSetData(TableViewProxy.java:695) E/AndroidRuntime( 9419): at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:872) E/AndroidRuntime( 9419): at android.os.Handler.dispatchMessage(Handler.java:98) E/AndroidRuntime( 9419): at android.os.Looper.loop(Looper.java:146) E/AndroidRuntime( 9419): at android.app.ActivityThread.main(ActivityThread.java:5602) E/AndroidRuntime( 9419): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 9419): at java.lang.reflect.Method.invoke(Method.java:515) E/AndroidRuntime( 9419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) E/AndroidRuntime( 9419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) E/AndroidRuntime( 9419): at dalvik.system.NativeStart.main(Native Method)ScrollView:
D/AndroidRuntime( 8093): Shutting down VM W/dalvikvm( 8093): threadid=1: thread exiting with uncaught exception (group=0x41751c08) E/AndroidRuntime( 8093): FATAL EXCEPTION: main E/AndroidRuntime( 8093): Process: --.----------, PID: 8093 E/AndroidRuntime( 8093): java.lang.NullPointerException E/AndroidRuntime( 8093): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:318) E/AndroidRuntime( 8093): at android.os.Handler.dispatchMessage(Handler.java:98) E/AndroidRuntime( 8093): at android.os.Looper.loop(Looper.java:146) E/AndroidRuntime( 8093): at android.app.ActivityThread.main(ActivityThread.java:5602) E/AndroidRuntime( 8093): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 8093): at java.lang.reflect.Method.invoke(Method.java:515) E/AndroidRuntime( 8093): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) E/AndroidRuntime( 8093): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) E/AndroidRuntime( 8093): at dalvik.system.NativeStart.main(Native Method) D/KeyguardUpdateMonitor( 733): sendKeyguardVisibilityChanged(true) I/KeyguardUpdateMonitor( 733): visibility is sameA workaround is to e.g. use Underscore::debounce to delay execution of androidback or 'disable' androidback for this window, but this wouldn't be a good user experience.
Thank you very much for your help in advance!
Environment:
- Host OS: OS X Yosemite 10.10.5
- Titanium SDK: 5.0.0GA (version: 5.0.0, git hash: ec79bc5, git timestamp: 09/15/15 23:07)
- Platform: Android 5.1.1 (api level: 22)
- Device: Samsung SM-T230 (Android version: 4.4.2), also happens on my beta testers devices
- Titanium Studio: Appcelerator Studio 4.3.0.201509151348-15092015134844