ANR Crash : BalloonPopUp is not showing in onVectorElementClicked

508 views
Skip to first unread message

Siva G

unread,
Jan 23, 2016, 11:21:21 PM1/23/16
to Nutiteq-dev
Hi All,

I am working on a functionality where i have ClusteredVectoryLayer  and buildClusterElement is returning Clustered Marker. Now if i zoom in... I can see original marker instead of cluster marker. At this point if user tap on that marker i have to show BalloonPopUp but when i clicked on the original marker App is going into ANR state and crashing.

If i add a balloonpopup in onMapClicked it is working but if try to add balloonpopup in onVectorElementClicked getting above ANR. I am not able to understand why it is happening. 

Please guide me in right direction.if i am doing anything wrong.

ANR log: I have seen this many times while achieving the above functionality.

01-24 09:03:12.143: D/skia(22172): jpeg_decoder finish successfully, L:1822!!!
01-24 09:03:20.032: I/ViewRootImpl(22172): ANR Key Analyze: No Key event currently.
01-24 09:03:20.033: I/ViewRootImpl(22172): ANR Key Analyze: Previeous Event null,finish at 1970-01-01 05:30:00.000
01-24 09:03:20.035: I/ViewRootImpl(22172): Dispatch MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=737.71246, y[0]=387.92865, toolType[0]=TOOL_TYPE_FINGER, id[1]=1, x[1]=166.52936, y[1]=1210.4927, toolType[1]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=2, historySize=2, eventTime=359237688, downTime=359237488, deviceId=6, source=0x1002 } status is 10: View Post IME stage,start at 2016-01-24 09:03:11.523, spent 8511ms.
01-24 09:03:20.045: D/ANRAppManager(22172): !!! It is not under singleton mode, U can't use it. !!!
01-24 09:03:20.046: W/Binder(22172): Caught a RuntimeException from the binder stub implementation.
01-24 09:03:20.046: W/Binder(22172): java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder com.mediatek.anrappmanager.IFrameworks.serviceManagerGetService(java.lang.String)' on a null object reference
01-24 09:03:20.046: W/Binder(22172): at com.mediatek.anrappmanager.ANRManagerNative$1.b(SourceFile:77)
01-24 09:03:20.046: W/Binder(22172): at com.mediatek.anrappmanager.ANRManagerNative$1.c(SourceFile:75)
01-24 09:03:20.046: W/Binder(22172): at com.mediatek.anrappmanager.ANRManagerNative$a.get(SourceFile:97)
01-24 09:03:20.046: W/Binder(22172): at com.mediatek.anrappmanager.ANRManagerNative.getDefault(SourceFile:35)
01-24 09:03:20.046: W/Binder(22172): at com.mediatek.anrappmanager.ANRAppManager.dumpMessageHistory(SourceFile:59)
01-24 09:03:20.046: W/Binder(22172): at android.app.ActivityThread$ApplicationThread.dumpMessageHistory(ActivityThread.java:1232)
01-24 09:03:20.046: W/Binder(22172): at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:679)
01-24 09:03:20.046: W/Binder(22172): at android.os.Binder.execTransact(Binder.java:451)
01-24 09:03:20.046: W/System.err(22172): java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder com.mediatek.anrappmanager.IFrameworks.serviceManagerGetService(java.lang.String)' on a null object reference
01-24 09:03:20.047: W/System.err(22172): at com.mediatek.anrappmanager.ANRManagerNative$1.b(SourceFile:77)
01-24 09:03:20.047: W/System.err(22172): at com.mediatek.anrappmanager.ANRManagerNative$1.c(SourceFile:75)
01-24 09:03:20.047: W/System.err(22172): at com.mediatek.anrappmanager.ANRManagerNative$a.get(SourceFile:97)
01-24 09:03:20.047: W/System.err(22172): at com.mediatek.anrappmanager.ANRManagerNative.getDefault(SourceFile:35)
01-24 09:03:20.047: W/System.err(22172): at com.mediatek.anrappmanager.ANRAppManager.dumpMessageHistory(SourceFile:59)
01-24 09:03:20.048: W/System.err(22172): at android.app.ActivityThread$ApplicationThread.dumpMessageHistory(ActivityThread.java:1232)
01-24 09:03:20.048: W/System.err(22172): at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:679)
01-24 09:03:20.048: W/System.err(22172): at android.os.Binder.execTransact(Binder.java:451)
01-24 09:03:20.088: I/art(22172): Thread[9,tid=22186,WaitingInMainSignalCatcherLoop,Thread*=0xab75b3f8,peer=0x12c2f080,"Signal Catcher"]: reacting to signal 3
01-24 09:03:20.330: I/art(22172): Wrote stack traces to '/data/anr/traces.txt'


Initially i was using nutiteq maps sdk 3.2.0 version... At this point even  balloonpopup in onMapClicked is also not worked but later i have upgraded to 3.2.2 and onMapClicked is working but onVectorElementClicked is not working.

