Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Log each step of quitting Playden

Leonardo Lobato524f4dc5252a
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 7bd2e2c..d860395 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -38,15 +38,22 @@ void Controller::Shutdown() {
phase_!=Phase::ClearLibrary && phase_!=Phase::ClearOrganization && phase_!=Phase::SignOut) SignOut(false);
}
begin_after_clear_=false;
- if(library_service_) {
- library_service_->Shutdown();
- library_->Tick();AdvanceClear();
- }
- if(persistence_) { persistence_->FlushAndShutdown();AdvanceOrganizationClear(); }
- if(app_details_) app_details_->Shutdown();
- if(installs_) installs_->Shutdown();
- if(cloud_) cloud_->Shutdown();
- if(runtime_) runtime_->Shutdown();
+ // Each step is logged before it starts and with its time after, so a hang shows where it stopped.
+ const auto step = [this](const char* name, const auto& work) {
+ if (shutdown_log_) shutdown_log_(std::string("shutdown ") + name + " start");
+ const auto started = std::chrono::steady_clock::now();
+ work();
+ if (shutdown_log_)
+ shutdown_log_(std::string("shutdown ") + name + " ms=" +
+ std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - started).count()));
+ };
+ if(library_service_) step("library", [&] { library_service_->Shutdown(); library_->Tick(); AdvanceClear(); });
+ if(persistence_) step("persistence", [&] { persistence_->FlushAndShutdown(); AdvanceOrganizationClear(); });
+ if(app_details_) step("details", [&] { app_details_->Shutdown(); });
+ if(installs_) step("installs", [&] { installs_->Shutdown(); });
+ if(cloud_) step("cloud", [&] { cloud_->Shutdown(); });
+ if(runtime_) step("runtime", [&] { runtime_->Shutdown(); });
service_.reset();
persistence_.reset();
library_.reset();
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index 4d983e9..7dbbb4f 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -38,6 +38,8 @@ class Controller {
void SetStoreDetails(steam::StoreDetailsService* store_details) { store_details_ = store_details; }
// Playden's own update: the controller passes the player's requests on and shows its state.
void SetSelfUpdate(update::UpdateService* self_update) { self_update_ = self_update; }
+ // Receives one line per shutdown step with how long it took, so a quit that hangs names the step.
+ void SetShutdownLog(std::function<void(const std::string&)> log) { shutdown_log_ = std::move(log); }
// Counts changes to the account's Steam licenses (steam::CmLicenseChanges): the library refreshes
// once they settle for `delay`, so a game added on another device shows up.
void SetLicenseChanges(std::function<std::uint64_t()> changes,
@@ -73,6 +75,7 @@ class Controller {
void TickInstalls();
void TickSelfUpdate();
void TickLicenseChanges();
+ std::function<void(const std::string&)> shutdown_log_;
std::function<std::uint64_t()> license_changes_;
std::chrono::steady_clock::duration license_refresh_delay_{};
std::optional<std::uint64_t> seen_license_changes_;
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index 63d4ea8..7a94af5 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -568,6 +568,7 @@ int main() {
services.SetSelfUpdate(&self_update);
// A game bought or added to the library elsewhere: Steam pushes the new license list.
services.SetLicenseChanges([steam_cm] { return playden::steam::CmLicenseChanges(*steam_cm); });
+ services.SetShutdownLog([](const std::string& line) { playden::app::AppendLogLine(log_root, "launch.log", line); });
#endif
#if PLAYDEN_UI_SIMULATION
playden::homebrew::Render renderer(paths.assets_root);
@@ -710,9 +711,13 @@ int main() {
pad.tick(1.0F / 60.0F);
}
#if !PLAYDEN_UI_SIMULATION
+ playden::app::AppendLogLine(log_root, "launch.log", "quit requested");
services.Shutdown();
+ playden::app::AppendLogLine(log_root, "launch.log", "shutdown artwork start");
artwork.Shutdown();
+ playden::app::AppendLogLine(log_root, "launch.log", "shutdown self-update start");
self_update.Shutdown();
+ playden::app::AppendLogLine(log_root, "launch.log", "shutdown done");
if (self_update.Snapshot().restart_requested || self_update.Snapshot().rollback_requested) {
// The relaunch payload starts first: it waits until Playden has gone, then opens it again.
std::string elf, error;