feat(libSceNKWebKit): implement DOMException::description, computeCurrentAge and the HTMLMediaElement media cache directory #19719

Merged
B-Howell merged 10 commits from upstream-pr/19719 into main 2026-11-20 04:38:58 +00:00
B-Howell commented 2026-11-13 21:32:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-13T21:32:21Z.


What

Implements four throwing libSceNKWebKit exports from the pinned PS5 WebKit source (neonmodder123/PS5-WebKit-11.x@80f77e9):

  • WebCore::DOMException::description(ExceptionCode) (9kGnP+jnLiI), from DOMException.cpp#L38-L82: if (ec < std::size(descriptions)) return descriptions[ec]; static const Description emptyDescription { { }, { }, 0 }; return emptyDescription;. The 32-row table is copied byte for byte, including the two messages with a leading space. Description is { const ASCIILiteral name; const ASCIILiteral message; LegacyCode legacyCode; } with LegacyCode = uint8_t, and the pinned ASCIILiteral holds only const char* m_characters, so src/DOMExceptionAbi.hpp static_asserts 24 bytes with fields at 0, 8 and 16. The export is declared in a new include/DOMExceptionExports.hpp.
  • WebCore::computeCurrentAge(const ResourceResponse&, WallTime) (zFaau6WD5yo), from CacheValidation.cpp#L106-L117: max(apparentAge, age.value_or(0)) plus WallTime::now() - responseTime, where apparentAge is max(0, responseTime - date) or 0 without a date. It reuses the existing ResourceResponseBase::date, ResourceResponseBase::age (ResponseOptionalTime, static_asserted in ResourceResponseAbi.hpp) and WTF::WallTime::now exports, and goes into src/CacheControl.cpp, which is already derived from the same CacheValidation.cpp.
  • WebCore::HTMLMediaElement::setMediaCacheDirectory(const String&) (eokEwsWT7zI) and mediaCacheDirectory() (u4uYkZNxIcg), from HTMLMediaElement.cpp#L7219-L7233: one never-destroyed shared String; the setter assigns it and the getter returns a reference to it. The assignment uses the existing WtfAbi::String reference counting.

The new source files carry the licence notices of DOMException.cpp and HTMLMediaElement.cpp. The debt file gets an entry for each, and only these four inventory rows are removed.

Tested