Test Environment: 3.2.2 sdk, Android Lollipop Setup(API 21). Eclipse, Lenovo K3 test android device.


buildClusterElement code is as below. 


public
VectorElement buildClusterElement(MapPos pos, VectorElementVector elements) {


// Try to reuse existing marker styles

MarkerStylEnter code her...
e
style = markerStyles.get((int) elements.size());

if (elements.size() == 1) {

if(elements.get(0) instanceof BalloonPopup){

System.out.println("element is of balloon type so returning balloon from here...."); //If idont return heregetting class cast exception

return elements.get(0);

}

style = ((Marker) elements.get(0)).getStyle();

}

if (style == null) {

android.graphics.Bitmap canvasBitmap = markerBitmap.copy(android.graphics.Bitmap.Config.ARGB_8888, true);

android.graphics.Canvas canvas = new android.graphics.Canvas(canvasBitmap);

android.graphics.Paint paint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);

paint.setTextAlign(Align.CENTER);

paint.setTextSize(12);

paint.setColor(android.graphics.Color.argb(255, 0, 0, 0));

canvas.drawText(Integer.toString((int) elements.size()), markerBitmap.getWidth() / 2, markerBitmap.getHeight() / 2 - 5, paint);

MarkerStyleBuilder styleBuilder = new MarkerStyleBuilder();

styleBuilder.setBitmap(BitmapUtils.createBitmapFromAndroidBitmap(canvasBitmap));

styleBuilder.setSize(30);

       styleBuilder.setPlacementPriority((int)-elements.size());

style = styleBuilder.buildStyle();

markerStyles.put((int) elements.size(), style);

}

System.out.println("returning marker");

// Create marker for the cluster

Marker marker = new Marker(pos, style);

return marker;

}





Jaak Laineste

unread,
Jan 24, 2016, 1:59:16 PM1/24/16
to nutit...@googlegroups.com
Hello,

Please give the class source which generates the ANR crash, it is probably your MapEventListener. The log what you give is a general system log, it has  nothing about your app or our SDK in it.

Also, does it happen on different devices?

Jaak
Nutiteq


--
You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark

unread,
Jan 24, 2016, 5:12:07 PM1/24/16
to Nutiteq-dev
Hi Siva,

SDK implicitly assumes that you always create a new vector element in buildClusterElement. So you have to clone your existing popup, even when cluster is based on only 1 element. Otherwise you get infinite loop for rather intricate reasons - SDK monitors your layer data source elements and rebuilds clusters if anything changes. At the same time, SDK itself animates created cluster elements. So when you try to reuse your existing vector element as cluster element, SDK animates it, then notices that data source has changed, rebuilds cluster again and so on.

I think this is not currently documented, so we will add some comments about this behaviour.

Regards,
Mark

siva subbu

unread,
Jan 24, 2016, 8:08:41 PM1/24/16
to nutit...@googlegroups.com
Thanks for the information Mark. I have uploaded the sample code into git repository.

I am not able to understand why the same code(Showing popup based on click) is working in onMapClicked and not in onVectorElementClicked. Please check my buildClusterElement code also. I have checked the datasource size in onVectorElementClicked it is adding balloon popup into datasource but not displaying it. Is there any reason please explain.

Kindly let me know where i am wrong. 

--
You received this message because you are subscribed to a topic in the Google Groups "Nutiteq-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nutiteq-dev/wWZ74v7xEYo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nutiteq-dev...@googlegroups.com.

Jaak Laineste

unread,
Jan 25, 2016, 2:38:14 AM1/25/16
to nutit...@googlegroups.com

Hello,

You should not use same DataSource for your Markers (which are clustered automatically), and for BalloonPopups. Currently clustering would try to do clusters also for the balloons you add to the datasource. It happens to be not an issue with standalone balloon, but with onVectorElementClicked there will be circular reference of the clicked Marker on map (base elements) and this causes ANR in some situations, like when clusters are recalculated after zoom. 

So just create new VectorDataSource and Layer for the balloons, simplest fix in your Activity:

LocalVectorDataSource vectorDataSource2 = new LocalVectorDataSource(proj);
mapView.getLayers().add(new VectorLayer(vectorDataSource2));
mapView.setMapEventListener(new MyMapEventListener(mapView,
      vectorDataSource2));


Jaak

You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.

Jaak Laineste

unread,
Jan 25, 2016, 3:54:23 AM1/25/16
to nutit...@googlegroups.com
Hello,

p.s. as Mark suggested, your cluster element builder cannot return same element, so you should remove following from your ClusteredRandomPoints.java:

// Try to reuse existing marker styles
if (elements.get(0) instanceof BalloonPopup) {
   System.out
         .println("element is of balloon type so returing from here....");
   return elements.get(0);
}

Jaak
Reply all
Reply to author
Forward
0 new messages