feat(libSceNpWebApi): add user contexts, requests and push event callbacks offline #9797

Merged
Terminev merged 2 commits from upstream-pr/9797 into main 2026-10-26 00:34:34 +00:00
Terminev commented 2026-10-22 15:33:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Terminev on 2026-10-22T15:33:22Z.


What

Implements ten libSceNpWebApi (PS4) exports offline, following shadPS4 with its network disabled, as the existing exports of this library do:

  • sceNpWebApiCreateContext, sceNpWebApiDeleteContext: user contexts of the initial user, ids libCtxId << 16 | counter, USER_CONTEXT_ALREADY_EXIST for a second one.
  • sceNpWebApiCreateRequest, sceNpWebApiDeleteRequest, sceNpWebApiAbortRequest: requests with ids userCtxId << 32 | counter, argument and content parameter checks before the lookups.
  • sceNpWebApiSendRequest: ABORTED for an aborted request, otherwise NOT_SIGNED_IN, since no user is signed in to PSN.
  • sceNpWebApiRegisterPushEventCallback, sceNpWebApiUnregisterPushEventCallback, sceNpWebApiRegisterServicePushEventCallback, sceNpWebApiUnregisterServicePushEventCallback: callbacks are recorded but never called; no service filter can exist, so a service callback gets SERVICE_PUSH_EVENT_FILTER_NOT_FOUND from SDK 2.50.

The SDK-dependent checks (null callback from 1.00, PATCH and existing filter from 2.50) read the compiled SDK version from the process parameters, as libSceAppContent does. With that available, sceNpWebApiCreateServicePushEventFilter now also rejects the invalid service label from SDK 2.00, which closes that part of its debt entry.

sceNpWebApiReadData, sceNpWebApiGetHttpStatusCode, the two header getters and sceNpWebApiUtilityParseNpId still throw: no request ever gets a response, and what the console returns for them is not settled by any source.

Sources and gaps are in docs/dev/debt/libSceNpWebApi.md. Where the sources disagree: shadPS4's terminateContext returns after deleting the first user context and keeps the library context; this PR keeps the existing sceNpWebApiTerminate, which deletes the library context with its user contexts and requests, and says so in the debt entry.

Tested

