From 8b9836afd3a4e15f6fae8147bf5a74fc0cca8005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 24 Sep 2023 21:51:58 +0200 Subject: [PATCH] SizeManager: Don't send notifySurface if paused. Cleaner exits / task switches in the log. --- android/src/org/ppsspp/ppsspp/NativeActivity.java | 14 ++++++++------ android/src/org/ppsspp/ppsspp/SizeManager.java | 14 +++++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 1f4d09178d..831cc16d76 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -677,6 +677,12 @@ public abstract class NativeActivity extends Activity { public void notifySurface(Surface surface) { mSurface = surface; + + if (!initialized) { + Log.e(TAG, "Can't deal with surfaces while not initialized"); + return; + } + if (!javaGL) { // If we got a surface, this starts the thread. If not, it doesn't. if (mSurface == null) { @@ -740,12 +746,6 @@ public abstract class NativeActivity extends Activity { navigationCallbackView = decorView; } - @Override - protected void onStop() { - super.onStop(); - Log.i(TAG, "onStop - do nothing special"); - } - @Override protected void onDestroy() { super.onDestroy(); @@ -803,6 +803,7 @@ public abstract class NativeActivity extends Activity { super.onPause(); Log.i(TAG, "onPause"); loseAudioFocus(this.audioManager, this.audioFocusChangeListener); + sizeManager.setPaused(true); NativeApp.pause(); if (!javaGL) { mSurfaceView.onPause(); @@ -838,6 +839,7 @@ public abstract class NativeActivity extends Activity { protected void onResume() { super.onResume(); updateSustainedPerformanceMode(); + sizeManager.setPaused(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { updateSystemUiVisibility(); } diff --git a/android/src/org/ppsspp/ppsspp/SizeManager.java b/android/src/org/ppsspp/ppsspp/SizeManager.java index 25509769eb..af81f640dd 100644 --- a/android/src/org/ppsspp/ppsspp/SizeManager.java +++ b/android/src/org/ppsspp/ppsspp/SizeManager.java @@ -39,10 +39,18 @@ public class SizeManager implements SurfaceHolder.Callback { private Point desiredSize = new Point(); private int badOrientationCount = 0; + + private boolean paused = false; + public SizeManager(final NativeActivity a) { activity = a; } + + public void setPaused(boolean p) { + paused = p; + } + @TargetApi(Build.VERSION_CODES.P) public void setSurfaceView(SurfaceView view) { surfaceView = view; @@ -107,7 +115,11 @@ public class SizeManager implements SurfaceHolder.Callback { NativeApp.backbufferResize(width, height, format); updateDisplayMeasurements(); - activity.notifySurface(holder.getSurface()); + if (!paused) { + activity.notifySurface(holder.getSurface()); + } else { + Log.i(TAG, "Skipping notifySurface while paused"); + } } @Override