MapView laggy, unresponsive after calling getMapDrawingCache

2639
9
08-16-2012 10:18 PM
SimonKlein
Occasional Contributor
Hi!

I have to report, that the bug discussed here http://forums.arcgis.com/threads/46792-mapview.getMapDrawingCache%28%29-returns-null is only partly fixed for me.
As said in that thread:
The problem is that when the bitmap is the entire map there is a lag in generating the bitmap.
If the bitmap is a smaller area the lag is unnoticeable.

This a bug we are fixing.

The code posted earlier if executed twice works without a problem.

Try using the code below, if you single tap on the map twice you will see the bitmap.


  map.setOnSingleTapListener(new OnSingleTapListener() {

      /**
       *
       */
      private static final long serialVersionUID = 1L;

      public void onSingleTap(float arg0, float arg1) {
       Polygon polygon = map.getExtent();
       Envelope env = new Envelope();
       polygon.queryEnvelope(env);
       Bitmap bitmap = map.getDrawingMapCache(arg0, arg1,
         100, 100));
//                                                        Bitmap bitmap = map.getDrawingMapCache(0, 0,
//         map.getWidth(), map.getHeight()));
       Log.d(TAG, "width = " + map.getWidth() + " ht = "
         + map.getHeight());
       ImageView img = new ImageView(HelloWorld.this);
       img.setImageBitmap(bitmap);
       map.addView(img);
      }
     });


Thanks
Archana


If you get the drawingcache from your whole mapview like this
map.getDrawingMapCache(0f, 0f,mMapView.getWidth(), mMapView.getHeight()));

it becomes really unresponsive and simply unusable. If the area is smaller like for example 200x200 there is no noticeable drop in responsiveness.
And sometimes I still need to call the method more then one time (but 2 times max).
I have tested this with SDK v1.1, v1.1.1 and v2.0 on a Galaxy Tab 10.1n, Galaxy S 2.3.6 and  a Galaxy Nexus with 4.1.1 with our ArcGIS Server 10.03.
Unfortunately I can not provide any logs, because there are none for this bug.
0 Kudos
9 Replies
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Simon,
Ironically I just called tech support about this very issue yesterday.  I'm experiencing the exact same lag that you describe.  It only happens after calling getMapDrawingCache().  I've tried setting it to false after generating the map image, and i've tried calling destroyDrawingCache() and getDrawingCache().recycle();.  None of them seem to solve the problem.

I also have to still loop the code a number of times in order to create the a bitmap.

I'm also still having the "black box" issue on Android 2.2.x devices (http://forums.arcgis.com/threads/46792-mapview.getMapDrawingCache%28%29-returns-null Post #15) This doesn't happen on any 3.0.x or 4.0.x devices.  This only happens when calling getMapDrawingCache().

FYI - My incident # is 1065985.  I suggest calling Tech Support and opening another incident.  Maybe between the two of us (or anyone else) we can get this resolved or find a workaround.

-Andrew
0 Kudos
SimonKlein
Occasional Contributor
Simon,
I've tried setting it to false after generating the map image, and i've tried calling destroyDrawingCache() and getDrawingCache().recycle();.  None of them seem to solve the problem.
-Andrew


Thanks for your help. I've tried these things too, but nothing helped.
Unfortunately I'm just an intern and I don't have any support contract or something like that so I can't look at your incident or call the support myself.

Let me know if there are any news on your request.

Did they say something about the callout not showing in the bitmap also?
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
I logged the incident and am awaiting a call back.  I called for an update yesterday and was told that Due to the complex nature of this issue, they are dedicating expert resource to this incident in order to maintain forward progress and expedite incident resolution.

A new specialist is currently reviewing the incident history and will be contacting you shortly.

That's all I have for now.  I will inquire about the callout when I talk to someone.
0 Kudos
SimonKlein
Occasional Contributor
Thanks for the heads up!
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Update from Tech Support:

" I have created a reproducible sample which demonstrates the issue. I will discuss with our dev contact on this and will let you know the findings. "
0 Kudos
by Anonymous User
Not applicable
Yes, this is all true.  We are researching this problem and hope to have a solution soon. 

Regards,
Doug Carroll, ESRI Support Services, SDK Tech Lead
http://support.esri.com/
0 Kudos
by Anonymous User
Not applicable
Just an update.  We logged a bug for this behavior.  NIM084361: MapView gets unresponsive after calling the getDrawingMapCache() method. We will target a fix in the upcoming release.

Would you please comment on what you plan to do with the static image following the getDrawingMapCache() call?  If we have a understanding of this we could test this method in the SDK accordingly.

-Doug C, ESRI Support Services, SDK Tech Lead
http://support.esri.com/
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Just an update.  We logged a bug for this behavior.  NIM084361: MapView gets unresponsive after calling the getDrawingMapCache() method. We will target a fix in the upcoming release.

Would you please comment on what you plan to do with the static image following the getDrawingMapCache() call?  If we have a understanding of this we could test this method in the SDK accordingly.

-Doug C, ESRI Support Services, SDK Tech Lead
http://support.esri.com/


Thanks Doug.  I use the static image to attach to a share intent.  This way the user can share a snapshot of the map as an email attachment, MMS, Social Media, etc. 

As a bit of a sidenote/add on.....  I see no way to include a callout (if visible) as part of the getDrawingMapCache() call.  While I realize the callout view is not part of the map itself, the callout has no methods to call in order to be able to add it to (or overlay) on the bitmap result of getDrawingMapCache().  Just something I thought would be helpful to be able to display.
0 Kudos
JuliusBagdonas
New Contributor
Are there any updates on this issue? It is still present on 10.1.1...

edit: also on 10.1.1 u1. Tested on samsung galaxy s4, samsung galaxy y, htc sense hd, samsung galaxy tab 3. The lag isn't very noticeable on galaxy y, sense hd and tab 3, but s4 becomes unusable. Also, methd profiling shows that gl thread keeps on calling nativeMapRenderToFile() untill activity is restarted on all of these devices.
0 Kudos