Description
The following code will make the app crash after scrolling all the way to the bottom and back up. Sometimes it crashes earlier. Another thing that happens is a JS error pops up as shown in this image:
http://f.cl.ly/items/3e3i103A0W0y3S3Z3S1B/image001.png
All this happened after the fix for bug TIMOB-13055
var win = Ti.UI.createWindow({
backgroundColor: '#ffffff'
});
var tableData = [];
var x = 0;
for(var i = 0; i < 10; i++) {
// Create 10 sections
var section = Ti.UI.createTableViewSection({
font: {
fontSize: '14dp'
},
headerTitle: 'Pretty Section #' + (i+1),
color: 'white'
});
// Create 10 rows and add them to the section
for(var o = 0; o < 10; o++) {
var avatar = Ti.UI.createImageView({
image: 'KS_nav_ui.png',
width: '64dp',
height: '64dp',
left: '0dp',
top: '0dp'
});
x++;
var title = Ti.UI.createLabel({
left: '70dp',
top: '5dp',
height: Ti.UI.SIZE,
font: {
fontSize: '18dp'
},
color: 'black',
text: 'Row number is ' + (o+1)
});
var subtitle = Ti.UI.createLabel({
left: '70dp',
top: '30dp',
height: Ti.UI.SIZE,
font: {
fontSize: '14dp'
},
color: 'black',
text: 'Section is ' + (i+1)
});
var row = Ti.UI.createTableViewRow({
height: '64dp',
className: 'choppy_tableview'
});
row.add(avatar);
row.add(title);
row.add(subtitle);
section.add(row);
}
tableData.push(section);
}
// Create the table view
var table = Ti.UI.createTableView({
data: tableData
});
table.addEventListener('click', function(){
});
table.addEventListener('scroll', function(){
});
win.add(table);
win.open();
Stack trace:
04-04 14:09:03.784: E/TiApplication(10959): (main) [11968,11968] Sending event: exception on thread: main msg:java.util.ConcurrentModificationException; Titanium 3.1.0,2013/04/02 15:41,1b76dea
04-04 14:09:03.784: E/TiApplication(10959): java.util.ConcurrentModificationException
04-04 14:09:03.784: E/TiApplication(10959): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
04-04 14:09:03.784: E/TiApplication(10959): at java.util.HashMap$EntryIterator.next(HashMap.java:833)
04-04 14:09:03.784: E/TiApplication(10959): at java.util.HashMap$EntryIterator.next(HashMap.java:831)
04-04 14:09:03.784: E/TiApplication(10959): at java.util.HashMap.constructorPutAll(HashMap.java:209)
04-04 14:09:03.784: E/TiApplication(10959): at java.util.HashMap.<init>(HashMap.java:200)
04-04 14:09:03.784: E/TiApplication(10959): at org.appcelerator.kroll.KrollDict.<init>(KrollDict.java:79)
04-04 14:09:03.784: E/TiApplication(10959): at ti.modules.titanium.ui.TableViewProxy.fireEvent(TableViewProxy.java:156)
04-04 14:09:03.784: E/TiApplication(10959): at org.appcelerator.titanium.proxy.TiViewProxy.fireEvent(TiViewProxy.java:818)
04-04 14:09:03.784: E/TiApplication(10959): at ti.modules.titanium.ui.widget.tableview.TiTableView$1.onScrollStateChanged(TiTableView.java:306)
04-04 14:09:03.784: E/TiApplication(10959): at android.widget.AbsListView.reportScrollStateChange(AbsListView.java:3253)
04-04 14:09:03.784: E/TiApplication(10959): at android.widget.AbsListView$TwFlingRunnable.endFling(AbsListView.java:3323)
04-04 14:09:03.784: E/TiApplication(10959): at android.widget.AbsListView$TwFlingRunnable.run(AbsListView.java:3392)
04-04 14:09:03.784: E/TiApplication(10959): at android.os.Handler.handleCallback(Handler.java:587)
04-04 14:09:03.784: E/TiApplication(10959): at android.os.Handler.dispatchMessage(Handler.java:92)
04-04 14:09:03.784: E/TiApplication(10959): at android.os.Looper.loop(Looper.java:130)
04-04 14:09:03.784: E/TiApplication(10959): at android.app.ActivityThread.main(ActivityThread.java:3691)
04-04 14:09:03.784: E/TiApplication(10959): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 14:09:03.784: E/TiApplication(10959): at java.lang.reflect.Method.invoke(Method.java:507)
04-04 14:09:03.784: E/TiApplication(10959): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
04-04 14:09:03.784: E/TiApplication(10959): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
04-04 14:09:03.784: E/TiApplication(10959): at dalvik.system.NativeStart.main(Native Method)
04-04 14:09:03.854: E/(134): Dumpstate > /data/log/dumpstate_app_error
04-04 14:09:03.854: E/AndroidRuntime(10959): FATAL EXCEPTION: main
04-04 14:09:03.854: E/AndroidRuntime(10959): java.util.ConcurrentModificationException
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.util.HashMap$EntryIterator.next(HashMap.java:833)
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.util.HashMap$EntryIterator.next(HashMap.java:831)
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.util.HashMap.constructorPutAll(HashMap.java:209)
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.util.HashMap.<init>(HashMap.java:200)
04-04 14:09:03.854: E/AndroidRuntime(10959): at org.appcelerator.kroll.KrollDict.<init>(KrollDict.java:79)
04-04 14:09:03.854: E/AndroidRuntime(10959): at ti.modules.titanium.ui.TableViewProxy.fireEvent(TableViewProxy.java:156)
04-04 14:09:03.854: E/AndroidRuntime(10959): at org.appcelerator.titanium.proxy.TiViewProxy.fireEvent(TiViewProxy.java:818)
04-04 14:09:03.854: E/AndroidRuntime(10959): at ti.modules.titanium.ui.widget.tableview.TiTableView$1.onScrollStateChanged(TiTableView.java:306)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.widget.AbsListView.reportScrollStateChange(AbsListView.java:3253)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.widget.AbsListView$TwFlingRunnable.endFling(AbsListView.java:3323)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.widget.AbsListView$TwFlingRunnable.run(AbsListView.java:3392)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.os.Handler.handleCallback(Handler.java:587)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.os.Handler.dispatchMessage(Handler.java:92)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.os.Looper.loop(Looper.java:130)
04-04 14:09:03.854: E/AndroidRuntime(10959): at android.app.ActivityThread.main(ActivityThread.java:3691)
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 14:09:03.854: E/AndroidRuntime(10959): at java.lang.reflect.Method.invoke(Method.java:507)
04-04 14:09:03.854: E/AndroidRuntime(10959): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
04-04 14:09:03.854: E/AndroidRuntime(10959): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
04-04 14:09:03.854: E/AndroidRuntime(10959): at dalvik.system.NativeStart.main(Native Method)
Another one from the same issue
The NPE reported above should be fixed by [PR#4078](https://github.com/appcelerator/titanium_mobile/pull/4078) and [3_1_X PR#4079](https://github.com/appcelerator/titanium_mobile/pull/4079). Ran the test case using the latest master and 3_1_X branch on Nexus 7 (4.1), Galaxy Nexus (4.0.4) and HTC Sensation 4G (2.3.4). Cannot reproduce the crash.
This is not resolved. I tested with the build from 3.1.0.v20130404173046 and my app is crashing. You have to scroll to the bottom of the list and scroll fast and then scroll back up a few times. It will happen. 3.1 will be unusable if this is not fixed. The PR above fixes the ti:/events.js error but not the scrolling error.
Hi Darren, I just used the build 3.1.0.v20130404173046 to test the test case attached in the ticket and it works fine without any crash. Can you post your test app, the crash log and on what device you tested? Thanks.
Samsung-SGH-I927 Android 2.3.5 var win = Ti.UI.createWindow({ backgroundColor: '#ffffff' }); var tableData = []; var x = 0; for(var i = 0; i < 10; i++) { // Create 10 sections var section = Ti.UI.createTableViewSection({ font: { fontSize: '14dp' }, headerTitle: 'Pretty Section #' + (i+1), color: 'white' }); // Create 10 rows and add them to the section for(var o = 0; o < 10; o++) { x++; var title = Ti.UI.createLabel({ left: '70dp', top: '5dp', height: Ti.UI.SIZE, font: { fontSize: '18dp' }, color: 'black', text: 'Row number is ' + (o+1) }); var subtitle = Ti.UI.createLabel({ left: '70dp', top: '30dp', height: Ti.UI.SIZE, font: { fontSize: '14dp' }, color: 'black', text: 'Section is ' + (i+1) }); var row = Ti.UI.createTableViewRow({ height: '64dp', className: 'choppy_tableview' }); row.add(title); row.add(subtitle); section.add(row); } tableData.push(section); } // Create the table view var table = Ti.UI.createTableView({ data: tableData }); table.addEventListener('click', function(){ }); win.add(table); win.open(); 04-05 14:41:56.594: W/dalvikvm(21111): threadid=1: thread exiting with uncaught exception (group=0x40192578) 04-05 14:41:56.594: E/TiApplication(21111): (main) [5739,5739] Sending event: exception on thread: main msg:java.util.ConcurrentModificationException; Titanium 3.1.0,2013/04/04 17:31,d30814c 04-05 14:41:56.594: E/TiApplication(21111): java.util.ConcurrentModificationException 04-05 14:41:56.594: E/TiApplication(21111): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796) 04-05 14:41:56.594: E/TiApplication(21111): at java.util.HashMap$EntryIterator.next(HashMap.java:833) 04-05 14:41:56.594: E/TiApplication(21111): at java.util.HashMap$EntryIterator.next(HashMap.java:831) 04-05 14:41:56.594: E/TiApplication(21111): at java.util.HashMap.constructorPutAll(HashMap.java:209) 04-05 14:41:56.594: E/TiApplication(21111): at java.util.HashMap.
I was able to reproduce this by scrolling up and down fast. This started happening after this commit I think https://github.com/appcelerator/titanium_mobile/commit/830727f5d65bf596e811fbbaaf1198c2517d35cf
You can see that this line below is getting called multiple times and the HashMap is not locked or thread safe which appears to cause the exception 04-05 14:41:56.594: E/TiApplication(21111): at ti.modules.titanium.ui.widget.tableview.TiTableView$1.onScrollStateChanged(TiTableView.java:306)
The crash can be easily reproduced on Nexus 7 (4.1). PR: https://github.com/appcelerator/titanium_mobile/pull/4110 3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4111
Environment used for verification - Titanium SDK: 3.1.0.v20130405170202 Titanium Studio:3.1.0.201304011603 Device: Samsung GALAXY Note (2.3.6) and Nexus 7 Android 4.1
This still has not been resolved. I was able to reproduce this error with 3.1.0.v20130405170202 Device Samsung SGH (2.3.5). As you can see from the stack trace below the build is from Friday. 04-07 23:29:04.710: E/TiApplication(1797): (main) [17296,47643] Sending event: exception on thread: main msg:java.util.ConcurrentModificationException; Titanium 3.1.0,2013/04/05 17:02,93d78f5 04-07 23:29:04.710: E/TiApplication(1797): java.util.ConcurrentModificationException 04-07 23:29:04.710: E/TiApplication(1797): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796) 04-07 23:29:04.710: E/TiApplication(1797): at java.util.HashMap$EntryIterator.next(HashMap.java:833) 04-07 23:29:04.710: E/TiApplication(1797): at java.util.HashMap$EntryIterator.next(HashMap.java:831) 04-07 23:29:04.710: E/TiApplication(1797): at java.util.HashMap.constructorPutAll(HashMap.java:209) 04-07 23:29:04.710: E/TiApplication(1797): at java.util.HashMap.
You need to scroll up and down to reproduce this error. You might have to a scroll a bunch I can reproduce it every time.
Still could not reproduce with following env. and devices(scrolled up and down around a dozen times) SDK: 3.1.0.v20130405170202 Studio:3.1.0.201304011603 CLI ver - 3.1.0 Device: Samsung GALAXY Note (2.3.6),Nexus 7 Android 4.1,Samsung Galaxy Nexus Android 4.0.2 and HTC Desire V Android 4.0.3. @Darren - If you could please specify the device on which you are able to reproduce the bug.
Shyam I am using Samsung-SGH-I927 (2.3.5) AT&T. Every app I have crashes on the table view now. Makes 3.1 unusable if this is not fixed. 04-08 08:57:20.110: E/TiApplication(7877): (main) [38305,118770] Sending event: exception on thread: main msg:java.util.ConcurrentModificationException; Titanium 3.1.0,2013/04/05 17:02,93d78f5 04-08 08:57:20.110: E/TiApplication(7877): java.util.ConcurrentModificationException 04-08 08:57:20.110: E/TiApplication(7877): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796) 04-08 08:57:20.110: E/TiApplication(7877): at java.util.HashMap$EntryIterator.next(HashMap.java:833) 04-08 08:57:20.110: E/TiApplication(7877): at java.util.HashMap$EntryIterator.next(HashMap.java:831) 04-08 08:57:20.110: E/TiApplication(7877): at java.util.HashMap.constructorPutAll(HashMap.java:209) 04-08 08:57:20.110: E/TiApplication(7877): at java.util.HashMap.
The latest kitchen sink from github crashes after just a few scrolls in the first list
[~vduggal] Believes he knows what is going on.
https://github.com/appcelerator/titanium_mobile/pull/4122 https://github.com/appcelerator/titanium_mobile/pull/4123
Vishal how is your change different than before?
We can not reproduce the error you are seeing. I am basically working off the theory that the first event gets the message onto the runtime thread, the runtime thread is paused for the UI thread where we are trying to fire the second event and it is trying to create a new dictionary for the second event and hence the ConcurrentModificationException. My PR basically creates a copy of the dictionary before firing off the event so the above scenario will not occur.
Why are there 2 scroll end events being fired?
scrollend and scrollEnd(deprecated but still supported)
ok I will test as soon as it makes it to the continuous builds
Merged the PR, and resolving for now. Please test this and reopen if you are still seeing the error.
Appears to have been fixed! Thanks!
App is running fine as TableView doesn't crashes. Verified on: SDK: 3.1.0.v20130408154547 CLI version : 3.1.0-cr OS : MAC OSX 10.7.5 Appcelerator Studio, build: 3.1.0.201304052347 XCode : 4.5.1