Skip to content

feat(libSceNpWebApi): implement handle aborts, request options and timeouts - #13455

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
KernelPanicNT:feat/npwebapi-request-options
Oct 30, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
KernelPanicNT:feat/npwebapi-request-options

Conversation

@KernelPanicNT

Copy link
Copy Markdown
Contributor

Source of the behaviour

Not measured on a device: NP is out of reach offline, so this follows the same two PS4 references the tree's NpWebApi model already uses, and the debt entry says so.

The timeout unit is unverified, and the one source disagrees with itself. shadPS4 logs the value of SetHandleTimeout and SetRequestTimeout as ms, but starts the request timer and the handle timer by adding the raw value to sceKernelGetProcessTime(), which counts microseconds (in tree). This branch follows the arithmetic (microseconds of process time), and the debt entry now opens with that gap.

Call Checks, in order Offline result
AbortHandle(libCtxId, handleId) library context, handle 0
AddHttpRequestHeader(requestId, name, value) null name or value: INVALID_ARGUMENT; library, user context, request 0, header unused
CreateMultipartRequest(user, group, path, method, id) null group or path, method after DELETE from SDK 2.50: INVALID_ARGUMENT; library, user context 0, id written when the pointer is not null
SendRequest2(requestId, data, size, info) same as SendRequest; a multipart request has no part 0: INVALID_ARGUMENT NOT_SIGNED_IN, or ABORTED; info untouched
SetHandleTimeout(libCtxId, handleId, timeout) library context; handle created at SDK 3.00 or later 0, else HANDLE_NOT_FOUND
SetMultipartContentType(requestId, type, boundary) library, user context, request (no null checks) 0
SetRequestTimeout(requestId, timeout) library, user context, request 0, timeout kept
CheckTimeout() none while no library context exists; at most once per 1000 µs of process time aborts sent requests whose timeout, counted in microseconds (unit unverified, see above), passed; such a request then sends with NOT_SIGNED_IN

In-tree lines that change (at 50c39f09b5): the placeholders and their declarations, Request, sceNpWebApiCreateHandle, sceNpWebApiCreateRequest, sceNpWebApiDeleteHandle, sceNpWebApiSendRequest and the inventory table.

What

