Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12857] mapsv2 Module: NPE crash while using new map while trying to click on and quickly remove annotations

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-02-26T01:47:57.000+0000
Affected Version/sRelease 3.0.2
Fix Version/sRelease 3.1.0, 2013 Sprint 05 API
Componentsn/a
Labelsqe-mapv2
ReporterEric Merriman
AssigneeHieu Pham
Created2013-02-26T01:10:50.000+0000
Updated2014-06-19T12:43:09.000+0000

Description

While testing maps, and hitting the remove annotations button form the test, I got the following log, and the app stopped working. I attempted the same steps but was unable to reproduce the issue. Hieu looked at the code and figured out what was happening and how to repro the bug.
var win = Ti.UI.createWindow({fullscreen: false});
var anno = MapModule.createAnnotation({latitude: -33.87365, image: 'map_pin.png', longitude: 151.20689, title: "Sydney", subtitle: "Sydney is quite chill", draggable: true});
var anno2 = MapModule.createAnnotation({latitude: -33.86365, pincolor: MapModule.ANNOTATION_BLUE, longitude: 151.21689, title: "Anno2", subtitle: "Blue Draggable", draggable: true});
var anno3 = MapModule.createAnnotation({latitude: -33.85365, longitude: 151.20689, title: "Anno3", subtitle: "Not Draggable", draggable: false});
var anno4 = MapModule.createAnnotation({latitude: -33.86365, longitude: 151.22689, title: "Anno4", subtitle: "Draggable", draggable: true});

Ti.API.info ("====> Latitude should be: -33.87365 and is: " + anno.latitude);
Ti.API.info ("====> Longitude should be: 151.20689 and is: " + anno.longitude);
Ti.API.info ("====> Title should be Sydney and is: " + anno.title);
Ti.API.info ("====> Draggable should be true and is: " + anno.draggable);
Ti.API.info ("====> Draggable should be true and is: " + anno.draggable);

var map = MapModule.createView({
	userLocation: true,
	mapType: MapModule.NORMAL_TYPE,
	animate: true,
	annotations: [anno, anno2, anno4],
	region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 }, //Sydney
	top: '30%'
});
Ti.API.info("====> userLocation: " + map.userLocation);
win.add(map);

var button = Ti.UI.createButton({top: 0, left: 0, title: "Go Mt. View"});
button.addEventListener('click', function(e) {
	map.region = {latitude: 37.3689, longitude: -122.0353, latitudeDelta: 0.1, longitudeDelta: 0.1 }; //Mountain View
});

var button2 = Ti.UI.createButton({top: '10%', title: "add anno3"});
button2.addEventListener('click', function(e) {
	map.addAnnotation(anno3);
});

var button3 = Ti.UI.createButton({top: 0, title: "rm anno3"});
button3.addEventListener('click', function(e) {
	map.removeAnnotation(anno3);
});

var button4 = Ti.UI.createButton({top: '20%', title: "rm all"});
button4.addEventListener('click', function(e) {
	map.removeAllAnnotations();
});

var button5 = Ti.UI.createButton({top: '10%', left: 0, title: "remove annos"});
button5.addEventListener('click', function(e) {
	Ti.API.info(anno.getTitle());
	map.removeAnnotations(["Sydney", anno2]);
});

var button6 = Ti.UI.createButton({top: 0, right: 0, title: "select anno2"});
button6.addEventListener('click', function(e) {
	map.selectAnnotation(anno2);
});

var button7 = Ti.UI.createButton({top: '10%', right: 0, title: "desel anno2"});
button7.addEventListener('click', function(e) {
	map.deselectAnnotation(anno2);
});

var button8 = Ti.UI.createButton({top: '20%', right: 0, title: "modify anno2"});
button8.addEventListener('click', function(e) {
	anno2.title = "Hello";
	anno2.subtitle = "Hi there.";
	anno2.longitude = 151.27689;
});

var button9 = Ti.UI.createButton({top: '20%', left: 0, title: "Add all"});
button9.addEventListener('click', function(e) {
	// this was broken TIMOB-12837
	map.addAnnotations([anno, anno2, anno3, anno4]);
});

