From 690ba81ab391edbb7e4f7aa509e812ed2bc855cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Jun 2025 00:20:11 +0200 Subject: [PATCH 1/5] Crashfix in InstallZipScreen --- UI/InstallZipScreen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index 05ae5112ad..e648d46298 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -218,7 +218,9 @@ UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams ¶ms) { } if (g_GameManager.InstallZipOnThread(task)) { installStarted_ = true; - playChoice_->SetEnabled(false); // need to exit this screen to played the installed one. We could make this smarter. + if (playChoice_) { + playChoice_->SetEnabled(false); // need to exit this screen to played the installed one. We could make this smarter. + } if (installChoice_) { installChoice_->SetEnabled(false); } From 11ad7db3cb325c804d58f3ddb4e2b60de33b4600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Jun 2025 00:27:45 +0200 Subject: [PATCH 2/5] Simplification in EmuScreen.cpp --- UI/EmuScreen.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 77263423c0..5f9a707b82 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1471,15 +1471,9 @@ void EmuScreen::update() { bool EmuScreen::checkPowerDown() { // This is for handling things like sceKernelExitGame(). if (coreState == CORE_POWERDOWN && PSP_GetBootState() == BootState::Complete && !bootPending_) { - bool shutdown = false; - if (PSP_IsInited()) { - Achievements::UnloadGame(); - PSP_Shutdown(true); - shutdown = true; - } INFO_LOG(Log::System, "SELF-POWERDOWN!"); screenManager()->switchScreen(new MainScreen()); - return shutdown; + return true; } return false; } From deb2fa4a63b881c0d011c478cd8ebe5e2adb15c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Jun 2025 10:31:01 +0200 Subject: [PATCH 3/5] Texture replacement: Fix issue where we could accidentally close a file twice. Add a sanity check. --- Common/File/VFS/DirectoryReader.cpp | 4 +++- GPU/Common/ReplacedTexture.cpp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/File/VFS/DirectoryReader.cpp b/Common/File/VFS/DirectoryReader.cpp index 2dd9a550aa..01d0267615 100644 --- a/Common/File/VFS/DirectoryReader.cpp +++ b/Common/File/VFS/DirectoryReader.cpp @@ -98,7 +98,9 @@ size_t DirectoryReader::Read(VFSOpenFile *vfsOpenFile, void *buffer, size_t leng void DirectoryReader::CloseFile(VFSOpenFile *vfsOpenFile) { DirectoryReaderOpenFile *openFile = (DirectoryReaderOpenFile *)vfsOpenFile; _dbg_assert_(openFile->file != nullptr); - fclose(openFile->file); + if (openFile->file) { + fclose(openFile->file); + } openFile->file = nullptr; delete openFile; } diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index 8221c4c72f..8ba7d4ce3a 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -473,7 +473,6 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference basist::ktx2_transcoder transcoder; if (!transcoder.init(buffer.data(), (int)buffer.size())) { WARN_LOG(Log::TexReplacement, "Error reading KTX file"); - vfs_->CloseFile(openFile); return LoadLevelResult::LOAD_ERROR; } @@ -513,7 +512,6 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference } } else { WARN_LOG(Log::TexReplacement, "PPSSPP currently only supports KTX for basis/UASTC textures. This may change in the future."); - vfs_->CloseFile(openFile); return LoadLevelResult::LOAD_ERROR; } From 8d6f8b9399c224f96329faf5de41d689fc9aecff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Jun 2025 10:34:13 +0200 Subject: [PATCH 4/5] Cleanup and paranoia --- Common/System/Request.cpp | 2 +- Core/Util/GameDB.cpp | 3 ++- UI/DebugOverlay.cpp | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Common/System/Request.cpp b/Common/System/Request.cpp index 8111c09302..532c28d443 100644 --- a/Common/System/Request.cpp +++ b/Common/System/Request.cpp @@ -72,7 +72,7 @@ bool RequestManager::MakeSystemRequest(SystemRequestType type, RequesterToken to callbackMap_[requestId] = { callback, failedCallback, token }; } - INFO_LOG(Log::System, "Making system request %s: id %d", RequestTypeAsString(type), requestId); + DEBUG_LOG(Log::System, "Making system request %s: id %d", RequestTypeAsString(type), requestId); std::string p1(param1); std::string p2(param2); // TODO: Convert to string_view diff --git a/Core/Util/GameDB.cpp b/Core/Util/GameDB.cpp index 0eb634e1d2..4d42d175e4 100644 --- a/Core/Util/GameDB.cpp +++ b/Core/Util/GameDB.cpp @@ -59,6 +59,7 @@ static void SplitSV(std::string_view strv, char delim, bool removeWhiteSpace, st } } +// Call this with the mutex locked. void GameDB::LoadIfNeeded() { if (loaded_) { // Already loaded @@ -143,7 +144,7 @@ bool GameDB::GetGameInfos(std::string_view id, std::vector *infos) { LoadIfNeeded(); for (const auto &line : lines_) { - for (const auto serial : line.serials) { + for (const auto &serial : line.serials) { // Ignore version and stuff for now if (IDMatches(id, serial)) { GameDBInfo info; diff --git a/UI/DebugOverlay.cpp b/UI/DebugOverlay.cpp index 0ca818a930..354ced7e7b 100644 --- a/UI/DebugOverlay.cpp +++ b/UI/DebugOverlay.cpp @@ -304,7 +304,7 @@ void DrawCrashDump(UIContext *ctx, const Path &gamePath) { if (Reporting::HasCRC(gamePath)) { u32 crc = Reporting::RetrieveCRC(gamePath); std::vector dbInfos; - if (g_gameDB.GetGameInfos(discID, &dbInfos)) { + if (discID.size() >= 9 && g_gameDB.GetGameInfos(discID, &dbInfos)) { for (auto &dbInfo : dbInfos) { if (dbInfo.crc == crc) { isoOK = true; @@ -329,9 +329,9 @@ void DrawCrashDump(UIContext *ctx, const Path &gamePath) { // TODO: Draw a lot more information. Full register set, and so on. #ifdef _DEBUG - char build[] = "debug"; + const char * const build = "debug"; #else - char build[] = "release"; + const char * const build = "release"; #endif std::string sysName = System_GetProperty(SYSPROP_NAME); From 1f5064d582fa3a0e09e9a48b1e63d8b8f6e03589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Jun 2025 11:01:34 +0200 Subject: [PATCH 5/5] Disable error return value in sceAtracLowLevelDecode See issue #20452 --- Core/HLE/AtracCtx2.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Core/HLE/AtracCtx2.cpp b/Core/HLE/AtracCtx2.cpp index 714f2345dd..b758527c71 100644 --- a/Core/HLE/AtracCtx2.cpp +++ b/Core/HLE/AtracCtx2.cpp @@ -1031,9 +1031,12 @@ int Atrac2::DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, bool success = decoder_->Decode(srcData, info.sampleSize, bytesConsumed, channels, dstData, &outSamples); if (!success) { ERROR_LOG(Log::ME, "Low level decoding failed: sampleSize: %d bytesConsumed: %d", info.sampleSize, *bytesConsumed); + // We proceed anyway, see issue #20452 + /* *bytesConsumed = 0; *bytesWritten = 0; return SCE_ERROR_ATRAC_API_FAIL; // need to check what return value we get here. + */ } *bytesWritten = outSamples * channels * sizeof(int16_t); // TODO: Possibly return a decode error on bad data.