Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-1776

Intermittent ConcurrentModificationException on Android

    Details

      Description

      {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}

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ngupta Neeraj Gupta
                Reporter:
                brionvibber Brion Vibber
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-1593
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration