title: Google Maps v2 lag after popping their fragment back from stack
body: <p>I have an <code>Activity</code> with a <code>MapFragment</code> that I add to the <code>Activity</code> programmatically using a <code>FragmentTransaction</code>:</p>
  
  <pre><code>private static final String MAP_FRAGMENT_TAG = "map";
  private MapFragment mapFragment = null;
  
  ...
  
  protected void onCreate(Bundle savedInstanceState) {
  
      ...
  
      mapFragment = (MapFragment) getFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);
      if (mapFragment == null) {
          mapFragment = MapFragment.newInstance();
          FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
          fragmentTransaction.add(R.id.fragment_wrapper, mapFragment, MAP_FRAGMENT_TAG);
          fragmentTransaction.commit();
      }
  
      ...
  
  }
  </code></pre>
  
  <p>Standard way. Then I get the <code>GoogleMap</code> instance from the <code>mapFragment</code> and set its settings, set the listeners, do stuff with it. Everything works fine.</p>
  
  <p>Then when the user is done with the map, an <code>AsyncTask</code> gets triggered to show a <code>ProgressDialog</code>, perform some operation, put a different fragment into the <code>fragment_wrapper</code> and dismiss the <code>ProgressDialog</code> again:</p>
  
  <pre><code>private class GetFlightsTask extends AsyncTask&lt;Double, Void, String&gt; {
  
  @Override
  protected void onPreExecute() {
      super.onPreExecute();
      // the activity context has been passed to the AsyncTask through its constructor
      loadingFlightsSpinner = new ProgressDialog(context);
      // setting the dialog up
      loadingFlightsSpinner.show();
  }
  
  @Override
  protected String doInBackground(Double... params) {
      // some pretty long remote API call
      // (loading a JSON file from http://some.website.com/...)
  }
  
  @Override
  protected void onPostExecute(String flightsJSON) {
      super.onPostExecute(flightsJSON);
      // here I do stuff with the JSON and then I swtich the fragments like this
      FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
      FlightsFragment fragment = new FlightsFragment();
      fragmentTransaction.replace(R.id.fragment_wrapper, fragment);
      fragmentTransaction.addToBackStack(null);
      fragmentTransaction.commit();
      loadingFlightsSpinner.dismiss();
  }
  </code></pre>
  
  <p>Everything still works fine. The user does something in the <code>FlightsFragment</code> and then maybe decides to go back to the map. Presses the <em>back</em> button and the map pops up again. And this is when the map gets laggy. The countries/cities names on it load really slowly, it lags heavily on moving the map... And I have no idea why, I don't do anything on popping the <code>MapFragment</code> back.</p>
  
  <p>What's interesting is that it gets fixed for example on pressing the <em>home</em> button and then returning to the app again...</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thank you for any ideas.</p>