Skip to content

feat(nkwebkit): implement JSON Value::writeJSON - #17864

Merged
oneandonlydean merged 12 commits into
boykopovar:mainfrom
alvaroelpob:feat/nkwebkit-json-value-serialization
Nov 19, 2026
Merged

oneandonlydean merged 12 commits into
boykopovar:mainfrom
alvaroelpob:feat/nkwebkit-json-value-serialization

Conversation

@alvaroelpob

@alvaroelpob alvaroelpob commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Implement WTF::JSONImpl::Value::writeJSON for scalar values and ArrayBase::writeJSON for recursive array serialization using the pinned PS5 WebKit behavior.

Tested

Linux: suite.py feat/nkwebkit-json-value-serialization at 9cd5236: CTest 4813/4813 passed; conventions passed.

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

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Progress report (d3206ad → 9cd5236)

📈 System libraries: 41.62% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceNKWebKit ArrayWriteJSON
libSceNKWebKit ValueWriteJSON

Changed libraries (implemented exports)

Library Before After Change
libSceNKWebKit 3174/11261 (28.19%) 3176/11261 (28.20%) +0.02%

@JJenkx

JJenkx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Windows check of head bdcda4af95, merged onto main 3cd86e6ea7 (7d6d5b4163, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • nkwebkit_jsonimpl passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@alvaroelpob
alvaroelpob marked this pull request as ready for review November 9, 2026 19:02
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 22678 core/libs/prx/libSceNKWebKit/src/WtfNumberFormat.cpp L143
PR 22684 core/libs/prx/libSceNKWebKit/src/WtfNumberFormat.cpp L143
PR 22689 core/libs/prx/libSceNKWebKit/src/WtfNumberFormat.cpp L143
PR 22937 core/libs/prx/libSceNKWebKit/src/WtfNumberFormat.cpp L143

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.

Pull request Shared files not compared
PR 13515 docs/dev/debt/libSceNKWebKit.md
PR 14138 docs/dev/debt/libSceNKWebKit.md
PR 14164 docs/dev/debt/libSceNKWebKit.md
PR 14259 docs/dev/debt/libSceNKWebKit.md
PR 14860 docs/dev/debt/libSceNKWebKit.md
PR 16510 docs/dev/debt/libSceNKWebKit.md

@alvaroelpob
alvaroelpob force-pushed the feat/nkwebkit-json-value-serialization branch from e5f6c34 to 419f926 Compare November 11, 2026 01:11
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Rebased onto main.

  • 9ff3bde: strings are escaped as Value::escapeString does in the WebKit revision the console's exports match (c55364d53f97, JSONValues.cpp:528-566). That means the short escapes, \uXXXX with upper-case hex for <, >, control characters and code units from 127, and surrogates one at a time. It no longer calls the 11.x appendQuotedJSONString, which escapes differently.
  • e3f234f: the test covers <, >, control characters, Latin-1, a BMP character, a surrogate pair and a null string.
  • 419f926: the debt entries cite that revision and state their gaps first.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

One change is needed before this can pass: the licence header.

core/libs/prx/libSceNKWebKit/src/WtfJson.cpp has no licence text, and the debt entries for Value::writeJSON and ArrayBase::writeJSON say the bodies (and the string escaping) are adapted from WebKit's JSONValues.cpp. Ported code has to keep its licence notice verbatim. Please add the copyright and licence header from the top of JSONValues.cpp at the WebKit revision your debt entry cites, copied as it is. WtfNumberFormat.cpp already carries the V8 header, so that file is fine. Other NKWebKit files on main, such as BmallocFreeList.cpp, show the convention.

The escaping and the null, bool, number and string cases look right against upstream. If you can, a test with a nested array, a large or exponent double and negative zero would cover what the current tests miss.

@ycbuzi

ycbuzi commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Tested 419f9264c4 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 5627; 99% tests passed, 3 tests failed out of 5627. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 5627; 100% tests passed, 0 tests failed out of 5627. run

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@alvaroelpob

Copy link
Copy Markdown
Contributor Author

Added the WebKit JSONValues.cpp notice verbatim with the line it is derived from (724ba30), and tests for -0, 1e21, the 21-digit value below it, 1.5e-7, 1e-6, -2.5e300 and nested arrays (9cd5236).

@RiverWhy

Copy link
Copy Markdown
Contributor

Hi @alvaroelpob, some evidence that might matter for the JSON writer here. I'm not asking for anything in particular; I'd just rather you see it before this merges.

I got a decrypted PS4 libSceNKWebKit.sprx whose WebKit is the same generation as the PS5 11.x module. It exports 5,120 of the 5,161 names in libSceNKWebKit's export inventory, and its Inspector handlers use the newer Protocol::ErrorStringOr style. So the module most likely matches the pinned 11.x source rather than the September 2020 revision. That's the same revision my #22666 followed, and I've since moved its request id handling to 11.x.

The pinned StringBuilderJSON.cpp / EscapedFormsForJSON.h writer differs from the 2020 one in a few ways:

  • <, > and non-ASCII characters are written as-is, not as \u escapes.
  • Control characters and unpaired surrogates use lowercase \u00xx / \uxxxx.
  • Output is 16-bit as soon as a 16-bit string is appended.

I checked the width difference directly. With the pinned 11.x dispatchers as an oracle (#23061's test), every response carrying a 16-bit string comes back 16-bit there and 8-bit through the 2020 writer. The text was identical in my runs, which were ASCII-only. I didn't check whether NumberToString changed between the two revisions.

If you'd like, I can send the oracle setup.

@oneandonlydean
oneandonlydean merged commit 470fcf3 into boykopovar:main Nov 19, 2026
14 of 18 checks passed
@alvaroelpob

Copy link
Copy Markdown
Contributor Author

@RiverWhy thanks, this is useful. The 5,120 of 5,161 export match and the Protocol::ErrorStringOr handlers point at the pinned 11.x source, so the writer should follow its StringBuilderJSON.cpp / EscapedFormsForJSON.h: <, > and non-ASCII written as-is, lowercase \u escapes for control characters and unpaired surrogates, and 16-bit output once a 16-bit string is appended. This PR is merged, so I'll make that change in a follow-up PR and compare NumberToString between the two revisions there. Yes, please send the oracle setup; I'd like to run the follow-up against #23061's dispatchers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants