From ee2d55ee497c9467c8df82515165a21eac13fff5 Mon Sep 17 00:00:00 2001 From: Alex <78863999+Sssnowyyy@users.noreply.github.com> Date: Sat, 31 Oct 2026 10:54:52 -0400 Subject: boot Pokopia past audio init (Switch 2 heap limits, aud:u 1, stpl:u) (#77) * game_list: don't free the worker while it is processing events OnPopulatingCompleted runs a nested event loop from inside GameListWorker::ProcessEvents. If the directory watcher fires there, the repopulate destroys the worker while ProcessEvents is still on the stack and the next lock hits a freed mutex. Stop the worker synchronously but free it with deleteLater, and stop ProcessEvents once it has been replaced. Assisted-by: Claude Opus 5.5 (code changes, debugging and commit message) * Fix Switch 2 heap limits and game list reloads during emulation - SetHeapSize rejected heaps of 8 GiB or more (Switch 1's MainMemorySizeMax), so Switch 2 titles that size their heap from the 12 GiB layout (Pokopia asks for 9.5 GiB) got ResultInvalidSize and aborted with 2001-0101. Allow up to the memory the active layout provides. - Grow the 39-bit heap region from 8 to 16 GiB so such a heap fits. - Skip watcher-driven game list reloads while a game runs: Repopulate calls CreateFactories, which replaces content providers the running game reads (segfault in ContentProviderUnion::GetEntry). Stopping emulation already repopulates the list. Assisted-by: Claude Opus 5.5 (code changes, debugging and commit message) * nx2: answer aud:u 1 with an IAudioOutManager nn::audio::OpenAudioOut gets its manager from aud:u command 1 and calls OpenAudioOut through slot 1 of the returned object. The auto stub returned no object, so Pokopia jumped through a null vtable 5 s into boot and never got past its first frame. Assisted-by: Claude Opus 5.5 (code changes, debugging and commit message) * nx2: add a stpl:u (stream play) stub with a user service nn::streamplay::detail::GetUserService opens a session with stpl:u 0 and attaches a system event to the handle command 300 returns. The generic missing-service stub returned no session, so Pokopia's first nn::streamplay call jumped through null right after audio setup. Assisted-by: Claude Opus 5.5 (code changes, debugging and commit message) --- src/qt_common/game_list/worker.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/qt_common/game_list/worker.cpp') diff --git a/src/qt_common/game_list/worker.cpp b/src/qt_common/game_list/worker.cpp index 14afe2f276..d18f84089a 100644 --- a/src/qt_common/game_list/worker.cpp +++ b/src/qt_common/game_list/worker.cpp @@ -313,12 +313,18 @@ GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs_, GameListWorker::~GameListWorker() { this->disconnect(); - stop_requested.store(true); - processing_completed.Wait(); + Stop(); +} + +void GameListWorker::Stop() { + if (!stop_requested.exchange(true)) { + processing_completed.Wait(); + } } void GameListWorker::ProcessEvents(GameListModel* model) { - while (true) { + // An event may spin a nested event loop that replaces this worker, in which case stop. + while (model->current_worker.get() == this) { std::function func; { // Lock queue to protect concurrent modification. -- cgit v1.2.3