Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10171] Android: When dynamically adding route points to a map over time causes app to crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-10-30T00:22:21.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sRelease 3.0.0, Sprint 2012-18 API, 2012 Sprint 18, 2012 Sprint 22 API, 2012 Sprint 22
ComponentsAndroid
Labelsapi, community, module_map, qe-and100112, qe-review, qe-testadded
ReporterAndrew Royce
AssigneeHieu Pham
Created2012-07-26T13:29:36.000+0000
Updated2012-11-12T18:46:45.000+0000

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

FileDateSize
device-2012-10-05-140900.png2012-10-05T21:25:58.000+000022777

Comments

  1. Andrew Royce 2012-07-26

    Tried to add this under Ti-MOB but dont have that as an option when I select 'Create Issue' button.
  2. Alexander Bauer 2012-08-15

    I also experience heavy performance issues when adding a real route (consists of 100+ points), this affects android only.
  3. Andrew Royce 2012-08-27

    Any update on this? I'm stuck until this gets fixed. Is there anything else I can do to help speed up this development?
  4. Hieu Pham 2012-08-28

    This issue is being addressed. As for performance, how are you adding routes? If you could provide a sample code (preferably in a new JIRA ticket), we'll be more than happy to dig into it.
  5. Allen Yeung 2012-08-30

    PR: https://github.com/appcelerator/titanium_mobile/pull/2849
  6. Satyam Sekhri 2012-08-31

    The app does not crash. Verified on: Titanium Studio: 2.1.2.201208301612 Titanium SDK: 2.2.0.v20120830182512 Android Device: LG-P970 (v2.2), Galaxy Note (v2.3), Galaxy Nexus (v4.0.2) Android Runtime: v8, Rhino
  7. Shyam Bhadauria 2012-09-06

    Re-opening to edit label
  8. Tamila Smolich 2012-10-05

    Reopening the bug, because the app still crashes. Need to wait approximately 40-60 sec to see mapView turns black (screenshot is attached) and then rotate device to landscape mode. Tested on: OS: Mac OS X Lion 10.7.4 Titanium Studio, build: 2.1.2.201208301612 Titanium SDK, build: 3.0.0.v20121005130642 Device: Samsung Galaxy III (4.0.4), Nexus 7 (4.1.1)
  9. Hieu Pham 2012-10-30

JSON Source