feat(libSceNKWebKit): implement WKContext memory sampler controls #24516

Closed
jagrat04 wants to merge 1 commit from upstream-pr/24516 into main
jagrat04 commented 2026-11-20 18:35:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-11-20T18:35:52Z.


What

Implement WebKit C API WKContext memory sampler controls in libSceNKWebKit:

  • WKContextStartMemorySampler (NID xXWslPRXf9Y): starts memory sampling at the specified interval, storing the interval value and running state on the host ProcessPool instance following WebKit's WKContext.cpp.
  • WKContextStopMemorySampler (NID 4k3e7qWpRcU): stops memory sampling on the host ProcessPool instance.

Tested

tools/check_conventions.py --base origin/main passed; tools/debt_fold.py --check passed; tests/ContextMemorySampler.cpp tests starting and stopping memory sampling, updating intervals, verifying state retention, rejecting null arguments, and enforcing type safety (Double and ProcessPool). Not tested on a PS5.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5418425984 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24516). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-11-20T18:35:52Z. --- ### What Implement WebKit C API `WKContext` memory sampler controls in `libSceNKWebKit`: - `WKContextStartMemorySampler` (NID `xXWslPRXf9Y`): starts memory sampling at the specified interval, storing the interval value and running state on the host `ProcessPool` instance following WebKit's `WKContext.cpp`. - `WKContextStopMemorySampler` (NID `4k3e7qWpRcU`): stops memory sampling on the host `ProcessPool` instance. ### Tested `tools/check_conventions.py --base origin/main` passed; `tools/debt_fold.py --check` passed; `tests/ContextMemorySampler.cpp` tests starting and stopping memory sampling, updating intervals, verifying state retention, rejecting null arguments, and enforcing type safety (`Double` and `ProcessPool`). Not tested on a PS5. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-20 18:59:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T18:59:13Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 2184cdb6db:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_contextmemorysampler_tests built cleanly.
  • CTest (nkwebkit_contextmemorysampler):
    1/1 Test #4702: nkwebkit_contextmemorysampler ....   Passed    0.08 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/WebKitValueExports.hpp, core/libs/prx/libSceNKWebKit/src/Configuration.hpp, core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WKContextStartMemorySampler and WKContextStopMemorySampler signatures in WebKitValueExports.hpp and ContextMemorySampler.cpp match WebKit C API (void return, const void* parameters)
    • Verified NKWebKit::Cast and NKWebKit::Cast properly validate pointers against nullptr and type mismatch, throwing std::invalid_argument handled by RequireThrows in tests
    • Verified ProcessPool struct in Configuration.hpp correctly tracks memorySamplerRunning and memorySamplerInterval with expected default initializations (false, 0.0)
    • Verified technical debt fragments in docs/dev/debt/changes/wkcontext-memory-sampler.md correctly remove NIDs xXWslPRXf9Y and 4k3e7qWpRcU
    • Verified tests in ContextMemorySampler.cpp thoroughly exercise start/stop state changes, interval updates, null pointer rejections, and type mismatches with proper cleanup via WKRelease

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5997892229 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24516#pullrequestreview-5997892229). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T18:59:13Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `2184cdb6db`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_contextmemorysampler_tests` built cleanly. - **CTest** (`nkwebkit_contextmemorysampler`): ``` 1/1 Test #4702: nkwebkit_contextmemorysampler .... Passed 0.08 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/WebKitValueExports.hpp`, `core/libs/prx/libSceNKWebKit/src/Configuration.hpp`, `core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified WKContextStartMemorySampler and WKContextStopMemorySampler signatures in WebKitValueExports.hpp and ContextMemorySampler.cpp match WebKit C API (void return, const void* parameters) - Verified NKWebKit::Cast<ProcessPool> and NKWebKit::Cast<Double> properly validate pointers against nullptr and type mismatch, throwing std::invalid_argument handled by RequireThrows in tests - Verified ProcessPool struct in Configuration.hpp correctly tracks memorySamplerRunning and memorySamplerInterval with expected default initializations (false, 0.0) - Verified technical debt fragments in docs/dev/debt/changes/wkcontext-memory-sampler.md correctly remove NIDs xXWslPRXf9Y and 4k3e7qWpRcU - Verified tests in ContextMemorySampler.cpp thoroughly exercise start/stop state changes, interval updates, null pointer rejections, and type mismatches with proper cleanup via WKRelease Looks Good To Me
MarcZX10 commented 2026-11-20 19:27:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:27:52Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected changes add typed WKContext sampler state controls; I did not run a build or tests, so approval is not justified.

