From 847e91c3a8ca2d699cc9ce0df68b733dd5f37b97 Mon Sep 17 00:00:00 2001 From: xbzk Date: Sat, 19 Sep 2026 17:44:12 +0200 Subject: [PATCH] [applet] add post exit cleanups to frontend applets to avoid accumulation (#4457) - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- Maran reported MK8D if one press Plus button 38 times. This could be impacting other games around, but 4442 already quenched the spontaneous accumulation cases, by avoiding multiple event signals. MK8D is an atypical induced example. The reason was a controller applet accumulation, as we had no proper way to keep track and erase child applets on exit. Now we have. Enjoy your Plus button rushing fetish! Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4457 Reviewed-by: lizzie Reviewed-by: MaranBr --- src/core/hle/service/am/frontend/applets.cpp | 15 +++++++++++---- .../service/am/service/library_applet_creator.cpp | 13 ++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/core/hle/service/am/frontend/applets.cpp b/src/core/hle/service/am/frontend/applets.cpp index 407ca10602..d622c7b7a7 100644 --- a/src/core/hle/service/am/frontend/applets.cpp +++ b/src/core/hle/service/am/frontend/applets.cpp @@ -29,6 +29,7 @@ #include "core/hle/service/am/frontend/applet_web_browser.h" #include "core/hle/service/am/frontend/applets.h" #include "core/hle/service/am/service/storage.h" +#include "core/hle/service/am/window_system.h" #include "core/hle/service/sm/sm.h" namespace Service::AM::Frontend { @@ -72,10 +73,16 @@ void FrontendApplet::PushInteractiveOutData(std::shared_ptr storage) { void FrontendApplet::Exit() { auto applet_ = applet.lock(); - - std::scoped_lock lk{applet_->lock}; - applet_->is_completed = true; - applet_->state_changed_event.Signal(system.Kernel()); + { + std::scoped_lock lk{applet_->lock}; + applet_->is_completed = true; + applet_->state_changed_event.Signal(system.Kernel()); + } + if (auto caller_applet = applet_->caller_applet.lock()) { + std::scoped_lock lk{caller_applet->lock}; + std::erase(caller_applet->child_applets, applet_); + } + if (auto* window_system = system.GetAppletManager().GetWindowSystem()) window_system->RequestUpdate(); } FrontendAppletSet::FrontendAppletSet() = default; diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index ce80ce946f..4ee92908b5 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -122,7 +122,10 @@ std::shared_ptr CreateGuestApplet(Core::System& system, auto broker = std::make_shared(system); applet->caller_applet = caller_applet; applet->caller_applet_broker = broker; - caller_applet->child_applets.push_back(applet); + { + std::scoped_lock lk{caller_applet->lock}; + caller_applet->child_applets.push_back(applet); + } window_system.TrackApplet(applet, false); return std::make_shared(system, broker, applet); } @@ -148,10 +151,10 @@ std::shared_ptr CreateFrontendApplet(Core::System& syste applet->caller_applet = caller_applet; applet->caller_applet_broker = storage; applet->frontend = system.GetFrontendAppletHolder().GetApplet(applet, applet_id, mode); - caller_applet->child_applets.push_back(applet); - - window_system.TrackApplet(applet, false); - + { + std::scoped_lock lk{caller_applet->lock}; + caller_applet->child_applets.push_back(applet); + } return std::make_shared(system, storage, applet); }