feat(libSceNKWebKit): implement the WebCore::TrackPrivateBase constructor and default getters #19704

Merged
c1b3r-p3d1a merged 2 commits from upstream-pr/19704 into main 2026-11-15 09:46:30 +00:00
c1b3r-p3d1a commented 2026-11-13 20:53:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by c1b3r-p3d1a on 2026-11-13T20:53:39Z.


What

Brings back the WebCore::TrackPrivateBase getters from #19147, together with the code that creates the object, as asked when #19147 was closed.

  • _ZN7WebCore16TrackPrivateBaseC2Ev, the base constructor, now creates the object. A subclass a title defines calls it before its own constructor body. It stores a pointer to this library's TrackPrivateBase vtable at offset 0 and the ThreadSafeRefCounted count of 1 (m_refCount { 1 }) at offset 8. It writes nothing at offsets 12 to 15: the class is not POD, so a subclass may place its first field in that tail padding.
  • The base destructor D2 is already a no-op on main (a bare ret in the 11.00 module, NoOpExports.cpp). So a title's subclass can now be constructed, used and destroyed, and its vtable reaches id, label, language and startTimeVariance. These return the defaults of the pinned TrackPrivateBase.h: the empty atom (this library's static empty string, flagged as an atom) and a copy of MediaTime::zeroTime().
  • The 16-byte layout (vtable pointer, then reference count) assumes the release build without the RELEASE_LOG fields. A RefPtr<const Logger> member would give D2 a body, and the 11.00 D2 is empty. The exported names also have no setLogger.
  • The vtable, like the one in WtfJson.cpp, holds the destructors, __cxa_pure_virtual for client(), then the exported virtuals in declaration order, with no type info. The subclass constructor overwrites it before anything can read it.

Still throwing, as the debt entry says:

  • D1 and D0: the class is abstract (no C1 is exported), so a subclass never calls them. Their 11.00 bodies are not a bare ret and were not read.
  • willBeRemoved: the slot of the client's willRemove depends on the WebKit revision.

The 4 getters and the constructor leave the inventory table.

Unverified: nothing was compared with a console module.

