java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException

Appcelerator JIRA | Brion Vibber | 6 years ago
  1. 0

    {html}<div><p>In StatusNet Mobile we've been working with a lot of event listeners, including Ti.App listeners for communication between our primary context, another context to run XML parsing in the background, and a WebView used for various data display.</p> <p>Sometimes we end up with cases where things quite reliably crash the VM dumping a raw C-level stacktrace that can be worked around temporarily by shuffling when/where we do an addEventListener, but I'm also seeing more intermittent bugs where I get a Java-level backtrace like this:</p> <pre> <code>W/dalvikvm( 1759): threadid=1: thread exiting with uncaught exception (group=0x4001d7f0) E/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 E/TiUncaughtHandler( 1759): java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException E/TiUncaughtHandler( 1759): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3655) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3673) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.access$2900(ActivityThread.java:125) E/TiUncaughtHandler( 1759): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) E/TiUncaughtHandler( 1759): at android.os.Handler.dispatchMessage(Handler.java:99) E/TiUncaughtHandler( 1759): at android.os.Looper.loop(Looper.java:123) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.main(ActivityThread.java:4627) E/TiUncaughtHandler( 1759): at java.lang.reflect.Method.invokeNative(Native Method) E/TiUncaughtHandler( 1759): at java.lang.reflect.Method.invoke(Method.java:521) E/TiUncaughtHandler( 1759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) E/TiUncaughtHandler( 1759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) E/TiUncaughtHandler( 1759): at dalvik.system.NativeStart.main(Native Method) E/TiUncaughtHandler( 1759): Caused by: java.util.ConcurrentModificationException E/TiUncaughtHandler( 1759): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:795) E/TiUncaughtHandler( 1759): at java.util.HashMap$KeyIterator.next(HashMap.java:822) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiContext.removeEventListenersFromContext(TiContext.java:468) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiProxy.removeEventListenersFromContext(TiProxy.java:242) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiApplication.removeEventListenersFromContext(TiApplication.java:275) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiContext.release(TiContext.java:879) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:415) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642) E/TiUncaughtHandler( 1759): ... 11 more</code> </pre> <p>It looks like there's a lot of unsynchronized access to the event listener hashmaps in TiContext; there's a few synchronized(eventListeners){...} constructs but they're not consistent, and I'm not too sure what does what.</p></div>{html}

    Appcelerator JIRA | 6 years ago | Brion Vibber
    java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException
  2. 0

    {html}<div><p>In StatusNet Mobile we've been working with a lot of event listeners, including Ti.App listeners for communication between our primary context, another context to run XML parsing in the background, and a WebView used for various data display.</p> <p>Sometimes we end up with cases where things quite reliably crash the VM dumping a raw C-level stacktrace that can be worked around temporarily by shuffling when/where we do an addEventListener, but I'm also seeing more intermittent bugs where I get a Java-level backtrace like this:</p> <pre> <code>W/dalvikvm( 1759): threadid=1: thread exiting with uncaught exception (group=0x4001d7f0) E/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 E/TiUncaughtHandler( 1759): java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException E/TiUncaughtHandler( 1759): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3655) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3673) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.access$2900(ActivityThread.java:125) E/TiUncaughtHandler( 1759): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) E/TiUncaughtHandler( 1759): at android.os.Handler.dispatchMessage(Handler.java:99) E/TiUncaughtHandler( 1759): at android.os.Looper.loop(Looper.java:123) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.main(ActivityThread.java:4627) E/TiUncaughtHandler( 1759): at java.lang.reflect.Method.invokeNative(Native Method) E/TiUncaughtHandler( 1759): at java.lang.reflect.Method.invoke(Method.java:521) E/TiUncaughtHandler( 1759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) E/TiUncaughtHandler( 1759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) E/TiUncaughtHandler( 1759): at dalvik.system.NativeStart.main(Native Method) E/TiUncaughtHandler( 1759): Caused by: java.util.ConcurrentModificationException E/TiUncaughtHandler( 1759): at java.util.HashMap$HashIterator.nextEntry(HashMap.java:795) E/TiUncaughtHandler( 1759): at java.util.HashMap$KeyIterator.next(HashMap.java:822) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiContext.removeEventListenersFromContext(TiContext.java:468) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiProxy.removeEventListenersFromContext(TiProxy.java:242) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiApplication.removeEventListenersFromContext(TiApplication.java:275) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiContext.release(TiContext.java:879) E/TiUncaughtHandler( 1759): at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:415) E/TiUncaughtHandler( 1759): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642) E/TiUncaughtHandler( 1759): ... 11 more</code> </pre> <p>It looks like there's a lot of unsynchronized access to the event listener hashmaps in TiContext; there's a few synchronized(eventListeners){...} constructs but they're not consistent, and I'm not too sure what does what.</p></div>{html}

    Appcelerator JIRA | 6 years ago | Brion Vibber
    java.lang.RuntimeException: Unable to destroy activity {net.status.client.mobile/org.appcelerator.titanium.TiActivity}: java.util.ConcurrentModificationException
  3. 0

    Crash in map

    GitHub | 5 years ago | Bananeweizen
    java.util.ConcurrentModificationException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  1. iridic 2 times, last 3 weeks ago
  2. franky li 1 times, last 1 month ago
  3. bpbhat77 2 times, last 3 months ago
  4. bpbhat77 1 times, last 5 months ago
  5. asvid 2 times, last 6 months ago
1 more registered users
9 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.util.ConcurrentModificationException

    No message provided

    at java.util.HashMap$HashIterator.nextEntry()
  2. Java RT
    HashMap$KeyIterator.next
    1. java.util.HashMap$HashIterator.nextEntry(HashMap.java:795)
    2. java.util.HashMap$KeyIterator.next(HashMap.java:822)
    2 frames
  3. org.appcelerator.titanium
    TiActivity.onDestroy
    1. org.appcelerator.titanium.TiContext.removeEventListenersFromContext(TiContext.java:468)
    2. org.appcelerator.titanium.TiProxy.removeEventListenersFromContext(TiProxy.java:242)
    3. org.appcelerator.titanium.TiApplication.removeEventListenersFromContext(TiApplication.java:275)
    4. org.appcelerator.titanium.TiContext.release(TiContext.java:879)
    5. org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:415)
    5 frames
  4. Android Platform
    ActivityThread.performDestroyActivity
    1. android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642)
    1 frame