win.add(button);
win.add(button2);
win.add(button3);
win.add(button4);
win.add(button5);
win.add(button6);
win.add(button7);
win.add(button8);
win.add(button9);
win.open();
Steps to reproduce: 1) Launch test code 2) click on a pin 3) Quickly click on the map, then click the "Remove all" button to remove all annotations Result: The app stops working and the log shows an NPE Expected: No NPE LOG:
I/TiAPI   ( 2826):  Sydney
D/AndroidRuntime( 2826): Shutting down VM
W/dalvikvm( 2826): threadid=1: thread exiting with uncaught exception (group=0x40b5b930)
E/TiApplication( 2826): (main) [23225,53526] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.0.2,2013/02/15 19:02,5a77fe7
E/TiApplication( 2826): java.lang.NullPointerException
E/TiApplication( 2826): 	at ti.map.AnnotationProxy.hideInfo(AnnotationProxy.java:196)
E/TiApplication( 2826): 	at ti.map.TiUIMapView.onMarkerClick(TiUIMapView.java:372)
E/TiApplication( 2826): 	at com.google.android.gms.maps.GoogleMap$4.f(Unknown Source)
E/TiApplication( 2826): 	at com.google.android.gms.internal.an$a.onTransact(Unknown Source)
E/TiApplication( 2826): 	at android.os.Binder.transact(Binder.java:310)
E/TiApplication( 2826): 	at com.google.android.gms.maps.internal.IOnMarkerClickListener$Stub$Proxy.onMarkerClick(IOnMarkerClickListener.java:84)
E/TiApplication( 2826): 	at maps.y.bw.a(Unknown Source)
E/TiApplication( 2826): 	at maps.a.dh.a(Unknown Source)
E/TiApplication( 2826): 	at maps.a.n.c(Unknown Source)
E/TiApplication( 2826): 	at maps.a.dw.a(Unknown Source)
E/TiApplication( 2826): 	at maps.a.bd.c(Unknown Source)
E/TiApplication( 2826): 	at maps.a.dq.onSingleTapConfirmed(Unknown Source)
E/TiApplication( 2826): 	at maps.e.v.onSingleTapConfirmed(Unknown Source)
E/TiApplication( 2826): 	at maps.e.j.handleMessage(Unknown Source)
E/TiApplication( 2826): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/TiApplication( 2826): 	at android.os.Looper.loop(Looper.java:137)
E/TiApplication( 2826): 	at android.app.ActivityThread.main(ActivityThread.java:5039)
E/TiApplication( 2826): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication( 2826): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/TiApplication( 2826): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/TiApplication( 2826): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/TiApplication( 2826): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2826): FATAL EXCEPTION: main
E/AndroidRuntime( 2826): java.lang.NullPointerException
E/AndroidRuntime( 2826): 	at ti.map.AnnotationProxy.hideInfo(AnnotationProxy.java:196)
E/AndroidRuntime( 2826): 	at ti.map.TiUIMapView.onMarkerClick(TiUIMapView.java:372)
E/AndroidRuntime( 2826): 	at com.google.android.gms.maps.GoogleMap$4.f(Unknown Source)
E/AndroidRuntime( 2826): 	at com.google.android.gms.internal.an$a.onTransact(Unknown Source)
E/AndroidRuntime( 2826): 	at android.os.Binder.transact(Binder.java:310)
E/AndroidRuntime( 2826): 	at com.google.android.gms.maps.internal.IOnMarkerClickListener$Stub$Proxy.onMarkerClick(IOnMarkerClickListener.java:84)
E/AndroidRuntime( 2826): 	at maps.y.bw.a(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.a.dh.a(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.a.n.c(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.a.dw.a(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.a.bd.c(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.a.dq.onSingleTapConfirmed(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.e.v.onSingleTapConfirmed(Unknown Source)
E/AndroidRuntime( 2826): 	at maps.e.j.handleMessage(Unknown Source)
E/AndroidRuntime( 2826): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2826): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2826): 	at android.app.ActivityThread.main(ActivityThread.java:5039)
E/AndroidRuntime( 2826): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2826): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2826): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 2826): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 2826): 	at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  388):   Force finishing activity com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity
W/ActivityManager(  388): Activity pause timeout for ActivityRecord{426a6478 u10 com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity}
I/Process ( 2826): Sending signal. PID: 2826 SIG: 9
I/WindowState(  388): WIN DEATH: Window{41793cd0 u10 com.appcelerator.mapmod/com.appcelerator.mapmod.Mapv2moduletestActivity}
I/ActivityManager(  388): Process com.appcelerator.mapmod (pid 2826) has died.
W/InputDispatcher(  388): channel '41794078 com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher(  388): channel '41794078 com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