Eight NpWebApi exports get their PS4 prototypes and the offline behaviour of the model the library already follows (#9797), and no longer throw: sceNpWebApiAbortHandle, sceNpWebApiAddHttpRequestHeader, sceNpWebApiCheckTimeout, sceNpWebApiCreateMultipartRequest, sceNpWebApiSendRequest2, sceNpWebApiSetHandleTimeout, sceNpWebApiSetMultipartContentType and sceNpWebApiSetRequestTimeout.

  • Requests remember whether they are multipart and their timeout; the first send starts the timer from sceKernelGetProcessTime. sceNpWebApiSendRequest and sceNpWebApiSendRequest2 share one path, so SendRequest now also rejects a multipart request and starts the timer.
  • Handles created at SDK 3.00 or later get a timer slot; SetHandleTimeout needs it. Handle timeouts and aborts have no further effect, since no NP request runs on a handle.
  • Headers and multipart content types are validated and dropped, because no request is ever sent.
  • sceNpWebApiAddMultipartPart, sceNpWebApiSendMultipartRequest2 and sceNpWebApiUtilityParseNpId still throw: the part layout has a single source, and the tree's NpId layout differs from the one shadPS4 parses into.

The debt entry opens with the unverified timeout unit (shadPS4 logs it as milliseconds but counts it in microseconds, as done here), then records that none of this is measured, which source gives what and the timed-out send result.

Tested

  • Linux (GitHub codespace), main at 50c39f09b5 with this branch applied: guest_np_web_api passes. New cases: every not-found error of each call, null-argument order, the SDK 2.50 method check and the SDK 3.00 handle timer (decided when the handle is created), SendRequest2 leaving the response information alone, multipart requests refused by both send calls even when aborted, and a timeout scan over four requests (short timeout sent, short timeout never sent, no timeout, 0xffffffff timeout) where only the sent short one stops reporting ABORTED.
  • Negative control: with Export.cpp from main (its throwing stubs given the new signatures so the test builds), guest_np_web_api aborts on sceNpWebApiAbortHandle not implemented.
  • python3 tools/check_conventions.py --base origin/main passes. tools/progress.py against main: +8 implemented functions (libSceNpWebApi 18/50 to 26/50).
  • No title test.

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

…meouts

Give sceNpWebApiAbortHandle, sceNpWebApiAddHttpRequestHeader,
sceNpWebApiCheckTimeout, sceNpWebApiCreateMultipartRequest,
sceNpWebApiSendRequest2, sceNpWebApiSetHandleTimeout,
sceNpWebApiSetMultipartContentType and sceNpWebApiSetRequestTimeout
their prototypes and the offline behaviour of the existing model.

Requests keep a multipart flag and a timeout whose timer starts on the
first send; CheckTimeout aborts expired requests at most once per
millisecond. The timeout unit is unverified: shadPS4 logs it as
milliseconds but adds it to microsecond process time, which is what
is done here. Handles created from SDK 3.00 get a timer slot. Headers
and multipart content types are validated and dropped, since nothing
is sent. Multipart parts and UtilityParseNpId still throw.
@maskym

maskym commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Windows result for head 7a0fe8bde1, merged into main 9f748f4d8e (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. Build clean.

The tree also carried the open PR #11843, merged cleanly, so the run is a joint one. guest_np_web_api, the test this PR extends, passes, with guest_np_web_api2; the whole ^(guest_np_web_api|guest_mktime|guest_time) set the tree's changed tests belong to passes 11/11, three runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@maskym maskym mentioned this pull request Oct 30, 2026
12 tasks done

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The implementation matches the pinned reference's validation flow; its unresolved timeout-unit question is explicitly documented as unverified.

What I ran

Reviewed head 7a0fe8bde19313284be687c02dc2afb3873dc16e against PR base 9f748f4d8e36ce3714f3b95f3386316e110a9b22. A read-only merge preview onto current main 9304896d89f070f65b8f38bd3a8024d5c19f8fe1 was clean (tree af356ec4171c8e9787df6ab912873e572507681b). Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0.

git diff --check 9f748f4d8e36ce3714f3b95f3386316e110a9b22...7a0fe8bde19313284be687c02dc2afb3873dc16e
python3 tools/check_conventions.py --base 9f748f4d8e36ce3714f3b95f3386316e110a9b22 --head 7a0fe8bde19313284be687c02dc2afb3873dc16e
python3 tools/pr_abi_audit.py --base 9f748f4d8e36ce3714f3b95f3386316e110a9b22 --head 7a0fe8bde19313284be687c02dc2afb3873dc16e --json
python3 tools/pr_test_quality.py --root . core/libs/tests/GuestNpWebApi.cpp
git merge-tree --write-tree refs/remotes/upstream/main refs/remotes/review/pr-13455

Results

Check Result
Diff check and conventions Passed
ABI audit Passed: 50 symbols, no findings
Test-quality heuristic Warned that it could not find the test path literally; verified registration in the PR's CMake file
Current-main merge preview Clean
Aggregate no-build precheck Its isolated copy lacked local-only, untracked audit scripts; the direct relevant checks above passed
Unedited output from direct checks
All conventions checks passed.
status: passed
symbols: 50
findings: []
core/libs/tests/GuestNpWebApi.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage.
Heuristic findings require manual interpretation.
git diff --check produced no output.
af356ec4171c8e9787df6ab912873e572507681b

Negative control

Not run locally because the regression test requires a built C++ target. The PR author reports a negative control in the description; I did not independently reproduce it.

Findings

Non-blocking

The timeout unit is unresolved: the pinned source labels it milliseconds but adds the raw value to a microsecond process-time counter. The PR follows that arithmetic and records the uncertainty; I did not verify timeout timing on a PS5.

Sources

Not verified

No local build or C++ test was run. The hosted Windows build was queued at final refresh; Linux build/test jobs were skipped. The PR author reports a Linux codespace test and negative control, which I did not independently reproduce.

@github-actions

Copy link
Copy Markdown

Progress report (9f748f4 → 7a0fe8b)

📈 System libraries: 27.3% (+0.04%, +8 implemented functions)

✅ 8 implemented
Library Name
libSceNpWebApi sceNpWebApiAbortHandle
libSceNpWebApi sceNpWebApiAddHttpRequestHeader
libSceNpWebApi sceNpWebApiCheckTimeout
libSceNpWebApi sceNpWebApiCreateMultipartRequest
libSceNpWebApi sceNpWebApiSendRequest2
libSceNpWebApi sceNpWebApiSetHandleTimeout
libSceNpWebApi sceNpWebApiSetMultipartContentType
libSceNpWebApi sceNpWebApiSetRequestTimeout

Changed libraries (implemented exports)

Library Before After Change
libSceNpWebApi 18/50 (36.00%) 26/50 (52.00%) +16.00%

@adriadam10 adriadam10 self-assigned this Oct 30, 2026
@adriadam10
adriadam10 merged commit e584b5a into boykopovar:main Oct 30, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the eight exports against the cited shadPS4 checks and order and the Orbital prototypes, the shared send path (multipart part check before the abort check), the timer and timeout scan, and the new guest_np_web_api cases, which fail without the change since the exports threw. The unverified timeout unit is recorded in the debt entry; Windows result from @maskym and @MarcZX10's review noted; merged.

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.

4 participants