0

I'm current using OSMdroid for offline maps rendering. Although there are some issues with tile loading every now and then for offline maps in osmdroid, I'm fine with it. But in my android app, I see when I test my map by just zooming in and zooming out multiple times, my app responds very slowly gradually over the time. I'm not sure what exactly might be the problem. Is this the issue with OSMdroid or my app, i'm unable to find out.

I have a fragment class which loads the mapoffline activity.

public class MapActivityFragment extends Fragment{

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,

            Bundle savedInstanceState) {

         View rootView = inflater.inflate(R.layout.map_view, container, false);
        /*Create my offline MapView*/
        oMapViewOffline     = new MapViewOffline(mapView);
        oMapViewOffline.run();
        return rootView;

    }

In my MapViewOffline.java

public void run(){

        /*Get custom Tile data*/
        MapTilerCustomDataSource myNewXYTileSource = new MapTilerCustomDataSource();
        myNewXYTileSource.isSourceTMS = true;
        mMapViewOSM.setTileSource(myNewXYTileSource);
        mMapViewOSM.setUseDataConnection(false);
    }

My MapTilerCustomDataSource is based on: OSMdroid : How to load offline map from zip archive - MapTileFileArchiveProvider

The biggest deal is not just loading of my offline maps, I'm running a expensive AsyncTask as well.

What it does is read data from server and draws markers accordingly on mapview. This again is degrading my performance.

@Override
protected Void doInBackground(Void... arg0) {
      while(true){
          Shadow = new CustomOverlay(getApplicationContext());
          Shadow.getData();
          try {
        Thread.sleep(1000);
          } catch (InterruptedException e) {
        e.printStackTrace();
        }
        publishProgress();
        mCount++;
     }
}

@Override
protected void onProgressUpdate(Void... progress){
     Shadow.runDrawing();
     listOfSensorOverlays.add(Shadow);
     mapView.invalidate();
}

How can I make my android app perform better? What might be the reasons that is causing the degrade in performance; Is it the osmdroid or the Async Task?

Community
  • 1
  • 1
zIronManBox
  • 4,967
  • 6
  • 19
  • 35
  • 1
    Have you run a performance profiler on it to see what methods are taking long to run. See http://developer.android.com/tools/debugging/debugging-tracing.html – kurtzmarc Mar 21 '14 at 13:11
  • I did run a traceview using DDMS on my app, although I dont fully understand the consumptions. I notice that android/os/Handler.Messages consumes 43%, android/os/MessageQueue.Next consumes 28% and osm maptileprovider consumes 15%. So, what should I be looking for? For better clarity I've attached an image. http://i62.tinypic.com/fu2v75.png – zIronManBox Mar 24 '14 at 10:39
  • I also observed some more facts. 1)When I do too much zoom in / zoom out the osm maptileprovider consumes over 30%. 2)When I disable **Async Task**, I see some little bit better performance. – zIronManBox Mar 24 '14 at 10:44
  • Zooming in and out will take some CPU cycles as it scales the tiles, but that should settle after a second or two. How many markers are you drawing? You will probably need to learn how to read the trace dump to understand what is going on. I would also recommend looking at the reference app OpenStreetMapViewer to see if you can reproduce it there. – kurtzmarc Mar 24 '14 at 13:06
  • @kurtzmarc Just another clarification. Which one is faster reading offline maptiles...GEMF or ZIP? – zIronManBox May 14 '14 at 16:50
  • @zIronMapBox - sorry, I don't have any experience comparing the speed of the two. – kurtzmarc May 14 '14 at 17:08

0 Answers0