{ "id": "62408", "key": "TIMOB-1776", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-08-20T16:19:25.000+0000", "created": "2011-04-15T03:01:58.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "concurrentmodificationexception", "context", "crash", "exception", "hashmap", "synchronization", "threading" ], "versions": [], "issuelinks": [ { "id": "20047", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "94532", "key": "TIMOB-9901", "fields": { "summary": "TiAPI: Review and clean up platform bugs and reduce bug count by 20%.", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-09T23:35:07.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

In StatusNet Mobile we've been working with a lot of event\nlisteners, including Ti.App listeners for communication between our\nprimary context, another context to run XML parsing in the\nbackground, and a WebView used for various data display.

\n

Sometimes we end up with cases where things quite reliably crash\nthe VM dumping a raw C-level stacktrace that can be worked around\ntemporarily by shuffling when/where we do an addEventListener, but\nI'm also seeing more intermittent bugs where I get a Java-level\nbacktrace like this:

\n
\nW/dalvikvm( 1759): threadid=1: thread exiting with uncaught exception (group=0x4001d7f0)\nE/TiUncaughtHandler( 1759): (main) [43,123166] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException\nE/TiUncaughtHandler( 1759): java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException\nE/TiUncaughtHandler( 1759):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3655)\nE/TiUncaughtHandler( 1759):     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3673)\nE/TiUncaughtHandler( 1759):     at android.app.ActivityThread.access$2900(ActivityThread.java:125)\nE/TiUncaughtHandler( 1759):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)\nE/TiUncaughtHandler( 1759):     at android.os.Handler.dispatchMessage(Handler.java:99)\nE/TiUncaughtHandler( 1759):     at android.os.Looper.loop(Looper.java:123)\nE/TiUncaughtHandler( 1759):     at android.app.ActivityThread.main(ActivityThread.java:4627)\nE/TiUncaughtHandler( 1759):     at java.lang.reflect.Method.invokeNative(Native Method)\nE/TiUncaughtHandler( 1759):     at java.lang.reflect.Method.invoke(Method.java:521)\nE/TiUncaughtHandler( 1759):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)\nE/TiUncaughtHandler( 1759):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)\nE/TiUncaughtHandler( 1759):     at dalvik.system.NativeStart.main(Native Method)\nE/TiUncaughtHandler( 1759): Caused by: java.util.ConcurrentModificationException\nE/TiUncaughtHandler( 1759):     at java.util.HashMap$HashIterator.nextEntry(HashMap.java:795)\nE/TiUncaughtHandler( 1759):     at java.util.HashMap$KeyIterator.next(HashMap.java:822)\nE/TiUncaughtHandler( 1759):     at org.appcelerator.titanium.TiContext.removeEventListenersFromContext(TiContext.java:468)\nE/TiUncaughtHandler( 1759):     at org.appcelerator.titanium.TiProxy.removeEventListenersFromContext(TiProxy.java:242)\nE/TiUncaughtHandler( 1759):     at org.appcelerator.titanium.TiApplication.removeEventListenersFromContext(TiApplication.java:275)\nE/TiUncaughtHandler( 1759):     at org.appcelerator.titanium.TiContext.release(TiContext.java:879)\nE/TiUncaughtHandler( 1759):     at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:415)\nE/TiUncaughtHandler( 1759):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642)\nE/TiUncaughtHandler( 1759):     ... 11 more\n
\n

It looks like there's a lot of unsynchronized access to the\nevent listener hashmaps in TiContext; there's a few\nsynchronized(eventListeners){...} constructs but they're not\nconsistent, and I'm not too sure what does what.

{html}", "attachment": [], "flagged": false, "summary": "Intermittent ConcurrentModificationException on Android", "creator": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "126632", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I don't have a minimal test case yet, but I was able to decrease\nincidence by switching order of some operations so that a window is\nclosed after, instead of before, starting some background\noperations for account switching.

\n

Looks like the cleanup of listeners when closing out the\nwindow's activity was conflicting with something else that was\ngetting run...

{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:59.000+0000", "updated": "2011-04-15T03:01:59.000+0000" }, { "id": "215238", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "No test case, ticket marked as invalid.", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-08-20T16:19:25.000+0000", "updated": "2012-08-20T16:19:25.000+0000" }, { "id": "215265", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Please reopen this ticket if you can provide a test case or better description to reproduce this issue.", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-20T19:29:58.000+0000", "updated": "2012-08-20T19:29:58.000+0000" }, { "id": "411060", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-09T23:35:07.000+0000", "updated": "2017-03-09T23:35:07.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }