Skip to content

front_mac: enter fullscreen once the app is active and on the active Space - #665

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:fullscreen-after-space
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:fullscreen-after-space

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

What and why

A Mac game started with DM_FULLSCREEN=1 from an app that is itself in macOS fullscreen (the NX2Apple launcher's console mode) comes up as a window. The owner of NX2Apple, @LNPANDY, reported it: "using a full screen app to launch another full-screen app will fail, it will automatically switch to windowed mode".

Cause (the state is confirmed, the refusal itself is not): the launcher lives in its own fullscreen Space, so opening the game makes macOS leave that Space. front_run asked for fullscreen on the next run-loop turn. A harness of two small apps making the same request, with the launcher and the game window on the same display, logged isOnActiveSpace 0 at that moment, and the Space change arrived 0.3 to 0.5 s later. AppKit can refuse a request made then. It reports a refusal only to the window delegate (windowDidFailToEnterFullScreen:), there is no NSWindowDidFailToEnterFullScreenNotification on macOS.

Change, in dm/host/front_mac.m only:

  • The request waits until the app is active and the window is on the active Space (NSApplicationDidBecomeActiveNotification or NSWorkspaceActiveSpaceDidChangeNotification, whichever comes last).
  • A small window delegate repeats a refused request once and logs fullscreen was refused.
  • It stops as soon as the player toggles fullscreen themselves. No loops, no timers. g_fullscreen and screen_match_apply are unchanged.

The alternative is a borderless screen-sized window with no Space of its own, as many games use. The retry comes first because it keeps native fullscreen, which screen_match_apply relies on to switch the screen's refresh rate.

A separate observation, not changed here: with two displays the game's window did not always open on the display of the launcher (twice on the other one, once on the same). It opens on NSScreen.mainScreen of a process that is not active yet. That is a follow-up.

Reference entry: docs/reference/frame-rate.md, symptom index updated.

Checked

  • Tests: make -C dm/host GAME=010015100B514000 builds, make -C dm/host/tests GAME=010015100B514000 run passes, dm/tools/lint_python.py 0 new, dm/tools/tests/test_docs.py passes.
  • Games run: none with the new code. The failure itself did not reproduce here: in the harness the old request was taken every time, even at isOnActiveSpace 0 (baseline logs: toggleFullScreen: active=1 onActiveSpace=0, then entered full screen). With the change, the harness waited for the Space change and then entered fullscreen (toggleFullScreen: active=1 onActiveSpace=1). The host code itself was only built, not run in a Space transition. The reporter or anyone with the console mode should confirm.
  • Devices and OS: Apple silicon Mac, macOS 27, a built-in display and an external one, "Displays have separate Spaces" on.
  • regress.py impact HEAD~1..HEAD names Breath of the Wild, Pokemon Scarlet and Tears of the Kingdom as affected and Hades as broad, only because every call from front_run is followed into the NVN loader. The change is in the DM_FULLSCREEN branch of the window setup, which a headless regress.py check run never takes (no DM_WINDOW), so a check would not reach it and none was run.

Docs

  • The finding is in its docs/reference/frame-rate.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • No game files, keys or data extracted from a game in the change or the attachments

…on the active Space, repeat a refused request once

A game opened from an app that is in fullscreen stayed a window. The request is now made when the app is active and the window is on the active Space, and repeated once when AppKit reports a refusal.
v0lumehi added a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
… fullscreen once it is on the active Space

Forwarded patch for dm/host/front_mac.m and its reference entry.
v0lumehi added a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
… fullscreen once it is on the active Space

Forwarded patch for dm/host/front_mac.m and its reference entry.
@LNPANDY

LNPANDY commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Confirming from the reporter's side (NX2Apple): the failure is real, and the fix works.

The failure reproduces. A real game build (Hades II) started from the launcher's console mode (the launcher itself fullscreen) came up windowed in 4/4 launches, with DM_FULLSCREEN=1 confirmed present in the host's environment. The host log's drawable lines show the enter starting and rolling back: 2560x1440 (the initial 1280x720 pt window) → 2560x1504 → 3024x1898 (full screen size) → 3024x1834 → 2560x1440 again. So on this machine the request is not only dropped — the enter starts, AppKit rolls it back, and no DidEnterFullScreen fires on the way.

The fix works. With this PR's code carried in the fork and the same game started the same way, the deferred request was taken the first time: the drawables go 2560x1440 → 2560x1504 → 3024x1898 and stay there, and no refusal was logged.

One note from testing an alternative first: a bounded interval retry (0.5 s apart, stopping at DidEnterFullScreenNotification) also fixes it, but the player sees the rolled-back attempt first. This PR's wait-for-the-right-state form enters without one, so we preferred it and carry it as patches/0027 (Upstream-Status: forwarded seedds/nxnative#665), to be dropped at the next upstream bump when this merges.

v0lumehi added a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
… fullscreen once it is on the active Space

Forwarded patch for dm/host/front_mac.m and its reference entry.
LNPANDY added a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
…ive Space

Console mode launches the game while the launcher's own full screen Space is
front, and the window then comes up in the middle of that Space switch: the
startup toggleFullScreen is refused or rolled back and the game stays windowed
although DM_FULLSCREEN=1 reached it. Carries seedds/nxnative#665 by v0lumehi:
the request waits for the app to be active with its window on the active Space,
and a refused one is repeated once through the window delegate. Validated on a
real game build started from a fullscreen parent app, which the upstream PR had
only built: the deferred request is taken the first time and the window enters
full screen with no rolled back attempt and holds.
LNPANDY added a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
…ive Space

Console mode launches the game while the launcher's own full screen Space is
front, and the window then comes up in the middle of that Space switch: the
startup toggleFullScreen is refused or rolled back and the game stays windowed
although DM_FULLSCREEN=1 reached it. Carries seedds/nxnative#665 by v0lumehi:
the request waits for the app to be active with its window on the active Space,
and a refused one is repeated once through the window delegate. Validated on a
real game build started from a fullscreen parent app, which the upstream PR had
only built: the deferred request is taken the first time and the window enters
full screen with no rolled back attempt and holds.
LNPANDY pushed a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
… fullscreen once it is on the active Space

Forwarded patch for dm/host/front_mac.m and its reference entry.
v0lumehi added a commit to LNPANDY/NX2Apple that referenced this pull request Oct 29, 2026
Carry seedds/nxnative#665: fullscreen for a game opened from a fullscreen app
seedds added a commit that referenced this pull request Oct 31, 2026
A game launched from another fullscreen app could request fullscreen before
its window reached the active Space, causing AppKit to roll the entry back.
Wait for app activation and window Space readiness before making the request,
and allow one repeat when AppKit reports a refused startup attempt.

Track the outstanding startup request and retire its failure handler after
successful entry or player takeover while waiting. A later refused manual
entry can no longer restart startup handling. Keep native fullscreen and the
existing screen refresh-rate matching behavior.

The reporter reproduced the original failure on four of four Hades II
launches and confirmed the readiness fix. The revised callbacks pass all 11
lifecycle harness cases; the original PR fails two. Mac host build, host unit
tests, documentation tests and targeted LLVM 23 clang-tidy pass. Regression
risk is low and confined to fullscreen startup, so no game regression runs
were performed; the revised lifecycle still needs native launcher testing.

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Landed on main in 3d247f35, with v0lumehi credited as co-author for the fullscreen readiness fix.

The landing also fixes the startup handler's lifecycle: refusal recovery applies only to an outstanding automatic startup request, and successful entry or player takeover while startup is waiting retires the handler. A later refused manual fullscreen request can no longer restart startup handling. All 11 lifecycle harness cases pass, along with the Mac host build, host tests, documentation tests, and targeted clang-tidy check.

Closing as landed. Thanks for the fix and the reporter's verification.

@seedds seedds closed this Oct 31, 2026
ZhaowTao added a commit to ZhaowTao/nxnative that referenced this pull request Nov 7, 2026
…off (Persona 5 Royal)

A program's shader libraries are loaded in the background as soon as the game makes
the program (nvn_mtl.m mtl_prog_prefetch, from nvnProgramSetShaders), whether or not a
draw uses them. It had a switch, DM_NVN_PREFETCH=0, but no front end could offer it:
dm/ios/Sources/player_env.h filters the DM_NVN_ prefix as a diagnostic, so it cannot be
saved from Documents/env.txt either.

On iOS a loaded library is a mapping the process keeps for good: NvShader holds the
MTLFunction, the function holds the library, and the shader table keeps the shader by
key. A game with a very large shader tree fills the process's mapping limit that way and
is ended with vnode-limit. Persona 5 Royal is 24,826 pipelines, 88,792 metallib and
30,646 json (119,439 files, 1.3 GB) and was ended after 60-100 s in every configuration
tried on an iPhone 17 Pro, while Breath of the Wild (4,829 pipelines) and Rhythm Heaven
Groove (100 metallib) run for hours on the same device and build
(LNPANDY/NX2Apple#665, seedds#666).

Off, one run held 30 fps for 34 minutes: 61,200 presents, p50 33.34 ms, 1,773 MiB, 410,000
audio callbacks with no underrun, no crash; with it on the same build aborted in a
prefetch worker at 5 min 33 s.

- settings.tsv gains the row for every NVN game, in Performance, with the iOS default
  from the profile and the Mac default on (the shape DM_PSO_MTL4 has).
- player_env.h carries the exception DM_NVN_ENC_THREAD already has, so a player build
  keeps the launcher's value.
- game.py takes the profile key nvn_prefetch (on / off) and writes DM_GAME_NVN_PREFETCH,
  which settings.py resolves as the iOS default.
- Persona 5 Royal's profile sets it off, so a player never has to find the row.
- The test covers the row's graphics API, both platforms' defaults and the Mac.

Off bounds nothing by itself: the mappings still grow, from what is drawn instead of what
is in the program, and a long session still ends somewhere. The prefetch staying unbounded
is seedds#665's subject.
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
)

A game launched from another fullscreen app could request fullscreen before
its window reached the active Space, causing AppKit to roll the entry back.
Wait for app activation and window Space readiness before making the request,
and allow one repeat when AppKit reports a refused startup attempt.

Track the outstanding startup request and retire its failure handler after
successful entry or player takeover while waiting. A later refused manual
entry can no longer restart startup handling. Keep native fullscreen and the
existing screen refresh-rate matching behavior.

The reporter reproduced the original failure on four of four Hades II
launches and confirmed the readiness fix. The revised callbacks pass all 11
lifecycle harness cases; the original PR fails two. Mac host build, host unit
tests, documentation tests and targeted LLVM 23 clang-tidy pass. Regression
risk is low and confined to fullscreen startup, so no game regression runs
were performed; the revised lifecycle still needs native launcher testing.

Co-authored-by: v0lumehi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants