Repository navigation
Rosetta direct path: run the guest off the main thread so the game window opens - #425
Merged
Merged
Conversation
…ndow opens A relinked title ran its guest entry on the process main thread, which never returned to the run loop, so DirectDisplayWindow's main-queue window creation never ran and the process never became a GUI app: no window, no Dock icon. - libkernel Aps5StartGuest: when libSceVideoOut is loaded, hand the main thread to its host application and start the guest on a detached thread with the main thread's stack size (>= 8 MiB) and user-interactive QoS; guest TLS and fault reports are per thread already. APS5_ROSETTA_GUEST_ON_MAIN_THREAD=1 keeps the old behaviour; titles without VideoOut are unchanged. - libSceVideoOut DirectHostApplication (fork-only): NSApplication with a regular activation policy (accessory under ANYPS5_UNOBTRUSIVE_WINDOWS), the game's title and icon, a menu bar with Quit, Toggle Full Screen (Ctrl-Cmd-F) and Minimize, then the AppKit run loop. Headless runs only service the main queue. - DirectDisplayWindow: the window opens with VideoOut, titled with the game's title, sized to the output at one point per backing pixel (scaled to fit the screen), centred, full-screen capable, aspect-locked, activated; closing it or quitting ends the game with exit code 0. - rosetta_direct_host_window test: VideoOut opened from a guest thread with the main thread in the host application puts a window on screen (CGWindowList); closing it and quitting each exit 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Aps5StartGuest(libkernel, Rosetta runtime) called the guest entry point on the process main thread, and the guest never returns to the run loop. DirectDisplayWindow (#397) creates its AppKit window + CAMetalLayer withdispatch_async(dispatch_get_main_queue(), ...), so that block never ran. Frames went to the offscreen layer forever, which is why frame capture still saw them. Nothing set up NSApplication either, so the process had no Dock icon and no menu bar. A launched title ran with zero windows (CGWindowList).Fix (Apple x86_64 direct path only; fork-only files or the Darwin runtime)
Aps5StartGuest: ifAps5RunHostApplication_nid_no_patchis loaded (libSceVideoOut), it takes over the main thread and the guest starts on a detached thread. That thread gets the main thread's stack size (at least 8 MiB) and user-interactive QoS. Guest TLS is allocated lazily per thread and the fault handler's alternate stack is per thread, so nothing depends on the main thread (pthread_main_npis unused in the runtime, and thread stacks come frompthread_get_stack*_np). Titles without VideoOut, such as the runtime test fixtures, still run on the main thread.APS5_ROSETTA_GUEST_ON_MAIN_THREAD=1brings back the old behaviour.DirectHostApplication.mm(new, fork-only): sets upNSApplication. The activation policy is regular, or accessory underANYPS5_UNOBTRUSIVE_WINDOWS. The title and icon0 come from the app metadata, read on the main thread before the guest starts. The menu bar has Hide, Quit (Cmd-Q), Toggle Full Screen (Ctrl-Cmd-F), Minimize and Zoom. Then the AppKit run loop starts. A quit that arrives before the window exists ends the game.ANYPS5_ROSETTA_HEADLESS=1only services the main queue.Ensure). It is now titled with the game's title and sized to the output at one point per backing pixel, scaled to fit the screen, so the drawable is Retina-sized. It is centred, aspect-locked, full-screen capable (green button / Ctrl-Cmd-F) and activated ([NSApp activate]on macOS 14+). Closing the window, or Cmd-Q (the window delegate turns it into a close request), ends the game with exit code 0, and the launcher forwards that exit.WindowConfiguration::gameWindow(centre,FullScreenPrimary, content aspect ratio). Existing callers are unchanged.Evidence (reference title through
bin/anyps5_rosetta_run, run the way MacPS runs it)screencapture -l <id>) show the game's "Choose Your Display Options" screen in the window from about 45 s after it opened.terminate:path as Cmd-Q) logged[videoout] the game window was closed: ending the game. The eboot was gone 0.23 s later, withguest_exitexit_code 0 and launcher exit 0.rosetta_direct_host_windowtest (x86_64): it opens VideoOut from a guest thread while the main thread is in the host application. It checks that a window owned by the process is on screen (CGWindowList, about 0.12 s), that the title, full-screen behaviour, activation policy and Quit / Toggle Full Screen items are right, and that closing the window and quitting each exit 0 (checked in child processes). It passes under ctest (unobtrusive) and when run directly (default etiquette).ctest -L rosetta(threads, fault, launcher smoke, launcher tests, lib binds) androsetta_direct_graphicspass.Not covered: the full-screen toggle was not exercised on the title, only its menu item and the window behaviour. Input in the window is unchanged; separate work covers it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj