safety checks for crash prevention

This commit is contained in:
David Griswold 2025-11-11 23:02:21 +03:00
parent d5c95ac3d8
commit 592237a32b
2 changed files with 8 additions and 3 deletions

View File

@ -42,7 +42,12 @@ class SecondaryDisplay(val context: Context) : DisplayManager.DisplayListener {
}
fun updateSurface() {
NativeLibrary.secondarySurfaceChanged(pres!!.getSurfaceHolder().surface)
val surface = pres?.getSurfaceHolder()?.surface
if (surface != null && surface.isValid) {
NativeLibrary.secondarySurfaceChanged(surface)
} else {
Log.w("SecondaryDisplay", "Attempted to update null or invalid surface")
}
}
fun destroySurface() {

View File

@ -18,8 +18,8 @@
#include "video_core/renderer_base.h"
bool EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) {
int w = ANativeWindow_getWidth(surface);
int h = ANativeWindow_getHeight(surface);
int w = surface== NULL ? 0 : ANativeWindow_getWidth(surface);
int h = surface== NULL ? 0 : ANativeWindow_getHeight(surface);
if (render_window == surface && w == window_width && h == window_height) {
return false;
}