What I ran

Reviewed head 2184cdb6db524aa39907c46a16068031ee0131ca. Read the prepared description, commit list, manifest, and diff, plus the changed source/test files and targeted ranges in Export.cpp and InventoryExports.hpp. Used repo_read.py to inspect source; no build or test commands were run.

Results

Check Result Note
Source review passed Changed behavior and declarations inspected
Build and tests not run No command execution available
PS5 behavior not run Description reports no console test

Negative control

Not run; no test execution was available.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The full text of Export.cpp and InventoryExports.hpp was excluded from the review bundle; only their changed regions were read. files.json was not available through the reader; exclusions are taken from manifest.json. Build and test results, including the author-reported checks, were not independently verified. PS5 runtime behavior was not tested.

To get this to a good state

Nothing is required. Optional: run the project checks and test on a PS5 when available.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998226350 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24516#pullrequestreview-5998226350). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T19:27:52Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected changes add typed WKContext sampler state controls; I did not run a build or tests, so approval is not justified. ## What I ran Reviewed head `2184cdb6db524aa39907c46a16068031ee0131ca`. Read the prepared description, commit list, manifest, and diff, plus the changed source/test files and targeted ranges in `Export.cpp` and `InventoryExports.hpp`. Used `repo_read.py` to inspect source; no build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed behavior and declarations inspected | | Build and tests | not run | No command execution available | | PS5 behavior | not run | Description reports no console test | ## Negative control Not run; no test execution was available. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Sampler implementation at reviewed head](https://github.com/boykopovar/AnyPS5/blob/2184cdb6db524aa39907c46a16068031ee0131ca/core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp) - [Sampler tests at reviewed head](https://github.com/boykopovar/AnyPS5/blob/2184cdb6db524aa39907c46a16068031ee0131ca/core/libs/prx/libSceNKWebKit/tests/ContextMemorySampler.cpp) ## Not verified The full text of `Export.cpp` and `InventoryExports.hpp` was excluded from the review bundle; only their changed regions were read. `files.json` was not available through the reader; exclusions are taken from `manifest.json`. Build and test results, including the author-reported checks, were not independently verified. PS5 runtime behavior was not tested. ## To get this to a good state Nothing is required. Optional: run the project checks and test on a PS5 when available.
MarcZX10 commented 2026-11-22 19:53:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T19:53:09Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: register both implementations in the PRX export inventory so the requested NIDs resolve to these functions.

What I ran

Reviewed head 0a12c0db6f9ebed465a5053af62d99d9531a8925 using the prepared diff and repo_read.py-backed reads. No tests or build commands were run; the description reports convention and debt checks passed, but I did not run them.

Results

Check Result Note
Diff and changed code passed Relevant implementation and declarations read
Build and tests not run Author reports tests; not independently verified
Console behavior not run PR description says not tested on PS5

Findings

Blocking

  • The PR removes both functions from InventoryExports.hpp and adds declarations only to WebKitValueExports.hpp. The repository search found no inventory declarations or other export registration for either name. As a result, these implementations are not shown to be exported under the requested NIDs and may not be reachable by callers. Add the required inventory/export mapping for both functions. Evidence: core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp:30 and core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp:31 (removed lines); implementations are at core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp:6 and core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp:13.

Non-blocking

None.

Not verified

No build, tests, convention check, or PS5 run was performed. The two files excluded from the prepared bundle because of size, Export.cpp and InventoryExports.hpp, were inspected only through targeted reader searches; other changed files listed in the manifest were read through the prepared bundle. No separate files.json listing was available through the reader.

To get this to a good state

Register both functions in the PRX export inventory, then run the relevant build and tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014139136 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24516#pullrequestreview-6014139136). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T19:53:09Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: register both implementations in the PRX export inventory so the requested NIDs resolve to these functions. ## What I ran Reviewed head `0a12c0db6f9ebed465a5053af62d99d9531a8925` using the prepared diff and `repo_read.py`-backed reads. No tests or build commands were run; the description reports convention and debt checks passed, but I did not run them. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Relevant implementation and declarations read | | Build and tests | not run | Author reports tests; not independently verified | | Console behavior | not run | PR description says not tested on PS5 | ## Findings ### Blocking - The PR removes both functions from `InventoryExports.hpp` and adds declarations only to `WebKitValueExports.hpp`. The repository search found no inventory declarations or other export registration for either name. As a result, these implementations are not shown to be exported under the requested NIDs and may not be reachable by callers. Add the required inventory/export mapping for both functions. Evidence: `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp:30` and `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp:31` (removed lines); implementations are at `core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp:6` and `core/libs/prx/libSceNKWebKit/src/ContextMemorySampler.cpp:13`. ### Non-blocking None. ## Not verified No build, tests, convention check, or PS5 run was performed. The two files excluded from the prepared bundle because of size, `Export.cpp` and `InventoryExports.hpp`, were inspected only through targeted reader searches; other changed files listed in the manifest were read through the prepared bundle. No separate `files.json` listing was available through the reader. ## To get this to a good state Register both functions in the PRX export inventory, then run the relevant build and tests on the updated head.
MarcZX10 commented 2026-11-25 00:19:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T00:19:59Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation records the sampler interval and running state on the host ProcessPool; the review was limited to source inspection and no tests were run.

