Revert "Implement exit callbacks. Attempt to solve #21828"

This reverts commit e4d3cc841c.
This commit is contained in:
Henrik Rydgård committed 2026-07-08 18:09:09 +02:00
1 parent 141b21a133
commit d5cec86933
3 files changed
+4 -128

No files matched your search

+2 -39
View File
@@ -65,7 +65,6 @@ using namespace std::placeholders;
#include "GPU/GPUCommon.h"
#include "Core/MIPS/MIPS.h"
#include "Core/HLE/sceCtrl.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/sceSas.h"
#include "Core/HLE/sceNet.h"
#include "Core/HLE/sceDisplay.h"
@@ -472,33 +471,6 @@ EmuScreen::~EmuScreen() {
bootPending_ = false;
}
// Catch-all for shutdown paths that didn't go through REQUEST_GAME_STOP (e.g. user navigated
// away with the back button, opened a different game, etc.). If an exit callback is registered
// and the core is still running, drive the CPU synchronously here so the callback gets a chance
// to run - there are no more host frames after this point. Capped tightly so a misbehaving
// callback can't stall shutdown.
if (!bootPending_ && PSP_IsInited() && coreState != CORE_POWERDOWN) {
const bool inflight = __KernelIsExitCallbackPending();
if (inflight || __KernelInvokeRegisteredExitCallback()) {
INFO_LOG(Log::Loader, "EmuScreen dtor: %s exit callback synchronously before shutdown",
inflight ? "finishing in-flight" : "running");
if (coreState == CORE_NEXTFRAME)
coreState = CORE_RUNNING_CPU;
const s64 chunkCycles = usToCycles(100000); // ~100ms of emulated time per chunk
const int maxChunks = 20; // hard cap: ~2s of emulated time total
for (int i = 0; i < maxChunks && __KernelIsExitCallbackPending(); i++) {
if (coreState != CORE_RUNNING_CPU && coreState != CORE_NEXTFRAME)
break;
PSP_RunLoopFor((int)chunkCycles);
if (coreState == CORE_NEXTFRAME)
coreState = CORE_RUNNING_CPU;
}
if (__KernelIsExitCallbackPending()) {
WARN_LOG(Log::Loader, "Exit callback didn't return in time; powering down anyway.");
}
}
}
Achievements::UnloadGame();
PSP_Shutdown(true);
@@ -591,17 +563,8 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
WARN_LOG(Log::Loader, "Can't stop during a pending boot");
return;
}
// Give the game a chance to run its registered exit callback before tearing things down.
// If the dispatch took, we keep running emulation; ActionAfterExitCallback (or a direct
// sceKernelExitGame from inside the callback) flips coreState to CORE_POWERDOWN, and
// checkPowerDown() then switches us to MainScreen as usual. Pressing stop again while
// the callback is in flight, or stopping a non-running core, falls through to immediate shutdown.
if (coreState == CORE_RUNNING_CPU && !__KernelIsExitCallbackPending() && __KernelInvokeRegisteredExitCallback()) {
INFO_LOG(Log::Loader, "REQUEST_GAME_STOP: running exit callback before shutdown.");
} else {
// No callback (or already in flight, or core not running) - the destructor will take care of shutting down.
screenManager()->switchScreen(new MainScreen());
}
// The destructor will take care of shutting down.
screenManager()->switchScreen(new MainScreen());
} else if (message == UIMessage::REQUEST_GAME_RESET) {
if (bootPending_) {
WARN_LOG(Log::Loader, "Can't reset during a pending boot");