I have an android app with a TabActivity holding 4 tabs - a list view, a map view, another list and a webview. From the list view I can tap an item and it starts another activity, pressing back returns to the tab activity.
However, once the map view tab has been visited, navigating to the second activity from the list view and then pressing the back button results in a hang of about 3-4 seconds. Once the map view has been visited, this problem never goes away until the app is exited.
Some more notes:
- The map view can also launch another activity - and in this case the back button works fine - it's only if the map view tab is inactive when the second activity is launched that the problem occurs.
- Testing on two devices - problem occurs on Galaxy S, doesn't occur on Nexys 7.
- There's nothing obvious in logcat that I can see.
- App is using Maps API V2, and support lib for fragment support.
- App is written in Mono.
More info. I put in some log messages on the map activity for it's lifecycle events:
Switching away from the map tab:
02-12 18:53:43.841 I/MAPTEST ( 5031): OnSaveInstanceState
02-12 18:53:43.857 I/MAPTEST ( 5031): OnPause
Launching the second activity from the list view tab:
02-12 18:54:06.900 I/MAPTEST ( 5031): OnSaveInstanceState
virtual void WebCore::Widget::show()
virtual void WebCore::Widget::show()
void WebCore::ScriptController::updatePlatformScriptObjects()
virtual void WebCore::Widget::show()
static bool WebCore::ResourceHandle::supportsBufferedData()
static bool WebCore::ResourceHandle::supportsBufferedData()
02-12 18:54:07.353 I/MAPTEST ( 5031): OnStop
Pressing the back button from the second activity (ie: when the pause occurs):
-- Absolutely nothing in log cat --
Switching back to the map tab:
02-12 18:54:59.056 I/MAPTEST ( 5031): OnRestart
02-12 18:54:59.060 I/MAPTEST ( 5031): OnStart
02-12 18:54:59.064 I/MAPTEST ( 5031): OnResume
What might cause returning to an activity to block for 3-4 seconds?
Alternatively, what more can I do to diagnose this?
More info:
As per michal-z's comment, profiled it under DDMS and most of the time was being spent in message dispatching, layout and drawing... so I'm suspicious of some sort of recursive layout or drawing issue...
Also, I tried removing the map fragment when the map activity is stopped and adding it back when map activity is started and this resolved the delay problem, but the map doesn't remember it's state, looses all it's markers and it's slow to reappear.
Another follow up:
The only solution I could find for this is to remove the fragment when the activity is stopped and add it back when resumed - and also saving the camera position. I also tried hiding and re-showing the fragment both through the fragment manager and directly on the map view - no luck.