Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Minor activity lifecycle stuff #18230

Merged
merged 6 commits into from
Sep 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
EARLY_LOG("NativeApp.init() -- begin");
PROFILE_INIT();

std::lock_guard<std::mutex> guard(renderLock); // Note: This is held for the rest of this function - intended?
std::lock_guard<std::mutex> guard(renderLock); // Note: This is held for the rest of this function - intended? and even necessary?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think so. I think it should be on shutdown too. It should not be possible to update renderer_inited to true, update renderer_inited to false, or render at the same time. Those operations should all be sequenced. Remember that there are annoying things happening with resize events and etc.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, true. I'll throw in a lock in shutdown too.

renderer_inited = false;
exitRenderLoop = false;
androidVersion = jAndroidVersion;
deviceType = jdeviceType;

Expand Down Expand Up @@ -1462,10 +1463,18 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runVulkanRenderLoo

if (!graphicsContext) {
ERROR_LOG(G3D, "runVulkanRenderLoop: Tried to enter without a created graphics context.");
renderLoopRunning = false;
exitRenderLoop = false;
return false;
}

exitRenderLoop = false;
if (exitRenderLoop) {
WARN_LOG(G3D, "runVulkanRenderLoop: ExitRenderLoop requested at start, skipping the whole thing.");
renderLoopRunning = false;
exitRenderLoop = false;
return true;
}

// This is up here to prevent race conditions, in case we pause during init.
renderLoopRunning = true;

Expand Down Expand Up @@ -1525,6 +1534,7 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runVulkanRenderLoo
INFO_LOG(G3D, "Shutting down graphics context from render thread...");
graphicsContext->ShutdownFromRenderThread();
renderLoopRunning = false;
exitRenderLoop = false;

WARN_LOG(G3D, "Render loop function exited.");
return true;
Expand Down