fix(libSceNpAuth): report an async request as running on its first poll #5322

Merged
lubaxe merged 1 commit from upstream-pr/5322 into main 2026-10-14 01:32:44 +00:00
lubaxe commented 2026-10-13 17:12:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lubaxe on 2026-10-13T17:12:36Z.


What

The async requests completed inside sceNpAuthGetIdTokenV3 and sceNpAuthGetAuthorizationCodeV3, so the first sceNpAuthPollAsync already returned finished. On the console these requests go over the network, so a poll made right after the request still returns running (1).

PPSA06694 (Remnant 2) creates an async request, calls sceNpAuthGetIdTokenV3 and polls at once (Remnant2.exe+0x12e2a0, called from +0x12e97a), during game instance initialisation:

  • When the poll returns running, it polls again on the next tick (+0x12e3ff schedules +0x12e2a0 again).
  • When it returns finished, it calls its login-complete handler (+0x12ecf0), even when the result is an error. That handler sets the active profile from the first local player (+0x1132c0).

At initialisation no local player exists yet, so the profile was set to none and nothing set it again. The main menu waits for the profile, so the title stayed on its logo screen.

The first sceNpAuthPollAsync of a processed async request now returns 1 (running) without writing the result; later polls return 0 with the result, as before. sceNpAuthWaitAsync still returns the result at once.

Tested

  • Windows 11 Pro, Ryzen 7 9800X3D, RTX 5090 (driver 617.42), WinLibs GCC 15.2.0 r7, Release.
  • guest_np_auth: the first poll after sceNpAuthGetIdTokenV3 returns 1 and leaves the result untouched, the next ones return 0 with the signed-out error. On main it fails at the first poll.
  • guest_np_auth, guest_np_auth_authorized_app_code, guest_np_auth_authorized_app_dialog pass.
  • ctest on main 8c772ad3 with this change: 1076 of 1077 passed. The failure is agc_driver_pixel_lds, which also fails on unmodified main on this GPU. Rebased onto main 61b8742b; there agc_driver_graphics, guest_np_auth and agc_driver_vertex_clip_cull_distances pass.
  • PPSA06694 with #5321, #5323 and #5324: with this change the title reaches Create Character in 8 of 8 runs (and 3 of 3 on an earlier main); without it, it stays on the logo screen (1 of 1 here, every run on the earlier main).
  • tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA06694 #5320
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846805116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5322). Originally posted by [lubaxe](https://github.com/lubaxe) on 2026-10-13T17:12:36Z. --- ### What The async requests completed inside `sceNpAuthGetIdTokenV3` and `sceNpAuthGetAuthorizationCodeV3`, so the first `sceNpAuthPollAsync` already returned finished. On the console these requests go over the network, so a poll made right after the request still returns running (1). PPSA06694 (Remnant 2) creates an async request, calls `sceNpAuthGetIdTokenV3` and polls at once (`Remnant2.exe+0x12e2a0`, called from `+0x12e97a`), during game instance initialisation: - When the poll returns running, it polls again on the next tick (`+0x12e3ff` schedules `+0x12e2a0` again). - When it returns finished, it calls its login-complete handler (`+0x12ecf0`), even when the result is an error. That handler sets the active profile from the first local player (`+0x1132c0`). At initialisation no local player exists yet, so the profile was set to none and nothing set it again. The main menu waits for the profile, so the title stayed on its logo screen. The first `sceNpAuthPollAsync` of a processed async request now returns 1 (running) without writing the result; later polls return 0 with the result, as before. `sceNpAuthWaitAsync` still returns the result at once. ### Tested - Windows 11 Pro, Ryzen 7 9800X3D, RTX 5090 (driver 617.42), WinLibs GCC 15.2.0 r7, Release. - `guest_np_auth`: the first poll after `sceNpAuthGetIdTokenV3` returns 1 and leaves the result untouched, the next ones return 0 with the signed-out error. On `main` it fails at the first poll. - `guest_np_auth`, `guest_np_auth_authorized_app_code`, `guest_np_auth_authorized_app_dialog` pass. - `ctest` on `main` 8c772ad3 with this change: 1076 of 1077 passed. The failure is `agc_driver_pixel_lds`, which also fails on unmodified `main` on this GPU. Rebased onto `main` 61b8742b; there `agc_driver_graphics`, `guest_np_auth` and `agc_driver_vertex_clip_cull_distances` pass. - PPSA06694 with #5321, #5323 and #5324: with this change the title reaches Create Character in 8 of 8 runs (and 3 of 3 on an earlier `main`); without it, it stays on the logo screen (1 of 1 here, every run on the earlier `main`). - `tools/check_conventions.py --base origin/main` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA06694 #5320 - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
coltken95 commented 2026-10-13 19:18:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T19:18:24Z.


Tested on Linux x86-64 (Release build), with cb8b0caf7 merged into main 18c438b10:

  • With the PR: guest_np_auth passes.
  • With main's sources and the PR's test: guest_np_auth aborts.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153293231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5322#issuecomment-6153293231). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T19:18:24Z. --- Tested on Linux x86-64 (Release build), with cb8b0caf7 merged into main 18c438b10: - With the PR: `guest_np_auth` passes. - With main's sources and the PR's test: `guest_np_auth` aborts. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5322
No description provided.