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

Android: When dynamically adding route points to a map over time causes app to crash

    Details

      Description

      I am tracking a user running and updating a map with a route. After a certain amount of points are added to the route I get the below error:

      W/dalvikvm(12413): threadid=1: thread exiting with uncaught exception (group=0x4001d560)
      E/TiApplication(12413): (main) [169428,177873] Sending event: exception on thread: main msg:java.util.ConcurrentModificationException; Titanium 2.1.0,2012/06/28 12:16,6e3cab6
      E/TiApplication(12413): java.util.ConcurrentModificationException
      E/TiApplication(12413): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:576)
      E/TiApplication(12413): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:41)
      E/TiApplication(12413): at com.google.android.maps.MapView.onDraw(MapView.java:530)
      E/TiApplication(12413): at android.view.View.draw(View.java:6902)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:655)
      E/TiApplication(12413): at android.view.View.draw(View.java:6905)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:655)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.View.draw(View.java:6905)
      E/TiApplication(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/TiApplication(12413): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1957)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.View.draw(View.java:6905)
      E/TiApplication(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:655)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.View.draw(View.java:6905)
      E/TiApplication(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/TiApplication(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/TiApplication(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/TiApplication(12413): at android.view.View.draw(View.java:6905)
      E/TiApplication(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/TiApplication(12413): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1957)
      E/TiApplication(12413): at android.view.ViewRoot.draw(ViewRoot.java:1554)
      E/TiApplication(12413): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
      E/TiApplication(12413): at android.view.ViewRoot.handleMessage(ViewRoot.java:1892)
      E/TiApplication(12413): at android.os.Handler.dispatchMessage(Handler.java:99)
      E/TiApplication(12413): at android.os.Looper.loop(Looper.java:130)
      E/TiApplication(12413): at android.app.ActivityThread.main(ActivityThread.java:3835)
      E/TiApplication(12413): at java.lang.reflect.Method.invokeNative(Native Method)
      E/TiApplication(12413): at java.lang.reflect.Method.invoke(Method.java:507)
      E/TiApplication(12413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
      E/TiApplication(12413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
      E/TiApplication(12413): at dalvik.system.NativeStart.main(Native Method)
      E/AndroidRuntime(12413): FATAL EXCEPTION: main
      E/AndroidRuntime(12413): java.util.ConcurrentModificationException
      E/AndroidRuntime(12413): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:576)
      E/AndroidRuntime(12413): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:41)
      E/AndroidRuntime(12413): at com.google.android.maps.MapView.onDraw(MapView.java:530)
      E/AndroidRuntime(12413): at android.view.View.draw(View.java:6902)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:655)
      E/AndroidRuntime(12413): at android.view.View.draw(View.java:6905)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:655)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.View.draw(View.java:6905)
      E/AndroidRuntime(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/AndroidRuntime(12413): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1957)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.View.draw(View.java:6905)
      E/AndroidRuntime(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:655)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.View.draw(View.java:6905)
      E/AndroidRuntime(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/AndroidRuntime(12413): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
      E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      E/AndroidRuntime(12413): at android.view.View.draw(View.java:6905)
      E/AndroidRuntime(12413): at android.widget.FrameLayout.draw(FrameLayout.java:357)
      E/AndroidRuntime(12413): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1957)
      E/AndroidRuntime(12413): at android.view.ViewRoot.draw(ViewRoot.java:1554)
      E/AndroidRuntime(12413): at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
      E/AndroidRuntime(12413): at android.view.ViewRoot.handleMessage(ViewRoot.java:1892)
      E/AndroidRuntime(12413): at android.os.Handler.dispatchMessage(Handler.java:99)
      E/AndroidRuntime(12413): at android.os.Looper.loop(Looper.java:130)
      E/AndroidRuntime(12413): at android.app.ActivityThread.main(ActivityThread.java:3835)
      E/AndroidRuntime(12413): at java.lang.reflect.Method.invokeNative(Native Method)
      E/AndroidRuntime(12413): at java.lang.reflect.Method.invoke(Method.java:507)
      E/AndroidRuntime(12413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
      E/AndroidRuntime(12413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
      E/AndroidRuntime(12413): at dalvik.system.NativeStart.main(Native Method)
      W/ActivityManager( 1646): Force finishing activity com.libertastechnologies.stelizabeth/ti.modules.titanium.ui.TiTabActivity
      

      1. Run this code, interact with screen, and you should be able to see this in ~5 seconds.

      var win = Ti.UI.createWindow({
      	backgroundColor : '#00f'
      });
       
      var maproute = {
      	name : 'runtrackerroute',
      	points : [{
      		latitude : 42.3353,
      		longitude : -71.1715
      	}, {
      		latitude : 42.3355,
      		longitude : -71.1725
      	}, {
      		latitude : 42.3359,
      		longitude : -71.1735
      	}],
      	color : 'blue',
      	width : 4
      };
       
      var map = Titanium.Map.createView({
      	mapType : Titanium.Map.STANDARD_TYPE,
      	region : {
      		latitude : 42.3366,
      		longitude : -71.1689,
      		latitudeDelta : 0.01,
      		longitudeDelta : 0.01
      	}
      });
      map.addRoute(maproute);
       
      function UpdateMapRoute(lat, lon)
      {
      	//remove route
      	map.removeRoute(maproute);
       
      	//add new points
      	maproute.points.push({
      		'latitude' : lat,
      		'longitude' : lon
      	});
       
      	//add route
      	map.addRoute(maproute);
      	
      	map.setLocation({
      		latitude : lat,
      		longitude : lon,
      		animate : true,
      		latitudeDelta : 0.001,
      		longitudeDelta : 0.004
      	});
       
      }
       
      var lat = 42.3359;
      var lon = -71.1735;
       
      setInterval(function(){
      	UpdateMapRoute(lat,lon);
      	lat = lat + .002;
      	lon = lon + .002;
      },500);
       
       
       
      win.add(map);
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              hpham Hieu Pham
              Reporter:
              aroyce Andrew Royce
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration