fix: ignore the termination of a previous game session
Description
At launch, hardKillStaleWineProcesses kills the processes left over by a previous session.
Their exit fires that old session's termination callback, which emits GuestProgramTerminated,
and the new XServerScreen handles it as its own exit. The app goes back to the library while
the new game keeps booting with no screen: endless splash, and abort does nothing.
Repro: abort a game from the splash, close the app right away, then launch a game.
Each setupXEnvironment call now gets a session number, and a termination callback from an
older session is ignored.
Tested on a Quest 3: the bug showed up once in the logs (stale kill, then an exit for the game
being launched). The repro depends on timing, so I couldn't force it again to confirm the fix
on device.
Recording
Type of Change
- Bug fix
- Performance / stability improvement
- Compatibility improvements
- Other (requires prior approval)
Checklist
- If I have access to
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed. - This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
- I have attached a recording of the change.
- I have read and agree to the contribution guidelines in
CONTRIBUTING.md.
Summary by cubic
Fixes a race where leftover processes from a previous game session fired that old session's termination callback, so a newly launched game was treated as exited, the app returned to the library, and the booting game was left with no screen and no working abort.
- Each game launch now gets a session number; termination callbacks from an older session are ignored, including pre-install step callbacks.
Summary by CodeRabbit
- Bug Fixes
- Prevented callbacks from an earlier guest session from interrupting a newer session. Stale termination events no longer trigger errors or end the active session, and stale pre-install callbacks no longer mark installation steps complete or advance the installation process. This helps keep session and installation progress tied to the guest environment currently in progress.