Tested

Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release.

  • nkwebkit_trackprivatebase:
    • Constructs into a buffer filled with 0xa5, then checks the vtable header (offset-to-top and type info null), the count of exactly 1 at offset 8, and that bytes 12 to 31 are untouched.
    • Calls id, label, language, trackIndex and startTimeVariance through the stored vtable, and builds twice to get the same vtable.
    • Keeps the getter checks from #19147: reference counts, poisoned result slots, null object.
    • It fails with each of these mutations: the old throwing stub, a count of 0, an 8-byte count store over offsets 12 to 15, a non-zero offset-to-top. Swapping the id and label slots is not detected, because both return the empty atom.
  • Rebased on main fb2ba350f9: the 79 tests matching nkwebkit and the 65 public_headers tests pass. python tools/check_conventions.py --base origin/main passes.
  • objdump of the built C2: this arrives in rdi. It stores the vtable address at 0(%rdi) and does movl $0x1,0x8(%rdi), with no other store.
  • On Windows a rebuilt libSceNKWebKit.prx is not copied over the one staged in build/tests (#17895), so I copied it there before each run.
  • Not run: the full suite, Linux.

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:5302688058 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19704). Originally posted by [c1b3r-p3d1a](https://github.com/c1b3r-p3d1a) on 2026-11-13T20:53:39Z. --- ### What Brings back the `WebCore::TrackPrivateBase` getters from #19147, together with the code that creates the object, as asked when #19147 was closed. - `_ZN7WebCore16TrackPrivateBaseC2Ev`, the base constructor, now creates the object. A subclass a title defines calls it before its own constructor body. It stores a pointer to this library's `TrackPrivateBase` vtable at offset 0 and the `ThreadSafeRefCounted` count of 1 ([`m_refCount { 1 }`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/ThreadSafeRefCounted.h#L100)) at offset 8. It writes nothing at offsets 12 to 15: the class is not POD, so a subclass may place its first field in that tail padding. - The base destructor `D2` is already a no-op on `main` (a bare `ret` in the 11.00 module, `NoOpExports.cpp`). So a title's subclass can now be constructed, used and destroyed, and its vtable reaches `id`, `label`, `language` and `startTimeVariance`. These return the defaults of the pinned [TrackPrivateBase.h](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/graphics/TrackPrivateBase.h#L53-L61): the empty atom (this library's static empty string, flagged as an atom) and a copy of `MediaTime::zeroTime()`. - The 16-byte layout (vtable pointer, then reference count) assumes the release build without the `RELEASE_LOG` fields. A `RefPtr<const Logger>` member would give `D2` a body, and the 11.00 `D2` is empty. The exported names also have no `setLogger`. - The vtable, like the one in `WtfJson.cpp`, holds the destructors, `__cxa_pure_virtual` for `client()`, then the exported virtuals in declaration order, with no type info. The subclass constructor overwrites it before anything can read it. Still throwing, as the debt entry says: - `D1` and `D0`: the class is abstract (no `C1` is exported), so a subclass never calls them. Their 11.00 bodies are not a bare `ret` and were not read. - `willBeRemoved`: the slot of the client's `willRemove` depends on the WebKit revision. The 4 getters and the constructor leave the inventory table. Unverified: nothing was compared with a console module. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), Release. - `nkwebkit_trackprivatebase`: - Constructs into a buffer filled with `0xa5`, then checks the vtable header (offset-to-top and type info null), the count of exactly 1 at offset 8, and that bytes 12 to 31 are untouched. - Calls `id`, `label`, `language`, `trackIndex` and `startTimeVariance` through the stored vtable, and builds twice to get the same vtable. - Keeps the getter checks from #19147: reference counts, poisoned result slots, null object. - It fails with each of these mutations: the old throwing stub, a count of 0, an 8-byte count store over offsets 12 to 15, a non-zero offset-to-top. Swapping the `id` and `label` slots is not detected, because both return the empty atom. - Rebased on `main` `fb2ba350f9`: the 79 tests matching `nkwebkit` and the 65 `public_headers` tests pass. `python tools/check_conventions.py --base origin/main` passes. - `objdump` of the built `C2`: `this` arrives in `rdi`. It stores the vtable address at `0(%rdi)` and does `movl $0x1,0x8(%rdi)`, with no other store. - On Windows a rebuilt `libSceNKWebKit.prx` is not copied over the one staged in `build/tests` (#17895), so I copied it there before each run. - Not run: the full suite, Linux. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
PrivacyOnion commented 2026-11-14 02:34:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T02:34:14Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: nkwebkit_trackprivatebase_tests built cleanly.
  • CTest (nkwebkit_trackprivatebase):
    1/1 Test #3916: nkwebkit_trackprivatebase ........   Passed    0.01 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/libSceNKWebKit.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified object layout and alignment in core/libs/prx/libSceNKWebKit/src/TrackPrivateBase.cpp: vptr is positioned at offset 0 (8 bytes) and refCount initialized to 1 at offset 8 (4 bytes), leaving offsets 12-15 untouched so derived class member tail padding is not clobbered under the Itanium ABI.
    • Verified vtable storage layout in TrackPrivateBaseVtableStorage (core/libs/prx/libSceNKWebKit/src/TrackPrivateBase.cpp): offsetToTop (0) and typeInfo (nullptr) sit at offsets -16 and -8 relative to dispatch, followed by the 8 virtual table slots matching the 64-byte dispatch table assert.
    • Verified null safety and default return semantics for getters _ZNK7WebCore16TrackPrivateBase2idEv, labelEv, languageEv, and startTimeVarianceEv in TrackPrivateBase.cpp: each getter returns the static EmptyAtom or MediaTime::zeroTime copy without dereferencing the self pointer.
    • Verified reference counting and string lifecycle in TrackPrivateBase.cpp and tests/TrackPrivateBase.cpp: EmptyAtom safely wraps EmptyStringImpl with balanced ref and deref lifecycles returning refCount to baseline.
    • Verified symbol consistency across core/libs/prx/libSceNKWebKit/Export.cpp, include/InventoryExports.hpp, and include/TrackPrivateBaseExports.hpp: replaced throwing stubs are cleanly excised from inventory exports and properly declared with APS5_VABI.
    • Verified LP64 (Linux) and LLP64 (Windows) compatibility: pointer sizes, std::ptrdiff_t, uint32_t members, and struct padding compile to identical 16-byte object and 80-byte storage layouts under APS5_VABI.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5900919440 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19704#pullrequestreview-5900919440). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T02:34:14Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `941839c083`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `nkwebkit_trackprivatebase_tests` built cleanly. - **CTest** (`nkwebkit_trackprivatebase`): ``` 1/1 Test #3916: nkwebkit_trackprivatebase ........ Passed 0.01 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/libSceNKWebKit.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified object layout and alignment in core/libs/prx/libSceNKWebKit/src/TrackPrivateBase.cpp: vptr is positioned at offset 0 (8 bytes) and refCount initialized to 1 at offset 8 (4 bytes), leaving offsets 12-15 untouched so derived class member tail padding is not clobbered under the Itanium ABI. - Verified vtable storage layout in TrackPrivateBaseVtableStorage (core/libs/prx/libSceNKWebKit/src/TrackPrivateBase.cpp): offsetToTop (0) and typeInfo (nullptr) sit at offsets -16 and -8 relative to dispatch, followed by the 8 virtual table slots matching the 64-byte dispatch table assert. - Verified null safety and default return semantics for getters _ZNK7WebCore16TrackPrivateBase2idEv, labelEv, languageEv, and startTimeVarianceEv in TrackPrivateBase.cpp: each getter returns the static EmptyAtom or MediaTime::zeroTime copy without dereferencing the self pointer. - Verified reference counting and string lifecycle in TrackPrivateBase.cpp and tests/TrackPrivateBase.cpp: EmptyAtom safely wraps EmptyStringImpl with balanced ref and deref lifecycles returning refCount to baseline. - Verified symbol consistency across core/libs/prx/libSceNKWebKit/Export.cpp, include/InventoryExports.hpp, and include/TrackPrivateBaseExports.hpp: replaced throwing stubs are cleanly excised from inventory exports and properly declared with APS5_VABI. - Verified LP64 (Linux) and LLP64 (Windows) compatibility: pointer sizes, std::ptrdiff_t, uint32_t members, and struct padding compile to identical 16-byte object and 80-byte storage layouts under APS5_VABI. 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!19704
No description provided.