feat(libSceNKWebKit): implement the WebKit C API objects, preferences, JavaScriptCore C API and WTF primitives #13500
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13500"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-10-30T17:04:04Z.
What
Replaces 1137 of the 11235
libSceNKWebKitstubs with implementations that follow Sony's OSS WebKit for PS5 11.x (neonmodder123/PS5-WebKit-11.x@80f77e9), evaluated for the PlayStation build:WKRetain,WKRelease,WKGetTypeID, every*GetTypeID) and value types:WKString,WKURLstored strings,WKArray/WKMutableArray,WKDictionary/WKMutableDictionary,WKData, numbers, geometry,WKUserContentURLPatternparsing,WKCertificateInfoandWKErrorCopyWKErrorDomain.WKPreferences*(398 exports) with the PlayStation defaults fromUnifiedWebPreferences.yaml.WKContextConfiguration,WKPageConfiguration,WKWebsiteDataStoreConfiguration,WKWebsitePolicies,WKUserScript,WKUserContentController,WKCredential,WKGeolocationPosition,WKPageGroup.JS*, 129 exports) on QuickJS-NG, added as the3rdparty/quickjssubmodule (v0.17.0) and built from source;JSStringRefvalues arelibSceJscstrings.Colorvalues; WTF allocation, bmalloc, Gigacage, assertions, clocks and random values;WTF::String,StringImpl,StringView,CStringandURLvalue operations with layouts pinned bystatic_assert.Exports that need the WebKit engine, the WebCore URL parser or layouts that cannot be proven from the source stay
NotImplemented_nid_no_patch. Gaps (QuickJS GC versus the conservative stack scan, unknown media preference defaults, host services, layouts verified on Windows only) are indocs/dev/debt/libSceNKWebKit.md, and the implemented names leave its export list.Tested
Windows 11, MinGW GCC (WinLibs UCRT), Release.
ctest -R nkwebkitruns six new suites (base, config, jsc, preferences, webcoregeometry, wtf); they passed 6/6 before this update. The suites cover round trips, defaults, null and empty cases, JSClass callbacks, exceptions, typed arrays, protect/unprotect acrossJSGarbageCollect, and string ownership throughfastFree. Not tested with a title or on Linux.This update rebases onto current
main, keeping theDateParsing.cppandCharactersToNumber.cppexports and tests that landed there, and makestryFastMalloc,tryFastZeroedMalloc,tryFastCallocandtryFastRealloctake the hiddenTryMallocReturnValue*result pointer first, as the Itanium ABI passes a type with a user-provided move constructor and destructor;tryFastAlignedMallocstill returnsvoid*.tests/Wtf.cppcalls them with that signature and checks the returned pointer and the value stored through it on success and failure.python3 tools/check_conventions.py --base upstream/mainandpython3 core/libs/tests/test_public_headers.py --audit-onlypass on this head; the C++ build and tests after this update are left to CI. ThelibSceJscstring exports thatlibSceNKWebKitcalls (JSStringCreateWithCharacters,JSStringCreateWithUTF8CString,JSStringRetain,JSStringRelease,JSStringGetLength,JSStringGetCharactersPtr,JSStringGetMaximumUTF8CStringSize,JSStringGetUTF8CString) now carry the_nid_postfixsuffix, sonid_patcherrenames the imports inlibSceNKWebKit.prxto the same NIDs as the exports and the Linuxpatched_librariesload resolves them; the NIDs are unchanged.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T17:15:05Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The exact-head public-header audit fails the repository rule, and the new allocator can wrap its allocation-size calculation for large requests.
What I ran
Reviewed head
e4894c3c6da20f401a1842e606b2423728bb011cagainst basea026562629da7bcc7af781639a11ab0647a524dd. A current-base merge preview was clean. Environment: Linux x86-64, Debian 12, Python 3.11.2, GCC 12.2.0; no C++ compiler command was run.The public-header audit was run from an archive of the exact PR head and, for comparison, an archive of base
a026562629da7bcc7af781639a11ab0647a524dd.Results
a026562629da7bcc7af781639a11ab0647a524dd.--audit-only)passed_with_warnings; lexical audit only, not ABI proof.file(GLOB)and a loop.Unedited check output
Findings
Blocking
JSString*declarations intests/Jsc.cpp, test-only declarations forWKArray*, and missing header declarations for exported functions. The repository requires every exportedAPS5_VABIfunction to have exactly one declaration in a header reachable through the library umbrella and forbids duplicates in tests. Add the required declarations to the public headers and remove duplicate/test-local declarations until the exact-head audit passes.AllocateandTryAllocateaddsize + alignment + sizeof(AllocationHeader)without checked arithmetic. For a request nearSIZE_MAX, this can produce a small allocation while storing the original large size in the header. The zeroed wrappers then write the requested length; for example,fastCalloc(1, SIZE_MAX)passes its multiplication check and callsmemsetwith that huge length after allocation. Check the additions before callingmalloc; make the try path returnnullptrand the non-try path follow its allocation-failure behavior. Add boundary coverage for the try and zeroed wrappers.Non-blocking
tests/Wtf.cppdeclares unused bmalloc prototypes with an extrasize_tparameter fortryLargeZeroedMemalignVirtual,commitAlignedPhysical, anddecommitAlignedPhysical. The pinned upstream WebKit declarations use(alignment, size, HeapKind)and(pointer, size, HeapKind)respectively. Correct or remove these declarations so the test file does not describe different symbols.Sources
Not verified
To get this to a good state
Fix the public-header audit errors and allocator overflow, then rerun the audit and relevant tests on the updated head. I’ll re-run the same checks against that head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T18:17:17Z.
Review: COMMENTED
Re-checked — new head, awaiting Windows CI
The updated head fixes the previously reported allocator-overflow and public-header declaration issues; I found no new source-level blocker, but the Windows build is still running.
What I ran
Reviewed head
0312a066453cff513919d9b5d15c04793e9e0fd1against PR basea026562629da7bcc7af781639a11ab0647a524dd; its merge preview against that base was clean. Environment: Linux x86-64, Python 3.11.2, GCC 12.2.0.Results
git diff --checkexited 0 with no output.passed_with_warnings; 26 warnings are callback/type names in test sources reported as missing function declarations. This lexical helper does not establish binary ABI correctness.tests/*.cppglob registers both test files and creates CTest entries.Unedited output from focused checks
The diff check exited 0 and emitted no output. The ABI audit summary was
passed_with_warningswith 26public-declaration-not-foundfindings, all names from test callback/type APIs. The test-quality helper emitted twopossible-unregistered-cpp-testwarnings; direct inspection confirmed the CMake glob andadd_testregistration.Findings
Blocking
None identified in the updated source. The previously reported allocation-size overflow is guarded before allocation, and the exact-head public-header audit now passes.
Non-blocking
Approval is withheld until the hosted Windows job completes because this update changes public C++ declarations and allocator code. The Linux job was skipped, and I did not run local C++ build or runtime tests.
Sources
Not verified
No local C++ build, CTest run, Linux build/runtime, or console behavior was verified. Hosted Windows CI was incomplete at the final check snapshot.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T18:24:54Z.
Review: APPROVED
Re-checked — new head, looks good
The public-header audit passes and the allocator boundary fix is in place; exact-head Windows CI and Emscripten portability checks passed. I approve head
0312a066453cff513919d9b5d15c04793e9e0fd1; Linux and specialized jobs were skipped, and I did not run a local build.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T19:15:09Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The four
tryFast*exports use the wrong return ABI: upstream returnsTryMallocReturnValue, while this PR exposesvoid*under the same symbols.What I ran
Reviewed exact head
0312a066453cff513919d9b5d15c04793e9e0fd1against basea026562629da7bcc7af781639a11ab0647a524dd. Environment: Linux x86-64, GCC 12.2.0, Python 3.11.2. I did not build or compile the project.Results
Unedited source output for the mismatched declarations
Findings
Blocking
void*for all four symbols, but the pinned WebKit interface returnsTryMallocReturnValue, a non-trivial C++ type with a move constructor and destructor. With the PS5 SysV ABI, a non-trivial aggregate return uses an indirect result pointer; keeping the same mangled name does not make thevoid*prototype ABI-compatible. A WebKit caller can pass its result pointer in the hidden-return register and shift the explicit arguments, causing these implementations to interpret the wrong values and return an incompatible result. Implement the actualTryMallocReturnValueABI (including its success/failure state), or leave these exports unimplemented until that ABI can be represented correctly.Non-blocking
None identified in this follow-up.
Sources
TryMallocReturnValuetype and four function declarationsAPS5_VABIuses the SysV ABI on the PS5 host pathNot verified
I did not compile a caller using the PS5 toolchain or run the WebKit runtime; the ABI defect is established from the pinned source interface, the PR prototypes, and the repository's
APS5_VABIdefinition. Linux and specialized hosted jobs were skipped.To get this to a good state
Correct these four exports to match
TryMallocReturnValue's target ABI and add coverage for its success and failure results. I’ll re-run the same source and no-build checks on the new head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-30T21:11:52Z.
Review: CHANGES_REQUESTED
Checked the head against the cited WebKit source; the earlier header and allocator-overflow points are fixed, and Windows CI is green. One blocking ABI problem remains, the one CodingBreadd and MarcZX10 raised:
tryFastMalloc,tryFastZeroedMalloc,tryFastCallocandtryFastRealloc(include/WtfExports.hpp:73-89,src/WtfMemory.cpp:49-75) are declared as returningvoid*. In the followed source (Source/WTF/wtf/FastMalloc.hL98-101) they returnTryMallocReturnValue, which has a user-provided move constructor and destructor (L77-86, L181-184). Under the Itanium C++ ABI that is returned in memory: the caller passes a hidden result pointer inrdi, the real arguments shift torsi/rdx/rcx, and the callee returns that pointer inrax. With the current signatures a WTF caller's result pointer is read as the size and no result is ever written. Fix: take the hiddenTryMallocReturnValue*first (storing the pointer through it, returning it), for all four, and keep the null-on-overflow behaviour.tests/Wtf.cpp:44-68calls the exports with the wrong signature, so it cannot catch this. Update it to the corrected signatures and check the value stored through the result pointer.tryFastAlignedMallocreturns a plainvoid*in the source, so it stays as is.tests/Wtf.cpp(tryLargeZeroedMemalignVirtual,commitAlignedPhysical,decommitAlignedPhysical) have an extrasize_tversus upstream's(alignment, size, HeapKind)/(pointer, size, HeapKind); fix or drop them.Happy to re-check once pushed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T09:34:24Z.
Review: APPROVED
Re-checked — new head, looks good
The hidden result-buffer implementation now matches the pinned WebKit
TryMallocReturnValueABI, and the exact-head Windows check passed.What I ran
Reviewed head
b7d83106ea189266c97bed91e25f91b25039d58cagainst PR based8ffa97effa1ab0113dc265d936e94322045875d; the merge preview against currentmainc3c45d73abd34dca81da6bad87cb6d36ea437a66was clean. Environment: Linux x86-64, Python 3.11.2. I did not run a local build.The precheck's diff and conventions checks passed. Its ABI-audit and test-quality helper commands could not run because those helper files are absent from the isolated PR checkout; I treated them as unavailable, not as code failures. GitHub's
windowsandlibrary-portabilitychecks passed on this exact head; Linux and specialized jobs were skipped. The precheck did not build or run C++ tests.Sources
The implementation and one-pointer result layout are in WtfMemory.cpp and WtfMemoryTypes.hpp; the pinned upstream declarations are in FastMalloc.h.
Not verified
No local build or Linux/specialized hosted job ran on this head. The Windows CI result is hosted evidence, not a local test run.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-31T10:04:37Z.
Review: CHANGES_REQUESTED
The full Build on this head fails on Linux (run 41189425926, job
linux):patched_librariesfails withlibSceNKWebKit.prx: undefined symbol: JSStringGetLength.src/String.cpp:79andsrc/JscContext.cpp:186calllibSceJscfunctions (prx/libSceJsc/include/Api.hpp) through a plain link dependency (CMakeLists.txt:23,PUBLIC libSceJsc). After NID patching,libSceJsc.prxexports the NID names, andlibSceNKWebKit.prxdoes not get its import renamed, sodlopencannot resolve it. Windows loads it, which is why the Windows run was green.Suggested direction: don't import
libSceJscsymbols fromlibSceNKWebKitat load time. Share theJSStringimplementation through a static library or object sources linked into both, or go through helpers that don't need a cross-library symbol, and check thatpatched_librariesloads every.prxon Linux.Everything else I checked on the previous review (the
tryFast*ABI, headers, allocator overflow, submodule, debt file) is fine.