@@ -174,6 +174,7 @@ static float dp_yscale = 1.0f;
174
174
175
175
static bool renderer_inited = false ;
176
176
static bool sustainedPerfSupported = false ;
177
+ static std::mutex renderLock;
177
178
178
179
// See NativeQueryConfig("androidJavaGL") to change this value.
179
180
static bool javaGL = true ;
@@ -567,6 +568,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
567
568
EARLY_LOG (" NativeApp.init() -- begin" );
568
569
PROFILE_INIT ();
569
570
571
+ std::lock_guard<std::mutex> guard (renderLock);
570
572
renderer_inited = false ;
571
573
androidVersion = jAndroidVersion;
572
574
deviceType = jdeviceType;
@@ -776,9 +778,14 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) {
776
778
INFO_LOG (G3D, " Not shutting down renderer - not initialized" );
777
779
}
778
780
779
- inputBoxCallbacks.clear ();
780
- NativeShutdown ();
781
- VFSShutdown ();
781
+ {
782
+ std::lock_guard<std::mutex> guard (renderLock);
783
+ inputBoxCallbacks.clear ();
784
+ NativeShutdown ();
785
+ VFSShutdown ();
786
+ }
787
+
788
+ std::lock_guard<std::mutex> guard (frameCommandLock);
782
789
while (frameCommands.size ())
783
790
frameCommands.pop ();
784
791
INFO_LOG (SYSTEM, " NativeApp.shutdown() -- end" );
@@ -929,10 +936,14 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendInputBox(JNIEnv *en
929
936
NativeInputBoxReceived (entry->second , result, value);
930
937
}
931
938
932
- void UpdateRunLoopAndroid (JNIEnv *env) {
939
+ void LockedNativeUpdateRender () {
940
+ std::lock_guard<std::mutex> renderGuard (renderLock);
933
941
NativeUpdate ();
934
-
935
942
NativeRender (graphicsContext);
943
+ }
944
+
945
+ void UpdateRunLoopAndroid (JNIEnv *env) {
946
+ LockedNativeUpdateRender ();
936
947
937
948
std::lock_guard<std::mutex> guard (frameCommandLock);
938
949
if (!nativeActivity) {
@@ -1352,10 +1363,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
1352
1363
}
1353
1364
} else {
1354
1365
while (!exitRenderLoop) {
1355
- NativeUpdate ();
1356
-
1357
- NativeRender (graphicsContext);
1358
-
1366
+ LockedNativeUpdateRender ();
1359
1367
graphicsContext->SwapBuffers ();
1360
1368
1361
1369
ProcessFrameCommands (env);
0 commit comments