Fix freezing on Android when rotating

Fixes #1941
This commit is contained in:
Leith Bade
2015-09-22 16:23:39 +10:00
parent da691dcbb5
commit d2d3df2a69
5 changed files with 13 additions and 9 deletions

View File

@@ -699,6 +699,11 @@ void NativeMapView::updateFps() {
void NativeMapView::onInvalidate() {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::onInvalidate()");
if (map.isPaused()) {
mbgl::Log::Debug(mbgl::Event::Android, "Not rendering as map is paused");
return;
}
const bool dirty = !clean.test_and_set();
if (dirty) {
float zoomFactor = map.getMaxZoom() - map.getMinZoom() + 1;

View File

@@ -1009,14 +1009,6 @@ public class MapView extends FrameLayout implements LocationListener {
mNativeMapView.resizeFramebuffer(width, height);
}
// Called when we need to redraw the view
// This is called before our view is first visible to prevent an initial
// flicker (see Android SDK documentation)
/*@Override
public void surfaceRedrawNeeded(SurfaceHolder holder) {
mNativeMapView.update();
}*/ // TODO call update somewhere?
// Not used
@Override
public void onSurfaceTextureUpdated (SurfaceTexture surface) {
@@ -1796,7 +1788,6 @@ public class MapView extends FrameLayout implements LocationListener {
});
}
/**
* Defines callback for events OnMapChange
*/

View File

@@ -176,12 +176,14 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@@ -204,6 +206,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}

View File

@@ -58,6 +58,7 @@ public:
// Pauses the render thread. The render thread will stop running but will not be terminated and will not lose state until resumed.
void pause();
bool isPaused();
// Resumes a paused render thread
void resume();

View File

@@ -39,6 +39,10 @@ void Map::pause() {
}
}
bool Map::isPaused() {
return paused;
}
void Map::resume() {
data->condResume.notify_all();
paused = false;