From 6328a4414bcd98463859f26060123bf8c1016529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 16 Sep 2024 11:51:06 +0200 Subject: [PATCH 1/3] Minor logging change --- Core/HLE/sceKernelModule.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 03ddb4860d..dd0b7e0e0b 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -2403,10 +2403,13 @@ static u32 sceKernelUnloadModule(u32 moduleId) u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus) { if (loadedModules.size() > 1) { - if (WithStatus) + if (WithStatus) { ERROR_LOG_REPORT(Log::sceModule, "UNIMPL sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): game may have crashed", exitCode, argSize, argp, statusAddr, optionAddr); - else - ERROR_LOG_REPORT(Log::sceModule, "UNIMPL sceKernelSelfStopUnloadModule(%08x, %08x, %08x): game may have crashed", exitCode, argSize, argp); + } else { + // NOTE: The previous "may have crashed" message is not accurate, Splinter Cell Essentials uses this normally when leaving/entering in-game. + // We should not report this. + WARN_LOG(Log::sceModule, "sceKernelSelfStopUnloadModule(%08x, %08x, %08x)", exitCode, argSize, argp); + } SceUID moduleID = __KernelGetCurThreadModuleId(); u32 priority = 0x20; u32 stacksize = 0x40000; @@ -2420,7 +2423,6 @@ u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, ERROR_LOG(Log::sceModule, "sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): invalid module id", exitCode, argSize, argp, statusAddr, optionAddr); else ERROR_LOG(Log::sceModule, "sceKernelSelfStopUnloadModule(%08x, %08x, %08x): invalid module id", exitCode, argSize, argp); - return error; } From b1fae3ccda06dce30fabdc0f3ff527bad40570fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 16 Sep 2024 14:59:58 +0200 Subject: [PATCH 2/3] Add two missing mutex-locks in MetaFileSystem. See #19272 --- Core/FileSystems/MetaFileSystem.cpp | 3 +++ Core/FileSystems/MetaFileSystem.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 8fba8dff00..adc86c0ebb 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -292,12 +292,14 @@ void MetaFileSystem::Mount(const std::string &prefix, std::shared_ptr guard(lock); for (auto iter = fileSystems.begin(); iter != fileSystems.end(); iter++) { if (iter->prefix == prefix) { fileSystems.erase(iter); @@ -325,6 +327,7 @@ IFileSystem *MetaFileSystem::GetSystemFromFilename(const std::string &filename) } IFileSystem *MetaFileSystem::GetSystem(const std::string &prefix) { + std::lock_guard guard(lock); for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) { if (it->prefix == NormalizePrefix(prefix)) return it->system.get(); diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index a735106f68..0a2255566f 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -43,8 +43,9 @@ private: currentDir_t currentDir; std::string startingDirectory; - std::recursive_mutex lock; // must be recursive + std::recursive_mutex lock; // must be recursive. TODO: fix that + // Assumes the lock is held void Reset() { // This used to be 6, probably an attempt to replicate PSP handles. // However, that's an artifact of using psplink anyway... From 11210442ce50e4d080425afe8e3c60b6238cda57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 17 Sep 2024 11:24:22 +0200 Subject: [PATCH 3/3] Fix potential crash in reporting screenshot functionality --- Common/UI/Screen.cpp | 1 + UI/ReportScreen.cpp | 23 ++++++++++++++--------- UI/ReportScreen.h | 9 +++++++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Common/UI/Screen.cpp b/Common/UI/Screen.cpp index 05a6c155c4..28943fb6a8 100644 --- a/Common/UI/Screen.cpp +++ b/Common/UI/Screen.cpp @@ -185,6 +185,7 @@ ScreenRenderFlags ScreenManager::render() { Screen *coveringScreen = nullptr; Screen *foundBackgroundScreen = nullptr; bool first = true; + do { --iter; ScreenRenderRole role = iter->screen->renderRole(first); diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 3701db3d63..8458507c99 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -160,20 +160,20 @@ void CompatRatingChoice::SetupChoices() { AddChoice(4, rp->T("Nothing")); } -ReportScreen::ReportScreen(const Path &gamePath) - : UIDialogScreenWithGameBackground(gamePath) { +ReportScreen::ReportScreen(const Path &gamePath) // unused gamePath, after removing the background + : UIDialogScreen(), gamePath_(gamePath) { enableReporting_ = Reporting::IsEnabled(); ratingEnabled_ = enableReporting_; } ScreenRenderFlags ReportScreen::render(ScreenRenderMode mode) { - ScreenRenderFlags flags = UIScreen::render(mode); + _dbg_assert_(mode & ScreenRenderMode::FIRST); + _dbg_assert_(mode & ScreenRenderMode::TOP); if (mode & ScreenRenderMode::TOP) { - // We do this after render because we need it to be within the frame (so the screenshot works). // We could do it mid frame, but then we have to reapply viewport/scissor. - if (!tookScreenshot_) { + if (!tookScreenshot_ && !g_Config.bSkipBufferEffects) { Path path = GetSysDirectory(DIRECTORY_SCREENSHOT); if (!File::Exists(path)) { File::CreateDir(path); @@ -189,6 +189,11 @@ ScreenRenderFlags ReportScreen::render(ScreenRenderMode mode) { tookScreenshot_ = true; } } + + // We take the screenshot first, then we start rendering. + // We are the only screen visible so this avoid starting and then trying to resume a backbuffer render pass. + ScreenRenderFlags flags = UIScreen::render(mode); + return flags; } @@ -200,12 +205,12 @@ void ReportScreen::update() { screenshot_->SetVisibility(V_GONE); } } - UIDialogScreenWithGameBackground::update(); + UIDialogScreen::update(); UpdateCRCInfo(); } void ReportScreen::resized() { - UIDialogScreenWithGameBackground::resized(); + UIDialogScreen::resized(); RecreateViews(); } @@ -407,7 +412,7 @@ EventReturn ReportScreen::HandleShowCRC(EventParams &e) { } ReportFinishScreen::ReportFinishScreen(const Path &gamePath, ReportingOverallScore score) - : UIDialogScreenWithGameBackground(gamePath), score_(score) { + : UIDialogScreen(), gamePath_(gamePath), score_(score) { } void ReportFinishScreen::CreateViews() { @@ -468,7 +473,7 @@ void ReportFinishScreen::update() { } } - UIDialogScreenWithGameBackground::update(); + UIDialogScreen::update(); } void ReportFinishScreen::ShowSuggestions() { diff --git a/UI/ReportScreen.h b/UI/ReportScreen.h index c287042dea..8967cac82e 100644 --- a/UI/ReportScreen.h +++ b/UI/ReportScreen.h @@ -33,12 +33,15 @@ enum class ReportingOverallScore : int { INVALID = -1, }; -class ReportScreen : public UIDialogScreenWithGameBackground { +class ReportScreen : public UIDialogScreen { public: ReportScreen(const Path &gamePath); const char *tag() const override { return "Report"; } + // For the screenshotting functionality to work. + ScreenRenderRole renderRole(bool isTop) const override { return ScreenRenderRole::MUST_BE_FIRST | ScreenRenderRole::CAN_BE_BACKGROUND; } + protected: ScreenRenderFlags render(ScreenRenderMode mode) override; void update() override; @@ -60,6 +63,7 @@ protected: UI::TextView *overallDescription_ = nullptr; UI::TextView *crcInfo_ = nullptr; UI::Choice *showCrcButton_ = nullptr; + Path gamePath_; Path screenshotFilename_; ReportingOverallScore overall_ = ReportingOverallScore::INVALID; @@ -73,7 +77,7 @@ protected: bool showCRC_ = false; }; -class ReportFinishScreen : public UIDialogScreenWithGameBackground { +class ReportFinishScreen : public UIDialogScreen { public: ReportFinishScreen(const Path &gamePath, ReportingOverallScore score); @@ -88,6 +92,7 @@ protected: UI::TextView *resultNotice_ = nullptr; UI::LinearLayout *resultItems_ = nullptr; + Path gamePath_; ReportingOverallScore score_; bool setStatus_ = false; };