mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-23 16:19:44 +00:00
Android: Fix race condition on lock/unlock.
This might be related to the recreate from bad orientation - sometimes, it was pause/resuming pretty quick, which would get stuck waiting for a join.
This commit is contained in:
parent
7f5ba21402
commit
9c046d7518
@ -1101,6 +1101,10 @@ static void ProcessFrameCommands(JNIEnv *env) {
|
||||
}
|
||||
|
||||
extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(JNIEnv *env, jobject obj, jobject _surf) {
|
||||
exitRenderLoop = false;
|
||||
// This is up here to prevent race conditions, in case we pause during init.
|
||||
renderLoopRunning = true;
|
||||
|
||||
ANativeWindow *wnd = ANativeWindow_fromSurface(env, _surf);
|
||||
|
||||
// Need to get the local JNI env for the graphics thread. Used later in draw_text_android.
|
||||
@ -1113,6 +1117,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
|
||||
|
||||
if (wnd == nullptr) {
|
||||
ELOG("Error: Surface is null.");
|
||||
renderLoopRunning = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1131,7 +1136,7 @@ retry:
|
||||
if (!graphicsContext->Init(wnd, desiredBackbufferSizeX, desiredBackbufferSizeY, backbuffer_format, androidVersion)) {
|
||||
ELOG("Failed to initialize graphics context.");
|
||||
|
||||
if (vulkan && tries < 2) {
|
||||
if (!exitRenderLoop && (vulkan && tries < 2)) {
|
||||
ILOG("Trying again, this time with OpenGL.");
|
||||
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
|
||||
SetGPUBackend((GPUBackend)g_Config.iGPUBackend); // Wait, why do we need a separate enum here?
|
||||
@ -1141,10 +1146,11 @@ retry:
|
||||
|
||||
delete graphicsContext;
|
||||
graphicsContext = nullptr;
|
||||
renderLoopRunning = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!renderer_inited) {
|
||||
if (!exitRenderLoop && !renderer_inited) {
|
||||
NativeInitGraphics(graphicsContext);
|
||||
if (renderer_ever_inited) {
|
||||
NativeDeviceRestore();
|
||||
@ -1153,9 +1159,6 @@ retry:
|
||||
renderer_ever_inited = true;
|
||||
}
|
||||
|
||||
exitRenderLoop = false;
|
||||
renderLoopRunning = true;
|
||||
|
||||
while (!exitRenderLoop) {
|
||||
static bool hasSetThreadName = false;
|
||||
if (!hasSetThreadName) {
|
||||
@ -1174,9 +1177,11 @@ retry:
|
||||
}
|
||||
|
||||
ILOG("Leaving EGL/Vulkan render loop.");
|
||||
g_gameInfoCache->WorkQueue()->Flush();
|
||||
if (g_gameInfoCache)
|
||||
g_gameInfoCache->WorkQueue()->Flush();
|
||||
|
||||
NativeDeviceLost();
|
||||
if (renderer_inited)
|
||||
NativeDeviceLost();
|
||||
renderer_inited = false;
|
||||
|
||||
ILOG("Shutting down graphics context.");
|
||||
|
@ -432,7 +432,7 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
||||
// Start emulation using the provided Surface.
|
||||
if (!runEGLRenderLoop(mSurface)) {
|
||||
// Shouldn't happen.
|
||||
Log.e(TAG, "Failed to start up OpenGL");
|
||||
Log.e(TAG, "Failed to start up OpenGL/Vulkan");
|
||||
}
|
||||
Log.i(TAG, "Left the render loop: " + mSurface);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user