WSL Ubuntu, GCC, Release, Linux build:

  • Red, at 3a35d096800 with the implementation removed (stubs from main restored, test kept): nkwebkit_webcorestatichelpers ... Subprocess aborted with _ZN7WebCore12DOMException11descriptionENS_13ExceptionCodeE not implemented.

  • Green: ctest -R '^nkwebkit_webcorestatichelpers$' passed 3 of 3 runs at 3a35d096800 and again 3 of 3 at this head 1b0a0f614ea, which only moves the declaration out of WebCoreExports.hpp to avoid conflicts with #14138 and #17917. nkwebkit_resourceresponse, nkwebkit_cachecontrol, nkwebkit_mediatime and nkwebkit_base passed, and ctest -R '^public_headers' passed 65/65, at both heads.

  • The test checks codes 0, 1, 10, 15, 22, 28 and 31 against the exact name, message and legacy code; codes 32, 37 and 0xffffffff return the same {nullptr, nullptr, 0} record. computeCurrentAge is checked with no headers, a future responseTime, Age: 100, a Date later than, equal to and earlier than responseTime, an Age smaller and larger than the apparent age, a negative and a fractional Age, and unparsable headers; the resident time is bounded by WallTime::now() read before and after the call. The media cache directory starts null, shares the set string's impl with balanced reference counts, survives self-assignment, then takes an empty and a null string, and the returned reference stays the same object.

  • tools/progress.py: libraries 15765/39340 (40.07%) on main to 15769/39340 (40.08%), done +4.

  • @JJenkx, Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, 1b0a0f614e merged onto main 2e5253e9ac (report): nkwebkit_webcorestatichelpers passed 3/3, none skipped.

  • 2026-11-14: comment-only commit 820bb000c81 rewrites each Derived from line as Derived from <path>@<40-character revision>, one line per source file (maintainer ruling, #19819 comment). No code changed, so no rebuild; tools/check_conventions.py --base origin/main passes and git diff --check is clean.

  • Main merge ee498826678: Windows 11, WinLibs GCC 15.2, Release, all 18 of our main merges from this round built together on main 790e9a371cc: ctest -R nkwebkit 116/116 passed, patched_libraries passed once the #19822 fix was in. Re-merged onto b9fb5ab5a32 (no NKWebKit changes in between); check_conventions passed.

  • Debt fragment cb9b668874: merged main c3d38470e0c and moved this PR's debt edits into docs/dev/debt/changes/claude-nkwebkit-domexception-cacheage-mediacache.md; the debt files match main, and the fragment applied to main gives the same debt lines as the previous head. debt_fold.py --check and check_conventions.py --base origin/main pass. Documentation only, no build.

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:5303155857 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19719). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-13T21:32:21Z. --- ### What Implements four throwing libSceNKWebKit exports from the pinned PS5 WebKit source ([neonmodder123/PS5-WebKit-11.x@80f77e9](https://github.com/neonmodder123/PS5-WebKit-11.x/tree/80f77e94c63ee7202eec3d4b5b1a021dd89011ba)): - `WebCore::DOMException::description(ExceptionCode)` (`9kGnP+jnLiI`), from [DOMException.cpp#L38-L82](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/dom/DOMException.cpp#L38-L82): `if (ec < std::size(descriptions)) return descriptions[ec]; static const Description emptyDescription { { }, { }, 0 }; return emptyDescription;`. The 32-row table is copied byte for byte, including the two messages with a leading space. `Description` is `{ const ASCIILiteral name; const ASCIILiteral message; LegacyCode legacyCode; }` with `LegacyCode = uint8_t`, and the pinned `ASCIILiteral` holds only `const char* m_characters`, so `src/DOMExceptionAbi.hpp` static_asserts 24 bytes with fields at 0, 8 and 16. The export is declared in a new `include/DOMExceptionExports.hpp`. - `WebCore::computeCurrentAge(const ResourceResponse&, WallTime)` (`zFaau6WD5yo`), from [CacheValidation.cpp#L106-L117](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/network/CacheValidation.cpp#L106-L117): `max(apparentAge, age.value_or(0))` plus `WallTime::now() - responseTime`, where `apparentAge` is `max(0, responseTime - date)` or 0 without a date. It reuses the existing `ResourceResponseBase::date`, `ResourceResponseBase::age` (`ResponseOptionalTime`, static_asserted in `ResourceResponseAbi.hpp`) and `WTF::WallTime::now` exports, and goes into `src/CacheControl.cpp`, which is already derived from the same CacheValidation.cpp. - `WebCore::HTMLMediaElement::setMediaCacheDirectory(const String&)` (`eokEwsWT7zI`) and `mediaCacheDirectory()` (`u4uYkZNxIcg`), from [HTMLMediaElement.cpp#L7219-L7233](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/html/HTMLMediaElement.cpp#L7219-L7233): one never-destroyed shared `String`; the setter assigns it and the getter returns a reference to it. The assignment uses the existing `WtfAbi::String` reference counting. The new source files carry the licence notices of DOMException.cpp and HTMLMediaElement.cpp. The debt file gets an entry for each, and only these four inventory rows are removed. ### Tested WSL Ubuntu, GCC, Release, Linux build: - Red, at `3a35d096800` with the implementation removed (stubs from main restored, test kept): `nkwebkit_webcorestatichelpers ... Subprocess aborted` with `_ZN7WebCore12DOMException11descriptionENS_13ExceptionCodeE not implemented`. - Green: `ctest -R '^nkwebkit_webcorestatichelpers$'` passed 3 of 3 runs at `3a35d096800` and again 3 of 3 at this head `1b0a0f614ea`, which only moves the declaration out of `WebCoreExports.hpp` to avoid conflicts with #14138 and #17917. `nkwebkit_resourceresponse`, `nkwebkit_cachecontrol`, `nkwebkit_mediatime` and `nkwebkit_base` passed, and `ctest -R '^public_headers'` passed 65/65, at both heads. - The test checks codes 0, 1, 10, 15, 22, 28 and 31 against the exact name, message and legacy code; codes 32, 37 and 0xffffffff return the same `{nullptr, nullptr, 0}` record. `computeCurrentAge` is checked with no headers, a future `responseTime`, `Age: 100`, a `Date` later than, equal to and earlier than `responseTime`, an `Age` smaller and larger than the apparent age, a negative and a fractional `Age`, and unparsable headers; the resident time is bounded by `WallTime::now()` read before and after the call. The media cache directory starts null, shares the set string's impl with balanced reference counts, survives self-assignment, then takes an empty and a null string, and the returned reference stays the same object. - `tools/progress.py`: libraries 15765/39340 (40.07%) on main to 15769/39340 (40.08%), done +4. - @JJenkx, Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, 1b0a0f614e merged onto main 2e5253e9ac ([report](https://github.com/boykopovar/AnyPS5/pull/19719#issuecomment-6866704786)): `nkwebkit_webcorestatichelpers` passed 3/3, none skipped. - 2026-11-14: comment-only commit `820bb000c81` rewrites each `Derived from` line as `Derived from <path>@<40-character revision>`, one line per source file (maintainer ruling, [#19819 comment](https://github.com/boykopovar/AnyPS5/pull/19819#issuecomment-6868889186)). No code changed, so no rebuild; `tools/check_conventions.py --base origin/main` passes and `git diff --check` is clean. - Main merge `ee498826678`: Windows 11, WinLibs GCC 15.2, Release, all 18 of our main merges from this round built together on main `790e9a371cc`: `ctest -R nkwebkit` 116/116 passed, `patched_libraries` passed once the #19822 fix was in. Re-merged onto `b9fb5ab5a32` (no NKWebKit changes in between); `check_conventions` passed. - Debt fragment `cb9b668874`: merged main `c3d38470e0c` and moved this PR's debt edits into `docs/dev/debt/changes/claude-nkwebkit-domexception-cacheage-mediacache.md`; the debt files match main, and the fragment applied to main gives the same debt lines as the previous head. `debt_fold.py --check` and `check_conventions.py --base origin/main` pass. Documentation only, no build. ### 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
PrivacyOnion commented 2026-11-18 09:33:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T09:33:31Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_webcorestatichelpers_tests built cleanly.
  • CTest (nkwebkit_webcorestatichelpers):
    1/1 Test #4580: nkwebkit_webcorestatichelpers ....   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/CacheControlExports.hpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/MediaExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/CacheControl.cpp, core/libs/prx/libSceNKWebKit/src/DOMException.cpp, core/libs/prx/libSceNKWebKit/src/HTMLMediaElement.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WebCore::DOMException::description(uint32_t) in DOMException.cpp matches upstream 32-entry table, bounds check (code < 32), and returns fallback static emptyDescription for code >= 32 with identical layout in DOMExceptionAbi.hpp
    • Verified WebCore::computeCurrentAge in CacheControl.cpp correctly implements RFC 7234 apparentAge calculation with date clamping, age header override, and residentTime addition per upstream CacheValidation.cpp
    • Verified WebCore::HTMLMediaElement::setMediaCacheDirectory and mediaCacheDirectory in HTMLMediaElement.cpp manage heap-allocated static WTF::String without teardown, mirroring upstream WebKit behaviour
    • Verified ABI struct definitions and alignment: DOMExceptionDescription sizeof == 24, alignof == 8, matching 64-bit pointer and uint8_t layout across Linux (LP64) and Windows (LLP64)
    • Verified test coverage in WebCoreStaticHelpers.cpp thoroughly tests DOMException boundary and table offsets, age calculation arithmetic with fixture dates/ages, and String refcounting and identity
    • Verified AGENTS.md compliance: no unauthorized comments, debt fragment correctly formatted in docs/dev/debt/changes/, no banned files, and exported symbols properly unhooked from Export.cpp

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5953908059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19719#pullrequestreview-5953908059). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T09:33:31Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `cb9b668874`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_webcorestatichelpers_tests` built cleanly. - **CTest** (`nkwebkit_webcorestatichelpers`): ``` 1/1 Test #4580: nkwebkit_webcorestatichelpers .... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/CacheControlExports.hpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/MediaExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/CacheControl.cpp`, `core/libs/prx/libSceNKWebKit/src/DOMException.cpp`, `core/libs/prx/libSceNKWebKit/src/HTMLMediaElement.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified WebCore::DOMException::description(uint32_t) in DOMException.cpp matches upstream 32-entry table, bounds check (code < 32), and returns fallback static emptyDescription for code >= 32 with identical layout in DOMExceptionAbi.hpp - Verified WebCore::computeCurrentAge in CacheControl.cpp correctly implements RFC 7234 apparentAge calculation with date clamping, age header override, and residentTime addition per upstream CacheValidation.cpp - Verified WebCore::HTMLMediaElement::setMediaCacheDirectory and mediaCacheDirectory in HTMLMediaElement.cpp manage heap-allocated static WTF::String without teardown, mirroring upstream WebKit behaviour - Verified ABI struct definitions and alignment: DOMExceptionDescription sizeof == 24, alignof == 8, matching 64-bit pointer and uint8_t layout across Linux (LP64) and Windows (LLP64) - Verified test coverage in WebCoreStaticHelpers.cpp thoroughly tests DOMException boundary and table offsets, age calculation arithmetic with fixture dates/ages, and String refcounting and identity - Verified AGENTS.md compliance: no unauthorized comments, debt fragment correctly formatted in docs/dev/debt/changes/, no banned files, and exported symbols properly unhooked from Export.cpp Looks Good To Me
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!19719
No description provided.