What I ran

Reviewed head b8053015bba873f421b4b2e95b90cf328d74bafd. Read the prepared description, commit list, manifest, diff, and changed source/test files through repo_read.py. No commands or tests were run.

Results

Check Result Note
Source review passed Sample state setters and type casts inspected
Tests not run No local test execution
PS5 behavior not run Description reports no console test

Findings

Blocking

None.

Non-blocking

None.

Not verified

Export.cpp and InventoryExports.hpp were excluded from the review folder as too large; their changed hunks are visible in the prepared diff but their full head text was not read. The remaining changed files were included and read. No build, test, or PS5 behavior was verified. The files.json listing mentioned in the instructions was not available through the reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6049595737 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24516#pullrequestreview-6049595737). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T00:19:59Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation records the sampler interval and running state on the host `ProcessPool`; the review was limited to source inspection and no tests were run. ## What I ran Reviewed head `b8053015bba873f421b4b2e95b90cf328d74bafd`. Read the prepared description, commit list, manifest, diff, and changed source/test files through `repo_read.py`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Sample state setters and type casts inspected | | Tests | not run | No local test execution | | PS5 behavior | not run | Description reports no console test | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `Export.cpp` and `InventoryExports.hpp` were excluded from the review folder as too large; their changed hunks are visible in the prepared diff but their full head text was not read. The remaining changed files were included and read. No build, test, or PS5 behavior was verified. The `files.json` listing mentioned in the instructions was not available through the reader. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-26 12:18:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:18:56Z.

Review: COMMENTED


Reviewed — comments

Material review is incomplete because Export.cpp was excluded from the review bundle and the change’s export wiring could not be verified.

What I ran

Reviewed head 464d127e8f8507a7779eddd0baaad0ba024acb8f using the prepared diff and repo_read.py. No tests or other commands were run.

Results

Check Result Note
Diff review passed Prepared patch inspected
Repository context not run Export wiring not fully verified
Tests not run No test execution

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

Export.cpp was excluded from the bundle because it was too large; only the surrounding lines at the removed stubs were read. files.json was not available through the reader, so other exclusions could not be confirmed. The test source was read, but its reported results were not independently verified. No PS5 behavior was tested.

Files read: description.md, commits.md, manifest.json, diff.patch, Export.cpp (targeted range), InventoryExports.hpp (targeted range), WebKitValueExports.hpp, Configuration.hpp, ContextMemorySampler.cpp, and tests/ContextMemorySampler.cpp. The debt note and full Export.cpp were not read.

To get this to a good state

Nothing is required. Please share the complete Export.cpp export wiring context and test execution results if you want a complete review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6074004768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24516#pullrequestreview-6074004768). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T12:18:56Z. **Review:** COMMENTED --- # Reviewed — comments Material review is incomplete because `Export.cpp` was excluded from the review bundle and the change’s export wiring could not be verified. ## What I ran Reviewed head `464d127e8f8507a7779eddd0baaad0ba024acb8f` using the prepared diff and `repo_read.py`. No tests or other commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff review | passed | Prepared patch inspected | | Repository context | not run | Export wiring not fully verified | | Tests | not run | No test execution | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified `Export.cpp` was excluded from the bundle because it was too large; only the surrounding lines at the removed stubs were read. `files.json` was not available through the reader, so other exclusions could not be confirmed. The test source was read, but its reported results were not independently verified. No PS5 behavior was tested. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `Export.cpp` (targeted range), `InventoryExports.hpp` (targeted range), `WebKitValueExports.hpp`, `Configuration.hpp`, `ContextMemorySampler.cpp`, and `tests/ContextMemorySampler.cpp`. The debt note and full `Export.cpp` were not read. ## To get this to a good state Nothing is required. Please share the complete `Export.cpp` export wiring context and test execution results if you want a complete review.

Pull request closed

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!24516
No description provided.