feat(libSceNpManager): register NP state callbacks and report signed-out from sceNpCheckCallback #6121
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6121"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T22:46:45Z.
What
#1277 reports that Minecraft Preview (PPSA19639) needs this for stop 2: the title registers an NP state callback and expects
sceNpCheckCallbackto deliver SIGNED_OUT once. This PR is the NpManager part of that stop. Onmain,sceNpRegisterStateCallbackandsceNpRegisterStateCallbackAstore nothing (the A form always returns 1), both unregister calls always return 0, andsceNpCheckCallbackdoes nothing.Registration follows shadPS4 np_manager.cpp @15abf68c (
RegisterStateCallbackAandUnregisterStateCallbackAByIdL857-L901, the legacy pair L981-L1005,ORBIS_NP_STATE_CALLBACK_MAX = 8at L36):sceNpRegisterStateCallbackA(cb, ud)keeps up to 8 callbacks and returns the slot plus 1. A null callback returnsINVALID_ARGUMENT(0x80550003), a callback that is already registeredCALLBACK_ALREADY_REGISTERED(0x80550008), and a ninth oneCALLBACK_MAX(0x8055001D, np_error.h L38).sceNpUnregisterStateCallbackA(id)returnsINVALID_ARGUMENTfor an id outside 1..8 andCALLBACK_NOT_REGISTERED(0x80550009) for an empty slot.sceNpRegisterStateCallback(cb, ud)is the legacy formvoid(int userId, uint32_t state, NpId* npId, void* ud)with one slot: a null callback isINVALID_ARGUMENT, a second registrationCALLBACK_ALREADY_REGISTERED.sceNpUnregisterStateCallbackwith nothing registered returnsCALLBACK_NOT_REGISTERED.APS5_VABI.Delivery:
sceNpCheckCallbackcopies the registrations and clears the pending flags under the mutex. After releasing it, on the calling thread, it calls the A form ascb(0x10000000, SIGNED_OUT = 1, ud)and the legacy form ascb(0x10000000, 1, nullptr, ud). 0x10000000 isUSER_SERVICE_INITIAL_USER_IDfromprx/libSceUserService/UserService.hpp.NpRegisterStateCallbackA(L4021-L4034) marks the registration pending, andNpCheckCallback(L3959-L3974) delivers it once. KytyPS5 never calls the legacy callback: itsNpRegisterStateCallbackandNpUnregisterStateCallback(L4009-L4019) do nothing.has_np_idonly forSignedIn(L823) and passesnullptrotherwise (L938-L940).DispatchPendingNpStateCallbacksalso calls it once with UNAVAILABLE for the same event (L922-L931, L959-L961), it gets no initial call.shadPS4 queues SIGNED_OUT from the user service login event and delivers it from
sceNpCheckCallback(DispatchPendingNpStateCallbacksL903-L962). That difference, the reachability difference, the unregister race and the fact that the console's timing and errors are not measured are recorded indocs/dev/debt/libSceNpManager.md.Test:
GuestNpManager.cpp(guest_np_manager) now also checks both forms withAPS5_VABIcallbacks that record userId, state, npId and userdata:sceNpUnregisterStateCallbackAon its own id gets 0, and its id is then empty.npId, and a second check makes none. Unregistering returns 0, and a second unregister returns 0x80550009.guest_np_reachabilitystill passes.Need on current
main: the only evidence for stop 2 is the #1277 reporter's local patch onmaind4c196c2, and a 2026-10-14 comment there notes that stop 2 is not covered by #5133. Minecraft (PPSA17221), which shares the engine, is reported to run onmainwithout this change. The change affects every title that registers a state callback: it now gets one SIGNED_OUT call that it never got before. I have not run either title, so this PR does not confirm the stop on currentmain. @ddrsilva, or anyone who runs PPSA17221: could you run this branch with the Preview and with PPSA17221 before merge? I will add the result to Tested.Tested
Windows Server 2025 (10.0.26100), WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release,
BUILD_TESTING=ON, onmain922abe6a4.main'sExport.cpp:guest_np_manageraborts (0xc0000409) withNpManager: duplicate state callback, in 2 of 2 runs on922abe6a4.153d5d469, the new checks also failed against three broken variants of this change. If unregistering clears the wrong slot, the test aborts withunregistering one id removed another callback. If the reachability callback is called with the state event, it aborts withthe reachability callback was called. If the callbacks are called with the mutex held, the self-unregistering callback deadlocks, and the test times out.922abe6a4:guest_np_managerandguest_np_reachabilitypass in 3 of 3 runs, each in under 0.75 s on a host running parallel builds.ctest -R guest_np_(9 tests, includingguest_np_auth,guest_np_partner,guest_np_web_api2andguest_np_session_signaling): 9 of 9 passed in 3 runs on922abe6a4.tools/check_conventions.py --base upstream/main(the tools frommain): passed.git merge-treeof this branch (on922abe6a4) with each of the four open PRs that change the same files adds no conflict.46541633,sceNpSetContentRestriction,sceNpRegisterGamePresenceCallback) and #2852 (head 3351d1f1,sceNpGetUserIdByAccountId) change other hunks ofExport.cppandGuestNpManager.cpp. #6023 also adds entries next to ours indocs/dev/debt/libSceNpManager.md, which merge cleanly.Export.cpp,GuestNpManager.cpp,libSceNpManager/CMakeLists.txtand the same debt file.5fa62e59) movesGuestNpManager.cpptocore/libs/tests/services/andGuestNpReachability.cpptocore/libs/tests/networking/, and editslibSceNpManager/CMakeLists.txt. git follows the move, and the merged tree has this PR's test changes at the new path. #6044's conflicts are inlibSceAgcDriver/CMakeLists.txtandlibc/CMakeLists.txt, and it has them withmainalone.153d5d469,guest_np_managerandguest_np_reachabilitywere built and passed on this branch merged with #6023 and #6056, and on this branch merged with #6023 and #2852. #2852 conflicts withmainonly indocs/dev/TechnicalDebt.md, and with #6056 inGuestNpManager.cpp; this PR changes neither conflict.Not tested: Linux, macOS, titles.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:15:01Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/tests/GuestNpManager.cppcore/libs/prx/libSceNpManager/Export.cppdocs/dev/debt/libSceNpManager.mdImported from boykopovar/AnyPS5. Originally posted by isnisk on 2026-10-15T14:50:21Z.
Checked on Linux: Ubuntu 26.04 (WSL2), GCC 15.2.0, Release, this head (
9f96444c4) merged ontomain489466d3f(clean merge).guest_np_manager,guest_np_reachabilityand the other 7guest_np_*tests pass, 3 rounds; no warnings from the changed files.main'sExport.cpp, the new test kept):guest_np_manageraborts 3 of 3 withNpManager: duplicate state callback, as on Windows.check_conventions.py --base origin/mainpasses.Not checked: macOS, the titles.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by ddrsilva on 2026-10-15T15:36:12Z.
Preview check for head
9f96444c4a511d64fb7efd184dafe12de3fa66b9: Windows 11 Pro 26200, WinLibs MinGW-w64 GCC 15.2, Minecraft Preview 1.21.40.22 (PPSA19639), RTX 2080 Ti, 1920x1080 / 32 chunks.I built the complete
libSceNpManager/Export.cppfrom this head unchanged, using the PR's headers, and substituted that module in an isolated copy of my existing working Minecraft integration. Preview reached its title screen, loaded the saved world and entered rendered gameplay without a crash or NP-related stop. The loaded-module path/hash were checked. A read-only snapshot of the PR module's state showed one registered A-form guest callback with its pending flag cleared, consistent with it being processed bysceNpCheckCallback; this is not a callback entry/return trace.The parent control also entered gameplay. I built the parent revision's complete NP module (
922abe6a4) and ran it with the same other 120 modules, fixture and launch flags. Therefore I cannot reproduce the original stop 2 in this configuration or claim that this PR newly unblocks Preview. The useful result is no observed Preview world-entry regression with the proposed callback behavior.The PR's
GuestNpManagerandGuestNpReachabilitytests pass three runs each. Keeping the new tests and using the parent's module failsGuestNpManagerwithNpManager: duplicate state callback(0xc0000409); reachability still passes.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:30:20Z.
Checked the state callback registration (8 slots, legacy single slot, error codes vs shadPS4), delivery from
sceNpCheckCallbackoutside the mutex, self-unregistering callbacks and the debt entry.guest_np_managerpasses with the change and fails without it; scoped ctest (36 tests) green on this head merged onto main. Third-party runs (Linux, Preview) noted in the thread. Merging.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:09:29Z.
I have a small offline-profile follow-up for issue #1794 that adds
sceNpGetAccountIdAand alignssceUserServiceGetNpAccountIdto a fixed local account ID.tools/pr_overlap.pyreports a merge conflict inlibSceNpManager/Export.cppat the shared include block, although the functions are otherwise distinct. Do you have a preferred merge order? I can declare a dependency and rebase after yours lands.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:15:16Z.
I adjusted the include placement; the latest
pr_overlap.pyrun no longer reports a conflict with #6121. No dependency or merge order is needed for the current diff.