feat(libSceNpWebApi): add the user-id context, pool stats and extended push event exports #9920
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9920"
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 ntamas94 on 2026-10-22T21:51:15Z.
What
Builds on #9797 (user contexts, requests and push event callbacks) and adds the six exports that remain missing and that the measured PS4 titles import:
sceNpWebApiCreateContextA(CUSA04865, CUSA12435),sceNpWebApiGetMemoryPoolStats,sceNpWebApiCreateExtdPushEventFilter,sceNpWebApiDeleteExtdPushEventFilter,sceNpWebApiRegisterExtdPushEventCallbackAandsceNpWebApiUnregisterExtdPushEventCallback(CUSA04865). The return values follow a PS4 Pro on firmware 10.71 with no PSN sign-in:sceNpWebApiCreateContextAgives 0x80552902 for a negative user, 0x80552903 for an unknown library context, 0x80960105 for a user that is not signed in, the samelibCtxId << 16 | nid assceNpWebApiCreateContextfor the initial user (the two share the user context, so the second call gives 0x8055290A);sceNpWebApiGetMemoryPoolStatsreports the pool size; an extended filter needs a signed-in user (0x80552910), so the register, unregister and delete calls answer 0x8055291C or 0x8055291D. The user-context creation of #9797 moves into a shared helper so both entry points use it. The in-use pool bytes the console reports, the unmeasured orderings and the guessed error names are recorded indocs/dev/debt/libSceNpWebApi.md. The guest test gains a section for the six exports.Tested
Windows 11:
guest_np_web_apipassed on the final head (02dc3f2). The values were measured on a PS4 Pro (firmware 10.71, offline, no request sent) with a homebrew probe; the same probe compiled against this branch on the host gives the same return values on the 24 rows that cover these exports andsceNpWebApiDeleteContextfrom #9797. Not run with a title.Refresh — 2026-11-03 (Codex, AI-assisted): Merged main
086c0686c8, retaining both the new response tests/constants and this PR's console-measured exports and tests. MinGW-w64 GCC 15.2 syntax-only compilation passes for Export.cpp and GuestNpWebApi.cpp; conventions and whitespace checks pass. No new linked runtime/public_headers run on this merged head.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:49:01Z.
Review: APPROVED
Reviewed exact head
02dc3f2fd4f1b79cd5b66844a0e12092c31cb6baas the declared stack on #9797. The six added exports and the shared context helper are covered byguest_np_web_api; the PS4 Pro firmware 10.71 probe values are reported separately from host comparison and no PS5/title result is claimed. Unmeasured pool usage, ordering and guessed error names are documented in debt. Current-main whitespace and conventions pass; the branch merges cleanly, with no intervening main commits touching the changed paths. Hosted product jobs are skipped; I did not rerun C++ tests locally. The open #9797 dependency remains required before merge, as declared.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T10:54:06Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The six exports build and
guest_np_web_apipasses, but the merged tree fails thepublic_headerstest becauseExport.cppredeclaressceNpWebApiCreateServicePushEventFilter.What I ran
bdf05fc6015b0b60466f1f763b8d112e390f79f0main:d2b15d8802f7fff387c523910355387b300d3911mainmerged with the PR head (--no-ff) in a clean worktree. The merge had no conflicts.Results
maingit diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.)libSceNpWebApi,guest_np_web_api_testsguest_np_web_apipublic_headers(merged tree)public_headers(main)guest_np_web_api+public_headerswith onlyExport.cpp:148deletedpublic_headerson the merged treeNegative control
I restored
Export.cppandinclude/Api.hppfrommainand kept the new test.guest_np_web_api_teststhen fails to compile:NpWebApiMemoryPoolStats,sceNpWebApiGetMemoryPoolStats,sceNpWebApiCreateContextA,sceNpWebApiCreateExtdPushEventFilter,sceNpWebApiRegisterExtdPushEventCallbackAandsceNpWebApiUnregisterExtdPushEventCallbackare undeclared. So the new section depends on the production change. Because the test cannot be built againstmain, this control cannot check individual return values.Findings
Blocking
public_headersfails because of a duplicate declaration.core/libs/prx/libSceNpWebApi/Export.cpp:148forward-declaressceNpWebApiCreateServicePushEventFilter, which is already declared ininclude/Api.hpp:28. Since #10706,public_headersrequires each export to be declared exactly once, in the library's public header, and it rejects this. This is the rule oneandonlydean pointed to earlier in this thread. The merge commit moved the six new declarations intoApi.hppbut left this one inExport.cpp. Fix: delete line 148.Export.cppalready sees the declaration throughApi.hpp. I checked that with that one line removed, the target builds and bothguest_np_web_apiandpublic_headerspass. The author's comment reportsguest_np_web_apiandcheck_conventions.pypassing on this head, but neither runs this audit.Non-blocking
sceNpWebApiRegisterExtdPushEventCallbackA.Export.cpp:284-292ignorescallback, and the debt entry says "a null callback is not checked". BunnyFl reported in this thread that the PS5 13.42 module returns0x80552902(INVALID_ARGUMENT) for a null callback before it looks at the user context or the filter. That data point has no reply yet. Either check!callbackfirst and add a test row, or note the PS5 result in the debt entry so the open question is not lost. I did not verify their measurement.sceNpWebApiCreateContextAreturnsINVALID_LIB_CONTEXT_IDfor every unknown library context, but only-1was measured. For a positive unknown id, the rest of the library returnsLIB_CONTEXT_NOT_FOUND. The debt entry records this, so it is not blocking. The test row with0x7fff + 1pins an unmeasured value, though. A comment-free way to keep the test honest is to test only-1there.Not verified
guest_np_web_apiandpublic_headers(the audit, not thepublic_headers_compile_*batches, which depend on the audit fixture).To get this to a good state
core/libs/prx/libSceNpWebApi/Export.cpp:148.ctest -R '^(guest_np_web_api|public_headers)$'on the new head, and post the result.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T21:16:37Z.
Review: APPROVED
Re-checked — approved
Commit
30556bb48bremoves the duplicate forward declaration ofsceNpWebApiCreateServicePushEventFilter, andpublic_headersnow passes on the merged tree. The later merge ofmain(3c783ecec2) garbled one character in the debt doc; that is non-blocking.What changed since my last review
30556bb48bdeletes the in-file forward declaration inExport.cpp.Export.cppgets the declaration frominclude/Api.hpp.3c783ecec2mergesmainat086c0686c8. Commitsf6f6e77287and02dc3f2fd4are unchanged. The six exports, the test section and the debt entry are the same as in the last review, apart from the encoding change below.public_headerstests on this merged head. Their earlier comment reportsguest_np_web_api,guest_np_web_api_initializeandpublic_headerspassing on30556bb48b(Windows, MinGW-w64 GCC 15.2).What I ran
3c783ecec230fa3a04bec38618b19f05fc6d39c7main:086c0686c8adff3ee648fdbe34e0b0b647e1d511ed864edb1f9e09d579949b02265fc461896179aa(--no-ff, clean worktree), Release build with GCC 14.2.0 and Ninja, on Debian 13.git diff --checkcheck_conventions.pyAll conventions checks passed.)main(unwrap_self_…destination_directory_group), 0 new failuresguest_np_web_api,guest_np_web_api_initialize,public_headerspublic_headersran about 60 s on this machine, as it is also slow onmain.guest_np_web_apifails as expectedPrevious findings
public_headers. Resolved. The only remaining mention ofsceNpWebApiCreateServicePushEventFilterinExport.cppis its definition (Export.cpp:217) plus the call atExport.cpp:186, andpublic_headerspasses on the merged tree.sceNpWebApiRegisterExtdPushEventCallbackA. Still open.Export.cpp:322-330still ignorescallback. BunnyFl's PS5 13.42 result (0x80552902for a null callback, returned first) is neither handled in the code nor recorded in the debt entry.0x7fff + 1test row pins an unmeasured value. No longer applies as written. Currentmainnow returnsINVALID_LIB_CONTEXT_IDforlibCtxId >= 0x8000insceNpWebApiCreateContext(Export.cpp:168). The0x8000row inGuestNpWebApi.cpp:270therefore matches what the sibling export does. One difference remains, and the debt entry records it: for an unknown id below0x8000,sceNpWebApiCreateContextAreturnsINVALID_LIB_CONTEXT_ID(Export.cpp:180), whilesceNpWebApiCreateContextreturnsLIB_CONTEXT_NOT_FOUND.Negative control
The test cannot be built against
main's headers, as found in the last review, so I mutated the production code instead. InExport.cpp, I madesceNpWebApiUnregisterExtdPushEventCallbackreturn 0 instead ofEXTD_PUSH_EVENT_CALLBACK_NOT_FOUND, then rebuilt.guest_np_web_apiaborted onNpWebApi: unregister an extended callback that does not exist. I restoredExport.cppfrom the merged tree and rebuilt. The test passes again, andgit status --porcelainis empty.New findings
Blocking
None.
Non-blocking
docs/dev/debt/libSceNpWebApi.md:71, "at most once per 1000 µs" became "1000 µs". At30556bb48bthe bytes areC2 B5; at3c783ecec2they areC3 82 C2 B5, which is UTF-8 read as Latin-1 and encoded again. The PR's diff againstmainchanges this line only for that reason. It is unrelated to the PR and corrupts an entry thatmainwrote correctly. Fix: takemain's version of line 71, so the PR's diff to this file is only the added entry.Not verified
30556bb48bis author-reported.