feat(libSceNKWebKit): implement Inspector::FrontendRouter and AgentRegistry #16383

Merged
gslashm merged 7 commits from upstream-pr/16383 into main 2026-11-12 01:02:46 +00:00
gslashm commented 2026-11-06 13:59:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gslashm on 2026-11-06T13:59:07Z.


What

Implements 19 libSceNKWebKit exports from Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp and InspectorAgentRegistry.cpp at 80f77e94c6.

FrontendRouter: create, constructors (C1, C2), destructors (D1, D2), connectFrontend, disconnectFrontend, disconnectAllFrontends, hasFrontends, hasLocalFrontend, hasRemoteFrontend, sendEvent and sendResponse.
AgentRegistry: constructor (C2), destructors (D1, D2), didCreateFrontendAndBackend, willDestroyFrontendAndBackend and discardValues.

FrontendRouter::frontendCount is already implemented on main (FieldGetters.cpp, +0x14) and is not redefined here.

Placement: both files are hand-written ports in core/libs/prx/libSceNKWebKit/src/, with the upstream Apple licence notices kept verbatim, as the other NKWebKit ports do. The guest layouts are pinned in src/InspectorFrontendRouterAbi.hpp and the tests are in tests/. There is no submodule and no new build target; this follows the review decision against a WebKit submodule.

FrontendRouter is 40 bytes (refcount at 0, Vector<FrontendChannel*, 2> at 8, inline buffer at 24) and AgentRegistry is 16 bytes (Vector at 0), all pinned with static_assert and checked by the tests. create() returns Ref<FrontendRouter>, so it comes back through the hidden pointer as the 8-byte, non-trivially-destructible FrontendRouterRef. The guest FrontendChannel and InspectorAgentBase vtables are called with the console's SysV ABI from the port (connectionType slot 2, sendMessageToFrontend 3; agent didCreate 2, willDestroy 3, discardValues 4, discardAgent 5, deleting destructor 1), because host virtual calls use the Windows calling convention. disconnectAllFrontends uses upstream Vector::clear() (Vector.h:837), which calls shrinkCapacity(0): it frees the heap buffer and returns to the inline buffer with capacity 2. The reference count is a relaxed atomic in the same 4 bytes at offset 0; the pinned RefCounted is non-atomic, so the port is stricter but layout-compatible. A null object, channel or agent entry throws before any call. No title and no console module were used.

Tested

Windows 11 Pro, WinLibs GCC 15.2.0. Full build exit 0. ctest -R nkwebkit: 64 of 64. tools/check_conventions.py --base origin/main: no findings. tools/progress.py: libraries 2784 of 11258, 19 more than main's 2765 of 11258; debt 5975. git diff --check clean. No title or console module. ctest -R public_headers currently fails on main's libSceXml duplicate declarations in Api.hpp and InventoryExports.hpp; this PR does not touch that library.

Based on main e70363f52c, with the reviewer's fb858878d9 link fix and a6d087591e duplicate-count-line fix included. #16261 adds no FrontendRouter or AgentRegistry export. The debt count line is 5994 on main and 5975 here.

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 ported into core/ with its upstream licence notice kept verbatim, as the other NKWebKit files do; no new submodule, per review
  • 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:5188945362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16383). Originally posted by [gslashm](https://github.com/gslashm) on 2026-11-06T13:59:07Z. --- ### What Implements 19 `libSceNKWebKit` exports from `Source/JavaScriptCore/inspector/InspectorFrontendRouter.cpp` and `InspectorAgentRegistry.cpp` at `80f77e94c6`. `FrontendRouter`: `create`, constructors (`C1`, `C2`), destructors (`D1`, `D2`), `connectFrontend`, `disconnectFrontend`, `disconnectAllFrontends`, `hasFrontends`, `hasLocalFrontend`, `hasRemoteFrontend`, `sendEvent` and `sendResponse`. `AgentRegistry`: constructor (`C2`), destructors (`D1`, `D2`), `didCreateFrontendAndBackend`, `willDestroyFrontendAndBackend` and `discardValues`. `FrontendRouter::frontendCount` is already implemented on `main` (`FieldGetters.cpp`, `+0x14`) and is not redefined here. Placement: both files are hand-written ports in `core/libs/prx/libSceNKWebKit/src/`, with the upstream Apple licence notices kept verbatim, as the other NKWebKit ports do. The guest layouts are pinned in `src/InspectorFrontendRouterAbi.hpp` and the tests are in `tests/`. There is no submodule and no new build target; this follows the review decision against a WebKit submodule. `FrontendRouter` is 40 bytes (refcount at 0, `Vector<FrontendChannel*, 2>` at 8, inline buffer at 24) and `AgentRegistry` is 16 bytes (`Vector` at 0), all pinned with `static_assert` and checked by the tests. `create()` returns `Ref<FrontendRouter>`, so it comes back through the hidden pointer as the 8-byte, non-trivially-destructible `FrontendRouterRef`. The guest `FrontendChannel` and `InspectorAgentBase` vtables are called with the console's SysV ABI from the port (`connectionType` slot 2, `sendMessageToFrontend` 3; agent `didCreate` 2, `willDestroy` 3, `discardValues` 4, `discardAgent` 5, deleting destructor 1), because host virtual calls use the Windows calling convention. `disconnectAllFrontends` uses upstream `Vector::clear()` (`Vector.h:837`), which calls `shrinkCapacity(0)`: it frees the heap buffer and returns to the inline buffer with capacity 2. The reference count is a relaxed atomic in the same 4 bytes at offset 0; the pinned `RefCounted` is non-atomic, so the port is stricter but layout-compatible. A null object, channel or agent entry throws before any call. No title and no console module were used. ### 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 Pro, WinLibs GCC 15.2.0. Full build exit 0. `ctest -R nkwebkit`: 64 of 64. `tools/check_conventions.py --base origin/main`: no findings. `tools/progress.py`: libraries 2784 of 11258, 19 more than `main`'s 2765 of 11258; debt 5975. `git diff --check` clean. No title or console module. `ctest -R public_headers` currently fails on `main`'s `libSceXml` duplicate declarations in `Api.hpp` and `InventoryExports.hpp`; this PR does not touch that library. Based on `main` `e70363f52c`, with the reviewer's `fb858878d9` link fix and `a6d087591e` duplicate-count-line fix included. #16261 adds no `FrontendRouter` or `AgentRegistry` export. The debt count line is 5994 on `main` and 5975 here. ### 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 ported into `core/` with its upstream licence notice kept verbatim, as the other NKWebKit files do; no new submodule, per review - [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
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!16383
No description provided.