Repository navigation
Conversation
…-backend-dispatcher
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Progress report (e481b13 → 3da439e)📈 System libraries: 44.65% (+0.05%, +19 implemented functions) ✅ 19 implemented
Changed libraries (implemented exports)
|
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against a902c297bb:
- Conventions:
tools/check_conventions.pypassed. - Build:
nkwebkit_forwarding_tests,nkwebkit_inspectorbackenddispatcher_tests,nkwebkit_jsonimpl_testsbuilt cleanly. - CTest (
nkwebkit_forwarding,nkwebkit_inspectorbackenddispatcher,nkwebkit_jsonimpl):1/3 Test #4479: nkwebkit_forwarding ................... Passed 0.01 sec 2/3 Test #4496: nkwebkit_jsonimpl ..................... Passed 0.01 sec 3/3 Test #4489: nkwebkit_inspectorbackenddispatcher ... Passed 0.10 sec 100% tests passed, 0 tests failed out of 3 - Negative control: with
core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/JsonExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp,core/libs/prx/libSceNKWebKit/src/WtfJson.cpp,core/libs/prx/libSceNKWebKit/src/WtfJsonObject.cpp,core/libs/prx/libSceNKWebKit/src/WtfJsonTypes.hpp,core/libs/prx/libSceNKWebKit/src/WtfNumberFormat.cpp,core/libs/prx/libSceNKWebKit/src/WtfTextAbi.hpp,core/libs/prx/libSceNKWebKit/src/InspectorBackendDispatcher.cpp,core/libs/prx/libSceNKWebKit/src/WtfJsonParse.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass. - Code reading:
- Verified libSceNKWebKit/src/InspectorBackendDispatcher.cpp dispatch routing, domain lookup, method parsing, and error reporting match upstream WebKit c55364d53f97 semantics.
- Verified BackendDispatcher and SupplementalBackendDispatcher destructor chaining and ref-counting (CreateBackendDispatcher, RefBackendDispatcher, DerefBackendDispatcher) avoid double frees and use exact WebKit layout.
- Checked protocol error serialization in SendPendingErrors for JSON-RPC 2.0 conformance and accurate error payload/data structure.
- Audited WtfJson.cpp and WtfJsonObject.cpp memory allocations, StringImpl refcounts, and string escaping for bounds/null safety and leak-free paths.
- Verified CallbackBase isActive, disable, and sendFailure error handling behavior against WebKit specifications.
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The dispatcher and JSON implementation are only partially inspected, so a formal merge decision is not justified; the author should address the review uncertainty before relying on this review.
What I ran
No commands or tests were run. I read the prepared description, commits, manifest, changed-file listing, and selected ranges of diff.patch; the repository reader was unavailable as a command in this session.
Results
| Check | Result | Note |
|---|---|---|
| Prepared bundle inspection | passed | Description, commits, manifest, and diff excerpts read |
| Source review | not run | Repository source could not be read at the pinned head |
| Tests | not run | No tests executed |
Findings
Blocking
None verified.
Non-blocking
No code-level feedback is offered because source implementation and callers were not verified against repository files.
Not verified
The listed changed files in review/manifest.json were not read through the pinned repository reader. Full source text for Export.cpp, InventoryExports.hpp, and docs/dev/debt/libSceNKWebKit.md was excluded from the prepared bundle. The only implementation evidence inspected was selected diff excerpts for InspectorBackendDispatcher.cpp, WtfJson.cpp, WtfJsonObject.cpp, and WtfJsonParse.cpp; no conclusions about uninspected code are made. Author-reported tests were not independently verified.
To get this to a good state
Nothing is required by a verified finding. Optional: complete source review at the pinned head and run the relevant checks before making a merge decision.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The pinned change has no verified blocking findings, but the review is incomplete because several changed files and portions of the diff were not inspected.
What I ran
Read the prepared review description, commit list, manifest and selected diff ranges. Used repo_read.py to read the dispatcher and parser sources and excerpts of JSON serialization and number formatting at head 72eecd137d58386b65b63c28f0e940c1538bd27c. No build or tests were run; the test results in the PR description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Source review | not run | Partial inspection only |
| Build and tests | not run | Author-reported results not verified |
Findings
Blocking
None verified in the portions inspected.
Non-blocking
None.
Not verified
The diff was not read in full. Source review was limited to InspectorBackendDispatcher.cpp, WtfJsonParse.cpp, and excerpts of WtfJson.cpp, WtfJsonObject.cpp, and WtfNumberFormat.cpp. Other changed files, including Export.cpp, InventoryExports.hpp, Forwarding.cpp, tests/InspectorBackendDispatcher.cpp, tests/JsonImpl.cpp, and the debt documentation, were not read. The manifest lists three additional changed files as excluded from the review folder because they were too large: Export.cpp, InventoryExports.hpp, and docs/dev/debt/libSceNKWebKit.md; their content was not inspected through the reader. No commands, build, or tests were run.
To get this to a good state
Complete the source review of the unread changed files and diff before making a formal approval decision. Nothing is required for the portions inspected.
|
Pushed 6c6ba33: Evidence: a decrypted PS4 Two more things the PS4 module shows, which I have not changed here:
Happy to move the core to the 11.x revision if you'd prefer that. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The review covered the dispatcher and JSON implementation at c7dcc8fe1f64b72344619373c03a6b092e1f8d2e; substantial tests and author-reported Linux runs are described, but were not run in this review.
What I ran
Read the prepared description, commit list, manifest and diff, plus targeted changed source ranges through repo_read.py. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Dispatcher and JSON code inspected |
| Test suite | not run | Only author-reported results available |
| Complete file review | not run | Some changed files were excluded or not read |
Findings
Blocking
None verified in the inspected code.
Non-blocking
- The error queue can be erased during a re-entrant frontend send.
SendPendingErrorssends the response before clearing the shared error list (core/libs/prx/libSceNKWebKit/src/InspectorBackendDispatcher.cpp:605). IfsendResponsesynchronously re-enters dispatch and queues errors, the outer call then clears those newly queued errors and resets the request id. Consider detaching the current batch before calling the router, or otherwise preserving errors added during the send.
Not verified
- The changed files read were
InspectorBackendDispatcherExports.hpp,JsonExports.hpp,libSceNKWebKit.hpp,InspectorBackendDispatcher.cpp, plus the indicated portions ofdiff.patchand review metadata. - The manifest reports
Export.cpp,InventoryExports.hppanddocs/dev/debt/libSceNKWebKit.mdas excluded from the review folder. Their full text and the remaining included changed files were not read; consequently this is not a complete file review. - Build/test execution, console behavior and the author-reported Linux Mint results were not independently verified.
To get this to a good state
Nothing is required. Optional: preserve errors queued by a re-entrant sendResponse, and verify the change with the project checks before merging.
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
@MarcZX10 On the re-entrant error send: the order is upstream's. At m_frontendRouter->sendResponse(message->toJSONString());
m_protocolErrors.clear();
m_currentRequestId = WTF::nullopt;so errors queued by a dispatch re-entered from |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
This review covers head 0e53c02b7c463665e172984da7bf2f189a0a88d1; it found one concrete JSON object ordering defect, and several changed files were excluded from full-text review.
What I ran
Read the prepared description, commit list, manifest, and diff, then used repo_read.py to inspect the dispatcher, JSON parser/serializer, object map, and relevant tests at the pinned head. No tests or build commands were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted code review | passed | Core dispatcher and JSON paths inspected |
| Build and tests | not run | Author reports 126 NKWebKit tests passed |
| Full changed-file coverage | not run | Three changed files were excluded |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceNKWebKit/src/WtfJsonObject.cpp:410— Parsing an object with a duplicate key overwrites its map value but preserves the key's original position inorder. UpstreamHashMap::setremoves and reinserts an existing key, so serialization should reflect the duplicate key's final insertion position. This affects serialized key order for inputs such as{"a":1,"b":2,"a":3}. Update the order when replacing an existing value, and cover duplicate-key replacement order in the JSON tests.
Not verified
- Full text was not available for
core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, anddocs/dev/debt/libSceNKWebKit.md; the prepared manifest excludes them. Their diff hunks were inspected where present. - The prepared manifest says all other changed files were included; I read targeted ranges from the new dispatcher and JSON code and inspected the changed test additions, but did not read every included file in full.
- No build, test, physical console behavior, or guest ABI validation was performed by this review. The test results in the PR description are author-reported.
To get this to a good state
Nothing is required. Optional: align duplicate-key replacement ordering with upstream and add a regression test.
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
@MarcZX10 On duplicate keys: upstream keeps the first position. if (m_map.set(name, WTFMove(value)).isNewEntry)
m_order.append(name);and
|
…or-backend-dispatcher
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
The review is incomplete because two changed files were excluded from the review bundle, and no checks were run.
What I ran
Inspected the prepared diff for head 0cd95339b1411b751793c9c9af2a25531c3b6b93; no commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff inspection | passed | Prepared diff reviewed |
| Tests | not run | No checks run in this review |
Negative control
Not run.
Findings
Blocking
None identified in the portions inspected.
Non-blocking
None.
Sources
Reviewed description.md, commits.md, manifest.json, and diff.patch; inspected changed lines for InspectorBackendDispatcherExports.hpp, JsonExports.hpp, libSceNKWebKit.hpp, InspectorBackendDispatcher.cpp, WtfJson.cpp, WtfJsonObject.cpp, WtfJsonParse.cpp, and WtfJsonTypes.hpp.
Not verified
Export.cpp and InventoryExports.hpp were excluded as too large for the review folder. The full changed test files and debt document were not read. No test results were independently verified.
To get this to a good state
Nothing is required. Optional: review the excluded files and run the relevant NKWebKit tests before making a formal decision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
The parser accepts unescaped control characters inside JSON strings, so malformed protocol messages can be treated as valid.
What I ran
Reviewed head 3da439efcf9d6d8ab39baaffbd82308265170982. No commands or tests were run; the author reports Linux Mint 22.3 oracle comparisons and 126 passing tests.
Results
| Check | Result | Note |
|---|---|---|
| Source review | failed | Parser accepts raw control characters |
| Tests | not run | Author-reported results only |
| Negative control | not run | No local test execution |
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/WtfJsonParse.cpp:173:ParseStringTokenaccepts any non-quote, non-backslash code unit, including unescaped control characters U+0000–U+001F. JSON strings forbid these characters, so malformed input such as a string containing a raw newline can be accepted and dispatched. Reject control code units below U+0020 unless escaped, and add a regression test.
Non-blocking
None.
Sources
Not verified
No tests or builds were run. Export.cpp and InventoryExports.hpp were listed as changed but their full text was not read; the final five lines of WtfJson.cpp were also not read. The remaining changed files were read, along with the prepared description, commits, manifest, and diff.
To get this to a good state
Reject unescaped control characters in JSON strings and add a regression test, then rerun the parser and dispatcher tests.
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
1 similar comment
|
Retested head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
@MarcZX10 on the unescaped control characters at |
|
This matches the parser being ported. |
Depends on boykopovar#22666 for object property insertion and serialization.
ligmaSec
left a comment
There was a problem hiding this comment.
Built the branch’s changed sources and ran Forwarding and InspectorBackendDispatcher on Linux against the existing runtime libraries. The test run passed and covered the Inspector dispatcher and export-forwarding cases.
AI-assisted: yes.
What
Implements the Inspector backend dispatcher core in
libSceNKWebKit. These are 19 exports that all throw onmaintoday, plus the JSON support they need.dispatch,reportProtocolError,sendPendingErrors,registerDispatcherForDomain,isActive,hasProtocolErrorsandD2.sendFailure,disable,isActive,D1andD2.C2,D0,D1andD2.Value::writeJSON,ArrayBase::writeJSONandValue::toJSONString.ForwardExports.cppdestructors ofBackendDispatcherand of the 22 domain dispatchers jump to these, so they now run real code. TheirRequireStublines intests/Forwarding.cppare dropped.Depends on #17864 (@alvaroelpob): this branch contains its head. It uses that PR's
ValueandArrayBasewriteJSONslots and itsNumberToString(double), which already follow the same 2020 revision. This PR only routes the twowriteJSONexports to those slots and adds the object slot,toJSONStringand parsing. @alvaroelpob, if you'd rather the two exports live in #17864, say so and I'll drop them here.Source: InspectorBackendDispatcher.cpp and JSONValues.cpp at
c55364d53f97(September 2020). The module's JSON exports use that revision's out-parameter API (asInteger(int&)), andlibSceJsc's agents use itsErrorString&handlers, so the dispatcher is that revision's, not the pinned 11.x one.dispatch:WtfJsonParse.cpp. The parser works on UTF-16 code units, limits nesting to depth 1000, and accepts\\xand\\vescapes.isSpaceOrNewline: ASCII spaces, plus the non-Latin-1 UnicodeWScharacters (U+1680, U+2000 to U+200A, U+2028, U+205F, U+3000).idandmethodwith the same JSON-RPC errors and messages, splitsDomain.methodon exactly one dot, and calls the registered dispatcher'sdispatchvtable slot.SetForScoperequest-id scopes are kept, so nested and re-entrant dispatches restore the outer id.intcut from the JSON double, as in the pinned 11.x dispatcher. That is the only behavioural difference between itsdispatchand the 2020 one. Ids outsideintbecome-2147483648, which is x86cvttsd2si.sendPendingErrorsbuilds the JSON-RPC 2.0 error object: the last error's code and message, all errors underdata, and"id":nullwhen no request id is set. It sends it through the existingFrontendRouter::sendResponse, then clears the errors and the id.SetValuefollows WTFHashMap::setand keeps the insertion order, on the table layoutWtfJsonObject.cppalready uses.ObjectBase'swriteJSONslot writes members in that order.Layouts:
BackendDispatcher(56 bytes): reference count, router at 8, domain map at 16, the errorVector<std::tuple<CommonErrorCode, String>>at 24 (libc++ tuple order, 16-byte elements), and the optional current id (value at 40, flag at 48, as a decrypted PS4libSceNKWebKitof the same generation reads it).SupplementalBackendDispatcher(24 bytes): vtable[D1, D0, dispatch], count at 8, dispatcher at 16.CallbackBase: 32 bytes.BackendDispatcher::createis not exported, so a library-internalCreateBackendDispatcherbuilds one. It allocates with the guestoperator new, and the lastdereffrees it withoperator delete.An unknown error code, a null domain or a null argument throws.
Debt: a fragment,
docs/dev/debt/changes/feat-nkwebkit-inspector-backend-dispatcher.md, adds the entry and removes the 19 inventory rows.Overlap: apart from #17864, which this depends on,
pr_overlap.pyfinds no open PR with these exports. It could not compare the NKWebKit PRs that conflict withmain(#13515, #14138, #14164, #14259, #14860, #16510, #17550, #17569, #17695, #17771, #17793, #17805, #17922, #17927, #17933, #18395, #18797, #20319, #20327, #20771, #21957, #22557). Their changes are inExport.cpp, the export headers and the shared include line, and none of them touch the dispatcher or JSON serialization.Tested
Linux Mint 22.3.
JSONValues.cppandInspectorBackendDispatcher.cpp, compiled against WTF with the 2020 JSON namespace renamed, with a capturingFrontendRouter. Its request id is read asint, which is the one line where the 11.xdispatchdiffers.int,1e400or1e-400; everymethodshape; duplicate keys; escapes, surrogates and raw non-ASCII; Unicode whitespace; nesting at 997 to 1002 levels; 8-bit and 16-bit strings.dispatch.nkwebkit_inspectorbackenddispatchertest: 16 sequences of 400 messages match. As a one-off, 200 sequences of 3,000 also matched.NaN, infinity,-0and1e21;int(answered with"id":-2147483648);SetForScoperestore fails the transcript check, and lowercase\\uhex fails the writer check.forwardingand feat(nkwebkit): implement JSON Value::writeJSON #17864's JSON test.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)