Comments

  1. Eric Merriman 2013-02-26

    Hieu also found another similar case in another location.
       I/TiAPI   ( 2994):  Sydney
       D/AndroidRuntime( 2994): Shutting down VM
       W/dalvikvm( 2994): threadid=1: thread exiting with uncaught exception (group=0x40b5b930)
       E/TiApplication( 2994): (main) [636721,2209485] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.0.2,2013/02/15 19:02,5a77fe7
       E/TiApplication( 2994): java.lang.NullPointerException
       E/TiApplication( 2994): 	at ti.map.TiUIMapView.onMapClick(TiUIMapView.java:386)
       E/TiApplication( 2994): 	at com.google.android.gms.maps.GoogleMap$6.onMapClick(Unknown Source)
       E/TiApplication( 2994): 	at com.google.android.gms.internal.o$a.onTransact(Unknown Source)
       E/TiApplication( 2994): 	at android.os.Binder.transact(Binder.java:310)
       E/TiApplication( 2994): 	at com.google.android.gms.maps.internal.IOnMapClickListener$Stub$Proxy.onMapClick(IOnMapClickListener.java:93)
       E/TiApplication( 2994): 	at maps.j.q.b(Unknown Source)
       E/TiApplication( 2994): 	at maps.a.bd.c(Unknown Source)
       E/TiApplication( 2994): 	at maps.a.dq.onSingleTapConfirmed(Unknown Source)
       E/TiApplication( 2994): 	at maps.e.v.onSingleTapConfirmed(Unknown Source)
       E/TiApplication( 2994): 	at maps.e.j.handleMessage(Unknown Source)
       E/TiApplication( 2994): 	at android.os.Handler.dispatchMessage(Handler.java:99)
       E/TiApplication( 2994): 	at android.os.Looper.loop(Looper.java:137)
       E/TiApplication( 2994): 	at android.app.ActivityThread.main(ActivityThread.java:5039)
       E/TiApplication( 2994): 	at java.lang.reflect.Method.invokeNative(Native Method)
       E/TiApplication( 2994): 	at java.lang.reflect.Method.invoke(Method.java:511)
       E/TiApplication( 2994): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
       E/TiApplication( 2994): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
       E/TiApplication( 2994): 	at dalvik.system.NativeStart.main(Native Method)
       E/AndroidRuntime( 2994): FATAL EXCEPTION: main
       E/AndroidRuntime( 2994): java.lang.NullPointerException
       E/AndroidRuntime( 2994): 	at ti.map.TiUIMapView.onMapClick(TiUIMapView.java:386)
       E/AndroidRuntime( 2994): 	at com.google.android.gms.maps.GoogleMap$6.onMapClick(Unknown Source)
       E/AndroidRuntime( 2994): 	at com.google.android.gms.internal.o$a.onTransact(Unknown Source)
       E/AndroidRuntime( 2994): 	at android.os.Binder.transact(Binder.java:310)
       E/AndroidRuntime( 2994): 	at com.google.android.gms.maps.internal.IOnMapClickListener$Stub$Proxy.onMapClick(IOnMapClickListener.java:93)
       E/AndroidRuntime( 2994): 	at maps.j.q.b(Unknown Source)
       E/AndroidRuntime( 2994): 	at maps.a.bd.c(Unknown Source)
       E/AndroidRuntime( 2994): 	at maps.a.dq.onSingleTapConfirmed(Unknown Source)
       E/AndroidRuntime( 2994): 	at maps.e.v.onSingleTapConfirmed(Unknown Source)
       E/AndroidRuntime( 2994): 	at maps.e.j.handleMessage(Unknown Source)
       E/AndroidRuntime( 2994): 	at android.os.Handler.dispatchMessage(Handler.java:99)
       E/AndroidRuntime( 2994): 	at android.os.Looper.loop(Looper.java:137)
       E/AndroidRuntime( 2994): 	at android.app.ActivityThread.main(ActivityThread.java:5039)
       E/AndroidRuntime( 2994): 	at java.lang.reflect.Method.invokeNative(Native Method)
       E/AndroidRuntime( 2994): 	at java.lang.reflect.Method.invoke(Method.java:511)
       E/AndroidRuntime( 2994): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
       E/AndroidRuntime( 2994): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
       E/AndroidRuntime( 2994): 	at dalvik.system.NativeStart.main(Native Method)
       W/ActivityManager(  388):   Force finishing activity com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity
       W/ActivityManager(  388): Activity pause timeout for ActivityRecord{41eb6508 u10 com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity}
       W/ActivityManager(  388): Launch timeout has expired, giving up wake lock!
       W/ActivityManager(  388): Activity idle timeout for ActivityRecord{4176b7a0 u10 com.appcelerator.mapmod/org.appcelerator.titanium.TiActivity}
       
  2. Hieu Pham 2013-02-26

    PR: https://github.com/appcelerator/titanium_modules/pull/86
  3. Hieu Pham 2013-02-26

    This is an edge case, which is reproducible by attempting to click and remove the annotation at the same time. It is easier to select the annotation first, then click anywhere on the map to trigger the click event, while deleting the selected annotation at the same time.
  4. Shyam Bhadauria 2013-02-27

    Unable to reproduce it with 3.0.2.GA on device Samsung GALAXY Note (2.3.6) and Nexus 7 Android 4.1. Titanium  Studio:3.0.2.201302141201
  5. Eric Merriman 2013-03-06

    Verified fixed with 3.0.2.GA and module commit 6bde65405649f2e14045b26e048406182b2cbade
  6. Jorge E. Aparicio 2013-03-15

    Hi, good day, I'm developing an app with Map Module updated but the problem is present. My env development platform is Android 4.0.3, Titanium 3.0.2GA and Map Module is updated at commit 6bde65405649f2e14045b26e048406182b2cbade. {quote} 03-15 10:06:34.060: E/TiApplication(13011): (main) [18509,103048] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.0.2,2013/02/15 19:02,5a77fe7 03-15 10:06:34.060: E/TiApplication(13011): java.lang.NullPointerException 03-15 10:06:34.060: E/TiApplication(13011): at ti.map.TiUIMapView.onMarkerClick(TiUIMapView.java:369) 03-15 10:06:34.060: E/TiApplication(13011): at com.google.android.gms.maps.GoogleMap$4.f(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at com.google.android.gms.internal.an$a.onTransact(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at android.os.Binder.transact(Binder.java:300) 03-15 10:06:34.060: E/TiApplication(13011): at com.google.android.gms.maps.internal.IOnMarkerClickListener$Stub$Proxy.onMarkerClick(IOnMarkerClickListener.java:84) 03-15 10:06:34.060: E/TiApplication(13011): at maps.z.by.a(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.y.ba.a(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.y.d.c(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.y.bj.a(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.y.v.c(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.y.bf.onSingleTapConfirmed(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.d.v.onSingleTapConfirmed(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at maps.d.j.handleMessage(Unknown Source) 03-15 10:06:34.060: E/TiApplication(13011): at android.os.Handler.dispatchMessage(Handler.java:99) 03-15 10:06:34.060: E/TiApplication(13011): at android.os.Looper.loop(Looper.java:137) 03-15 10:06:34.060: E/TiApplication(13011): at android.app.ActivityThread.main(ActivityThread.java:4464) 03-15 10:06:34.060: E/TiApplication(13011): at java.lang.reflect.Method.invokeNative(Native Method) 03-15 10:06:34.060: E/TiApplication(13011): at java.lang.reflect.Method.invoke(Method.java:511) 03-15 10:06:34.060: E/TiApplication(13011): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822) 03-15 10:06:34.060: E/TiApplication(13011): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589) 03-15 10:06:34.060: E/TiApplication(13011): at dalvik.system.NativeStart.main(Native Method) 03-15 10:06:34.200: E/AndroidRuntime(13011): FATAL EXCEPTION: main 03-15 10:06:34.200: E/AndroidRuntime(13011): java.lang.NullPointerException 03-15 10:06:34.200: E/AndroidRuntime(13011): at ti.map.TiUIMapView.onMarkerClick(TiUIMapView.java:369) 03-15 10:06:34.200: E/AndroidRuntime(13011): at com.google.android.gms.maps.GoogleMap$4.f(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at com.google.android.gms.internal.an$a.onTransact(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at android.os.Binder.transact(Binder.java:300) 03-15 10:06:34.200: E/AndroidRuntime(13011): at com.google.android.gms.maps.internal.IOnMarkerClickListener$Stub$Proxy.onMarkerClick(IOnMarkerClickListener.java:84) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.z.by.a(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.y.ba.a(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.y.d.c(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.y.bj.a(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.y.v.c(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.y.bf.onSingleTapConfirmed(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.d.v.onSingleTapConfirmed(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at maps.d.j.handleMessage(Unknown Source) 03-15 10:06:34.200: E/AndroidRuntime(13011): at android.os.Handler.dispatchMessage(Handler.java:99) 03-15 10:06:34.200: E/AndroidRuntime(13011): at android.os.Looper.loop(Looper.java:137) 03-15 10:06:34.200: E/AndroidRuntime(13011): at android.app.ActivityThread.main(ActivityThread.java:4464) 03-15 10:06:34.200: E/AndroidRuntime(13011): at java.lang.reflect.Method.invokeNative(Native Method) 03-15 10:06:34.200: E/AndroidRuntime(13011): at java.lang.reflect.Method.invoke(Method.java:511) 03-15 10:06:34.200: E/AndroidRuntime(13011): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822) 03-15 10:06:34.200: E/AndroidRuntime(13011): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589) 03-15 10:06:34.200: E/AndroidRuntime(13011): at dalvik.system.NativeStart.main(Native Method) {quote}

JSON Source