Xbox Cloud Gaming app for PS5 Homebrew
C
Free the decoded images before opening the browser
Rafael Abud Ferreirac7dceab6e8f2
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cppindex 709e978..631bfd5 100644--- a/src/app/ps5_main.cpp+++ b/src/app/ps5_main.cpp@@ -693,6 +693,9 @@ int main(int argc, char** argv) {case ui::Action::Retry: g_command = kSignIn; break;case ui::Action::CancelLaunch: g_cancel = true; break;case ui::Action::OpenUrl:+ // The browser is a heavy process next to this app: give it+ // the decoded images (up to 160 MB; they come back from disk).+ g_images->clear();platform::openUrl(ev.url); // the result is loggedbreak;case ui::Action::SettingsChanged: {diff --git a/src/ui/image_cache.cpp b/src/ui/image_cache.cppindex 85e4260..5adf9cb 100644--- a/src/ui/image_cache.cpp+++ b/src/ui/image_cache.cpp@@ -103,6 +103,15 @@ std::shared_ptr<const Image> ImageCache::get(const std::string& url, int w, intreturn e.image;}+void ImageCache::clear() {+ std::lock_guard<std::mutex> lock(mutex_);+ size_t freed = bytes_;+ for (auto it = entries_.begin(); it != entries_.end();)+ it = it->second.loading ? std::next(it) : entries_.erase(it);+ bytes_ = 0;+ XC_LOGI("image cache: %zu MB freed", freed >> 20);+}+void ImageCache::evict() {// Caller holds mutex_.while (bytes_ > budget_) {diff --git a/src/ui/image_cache.h b/src/ui/image_cache.hindex 6cd9e89..f82900d 100644--- a/src/ui/image_cache.h+++ b/src/ui/image_cache.h@@ -37,6 +37,9 @@ public:// The image scaled to w x h, or nullptr while it loads (or if it failed).std::shared_ptr<const Image> get(const std::string& url, int w, int h);+ // Drops every decoded image (they reload from disk on demand): memory for+ // another process, such as the web browser.+ void clear();private:struct Entry {