Linux x86-64 (Intel Xeon @ 2.10GHz with AVX2, FMA, F16C, BMI1, BMI2, LZCNT and MOVBE), GCC 13.3, Release, on 0435d0b25 rebased onto main at c661d9fae: ctest -R '^guest_np_web_api$' and ctest -R public_headers (65/65) pass. The test covers the new exports at SDK 4.50, 2.00, 1.00 and 0.90 through the process parameters fixture, and pins the results measured on a PS4 Pro in the review thread. SDL was configured with its XRandR and audio checks disabled locally, since that machine lacks those headers; this library and its test do not use SDL. python3 tools/check_conventions.py --base origin/main and git diff --check pass. Not built on Windows. No title tested.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4969955246 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9797). Originally posted by [Terminev](https://github.com/Terminev) on 2026-10-22T15:33:22Z. --- ### What Implements ten libSceNpWebApi (PS4) exports offline, following shadPS4 with its network disabled, as the existing exports of this library do: - `sceNpWebApiCreateContext`, `sceNpWebApiDeleteContext`: user contexts of the initial user, ids `libCtxId << 16 | counter`, `USER_CONTEXT_ALREADY_EXIST` for a second one. - `sceNpWebApiCreateRequest`, `sceNpWebApiDeleteRequest`, `sceNpWebApiAbortRequest`: requests with ids `userCtxId << 32 | counter`, argument and content parameter checks before the lookups. - `sceNpWebApiSendRequest`: `ABORTED` for an aborted request, otherwise `NOT_SIGNED_IN`, since no user is signed in to PSN. - `sceNpWebApiRegisterPushEventCallback`, `sceNpWebApiUnregisterPushEventCallback`, `sceNpWebApiRegisterServicePushEventCallback`, `sceNpWebApiUnregisterServicePushEventCallback`: callbacks are recorded but never called; no service filter can exist, so a service callback gets `SERVICE_PUSH_EVENT_FILTER_NOT_FOUND` from SDK 2.50. The SDK-dependent checks (null callback from 1.00, PATCH and existing filter from 2.50) read the compiled SDK version from the process parameters, as libSceAppContent does. With that available, `sceNpWebApiCreateServicePushEventFilter` now also rejects the invalid service label from SDK 2.00, which closes that part of its debt entry. `sceNpWebApiReadData`, `sceNpWebApiGetHttpStatusCode`, the two header getters and `sceNpWebApiUtilityParseNpId` still throw: no request ever gets a response, and what the console returns for them is not settled by any source. Sources and gaps are in `docs/dev/debt/libSceNpWebApi.md`. Where the sources disagree: shadPS4's `terminateContext` returns after deleting the first user context and keeps the library context; this PR keeps the existing `sceNpWebApiTerminate`, which deletes the library context with its user contexts and requests, and says so in the debt entry. ### Tested Linux x86-64 (Intel Xeon @ 2.10GHz with AVX2, FMA, F16C, BMI1, BMI2, LZCNT and MOVBE), GCC 13.3, Release, on 0435d0b25 rebased onto main at c661d9fae: `ctest -R '^guest_np_web_api$'` and `ctest -R public_headers` (65/65) pass. The test covers the new exports at SDK 4.50, 2.00, 1.00 and 0.90 through the process parameters fixture, and pins the results measured on a PS4 Pro in the review thread. SDL was configured with its XRandR and audio checks disabled locally, since that machine lacks those headers; this library and its test do not use SDL. `python3 tools/check_conventions.py --base origin/main` and `git diff --check` pass. Not built on Windows. No title tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-22 16:18:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T16:18:28Z.

Review: CHANGES_REQUESTED


The implementation and focused test coverage look thorough on inspection. I built the exact PR head successfully with the guest_np_web_api_tests target. I could not get a passing local runtime result: ctest -R "^guest_np_web_api$" aborts during libkernel initialization because this host CPU (Xeon E5-1620 v2) lacks LZCNT, BMI1, BMI2, MOVBE and AVX2, which the repository documents as required for PS5 title execution. The PR description reports the focused test passing on Linux with GCC 13.3; current hosted checks are conventions, intake and labels only.

The branch is eight commits behind current main (8499ea52e571b0edfc1feecfd3f6b9944012b359). CONTRIBUTING.md requires branches to be based on and kept up to date with main. Please sync the branch, resolve any conflicts, rerun the focused test on a supported host, and update the test evidence before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5617405314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9797#pullrequestreview-5617405314). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T16:18:28Z. **Review:** CHANGES_REQUESTED --- The implementation and focused test coverage look thorough on inspection. I built the exact PR head successfully with the `guest_np_web_api_tests` target. I could not get a passing local runtime result: `ctest -R "^guest_np_web_api$"` aborts during libkernel initialization because this host CPU (Xeon E5-1620 v2) lacks LZCNT, BMI1, BMI2, MOVBE and AVX2, which the repository documents as required for PS5 title execution. The PR description reports the focused test passing on Linux with GCC 13.3; current hosted checks are conventions, intake and labels only. The branch is eight commits behind current `main` (`8499ea52e571b0edfc1feecfd3f6b9944012b359`). CONTRIBUTING.md requires branches to be based on and kept up to date with `main`. Please sync the branch, resolve any conflicts, rerun the focused test on a supported host, and update the test evidence before merge.
MarcZX10 commented 2026-10-22 16:54:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T16:54:48Z.

Review: COMMENTED


Thanks for rebasing and adding the supported-host test result. The refreshed head f5c41260d83f654e7502070e9bf2ae7aecec5158 has a clean merge tree with current main (11f976b27c16ed91633f00039dba5dfd97dd7cc1); conventions and git diff --check also pass. I confirmed the updated Tested section reports guest_np_web_api passing on a CPU with the required feature set. The earlier base/runtime request is resolved. The PR’s current hosted checks show conventions and labels passing; full product builds are not in this check set. I have not independently rerun the runtime test in this VM because its CPU lacks the required features.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5617835317 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9797#pullrequestreview-5617835317). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T16:54:48Z. **Review:** COMMENTED --- Thanks for rebasing and adding the supported-host test result. The refreshed head `f5c41260d83f654e7502070e9bf2ae7aecec5158` has a clean merge tree with current `main` (`11f976b27c16ed91633f00039dba5dfd97dd7cc1`); conventions and `git diff --check` also pass. I confirmed the updated Tested section reports `guest_np_web_api` passing on a CPU with the required feature set. The earlier base/runtime request is resolved. The PR’s current hosted checks show conventions and labels passing; full product builds are not in this check set. I have not independently rerun the runtime test in this VM because its CPU lacks the required features.
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!9797
No description provided.