feat(libSceNKWebKit): implement diagnostic logging keys, MediaTime, MIME registry, JSON values, WTF values and region geometry #13992
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13992"
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-31T14:35:49Z.
What
Replaces 297
libSceNKWebKitstubs with implementations that follow the WTF and WebCore sources of the PS5 11.x WebKit snapshot at neonmodder123/PS5-WebKit-11.x@80f77e9, evaluated for the PlayStation build. That repository is a personal mirror, not a Sony repository. The files it was read from match Sony's own archive: the PS5 open source page linksWebKit-1100.zip(https://secure.cdn.us.playstation.com/oss/PS5/webkit/WebKit-1100.zip, 1,620,748,361 bytes, Last-Modified 10 Aug 2026), and the 18 upstream files these implementations follow (Region.cpp/.h,DiagnosticLoggingKeys.cpp,MediaTime.cpp/.h,PlatformTimeRanges.cpp,TimeRanges.cpp,MIMETypeRegistry.cpp,MIMETypeRegistryPlayStation.cpp,LegacySchemeRegistry.cpp,JSONValues.cpp/.h,PersistentEncoder.cpp,PersistentDecoder.cpp,URL.cpp,WTFString.cpp,StringView.cpp,StringImpl.cpp) have the same CRC-32 and size in that archive's central directory as in the mirror. Only the central directory was read, so no hash of the whole archive is claimed. Every implemented export was compared with its definition in the mirror; the ones that differed in some input, or that depended on something not present, were put back to stubs.WebCore::DiagnosticLoggingKeyskey strings and the memory and CPU usage bucketing helpersWTF::MediaTime(48),WebCore::PlatformTimeRanges(30),WebCore::TimeRanges(13),WTF::abs(MediaTime)(1)WebCore::MIMETypeRegistry(18) andWebCore::LegacySchemeRegistry(16)WTF::JSONImplvalues, objects and arraysWTF::Persistenceencoder, decoder and checksum (20),WTF::URLaccessors and host classification (9),WTF::String(7),WTF::StringViewsplit iterator (2),WTF::StringImpl(2)WebCore::RegionLayouts are pinned with
static_assert.WTF::MediaTimehas a user-provided copy constructor and copy assignment, as upstream (MediaTime.h), so it is not trivially copyable and every export returning it by value uses the Itanium hidden result pointer;tests/MediaTime.cppcallsabs,toTimeScaleandoperator+through function pointers with the guest shape (result pointer first). Other non-trivial class returns (WTF::String,Ref,Vector) also use the hidden result pointer, as in #13500.WTF::Vectoris defined once insrc/WtfVector.hpp.src/Region.cppandsrc/DiagnosticLoggingKeys.cppare ports ofWebCore/platform/graphics/Region.cppandWebCore/page/DiagnosticLoggingKeys.cppand keep Apple's BSD notice; the other new files are reimplementations.Stays
NotImplemented_nid_no_patchand recorded indocs/dev/debt/libSceNKWebKit.md: everything that formats numbers (MediaTime::toString,String::number*) or serialises JSON (writeJSON, including theValueandArrayBasevirtual slots), because upstream uses WTF's double-conversion andStringBuilder;MIMETypeRegistry::canShowMIMEType,extensionsForMIMETypeandallowedFileExtensions, which depend on the media player or areASSERT_NOT_IMPLEMENTED_YET()upstream; and theFilterOperationsubclasses, whose objects are dispatched through the module's own vtables.The
operator newanddeleteofMediaTimeandPlatformTimeRangesand thePersistence::Decoderdestructors are left out because #13930, #13936 and #13947 implement them.Tested
Windows 11, MinGW GCC 13.1 (host ABI, the library's
src/*.cppplus each test's own source linked into one executable). The six new suites (DiagnosticLoggingKeys,MediaTime,JsonImpl,MimeTypeRegistry,WtfValues,RegionGeometry) build together in the same tree and each exits 0; their expected values are derived from the upstream source, not from the implementation. Every source and test file of this PR also compiles with-fsyntax-onlyusing the realAPS5_VABI(sysv_abi) and the CI flags.python3 tools/check_conventions.py --base upstream/mainandpython3 core/libs/tests/test_public_headers.py --audit-onlypass. The guest runtime needs WinLibs 15.2 or MSYS2, so the guest build and CTest run are left to CI. Not tested with a title or on Linux.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-31T14:42:56Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The exact-head Windows CI build fails because two JSON vtable callbacks do not use the
APS5_VABIcalling convention required by their function-pointer types.What I ran
Reviewed head
ff86b3668f815894f0682ea509e75e8dfaa30106against base73f4f7e06e4f210a8c6570e335fd654dc0a86134; no local build or merge-preview was run. Environment: Debian Linux 6.1 x86_64, Python 3.11.2.I inspected the failing assignments in
WtfJson.cppand the callback declarations inWtfJsonTypes.hppat this head.Results
src/WtfJson.cppat both vtable callback assignments.Unedited Windows compiler output
Unedited diff-check output
Findings
Blocking
ValueVtable::writeJSONis declared withAPS5_VABIinsrc/WtfJsonTypes.hpp, butValueWriteJSONandArrayWriteJSONare ordinary host-ABI functions assigned to it atWtfJson.cpp:85and:99. MinGW rejects both conversions, so the library build cannot complete.The minimal fix is to give both callbacks the required calling convention, or provide wrappers with that signature:
Apply the same
APS5_VABIannotation toArrayWriteJSON.Non-blocking
None identified from the reviewed evidence.
Sources
APS5_VABIrequirement at the reviewed headNot verified
I did not run the local Windows build, Linux build, the six standalone suites, a title, or console behavior. CI's Linux and specialized product jobs were skipped.
To get this to a good state
Add
APS5_VABIto both callback definitions (or use wrappers with that signature), then rerun the Windows build and the standalone suites. I will recheck the new head and rerun the same available checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T14:46:51Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The new head fixes the Windows calling-convention errors, but leaves two live JSON vtable callbacks as silent no-ops.
What I ran
Rechecked head
e77cd2cc2c3f736f83dd8368726d53f6b2a3e153against base73f4f7e06e4f210a8c6570e335fd654dc0a86134; no build or C++ tests were run locally. Environment: Debian Linux 6.1 x86_64, Python 3.11.2.I inspected the new head's callback definitions, vtable assignments, and exported
writeJSONhandlers. The no-build precheck's diff, convention/template, and dependency checks passed; its ABI and test-quality helpers were unavailable in the isolated checkout because those local helper files are not in the PR tree.Results
Valuevtables. The exportedValue::writeJSONandArrayBase::writeJSONhandlers still throw as unimplemented.Unedited hosted check summary
Findings
Blocking
ValueWriteJSONandArrayWriteJSONare installed into thewriteJSONentries of theValueandArrayvtables, but their bodies return without appending anything to the suppliedStringBuilder. A guest calling these virtual methods therefore gets a normal return with no JSON output, while the corresponding exportedwriteJSONhandlers inExport.cppcorrectly remain throwing stubs. Either implement these callbacks and test serialized output, or make the callbacks throw and keep the unsupported behavior explicit in the debt inventory.For the unsupported case, the minimal safe callback behavior is:
Apply the same behavior to
ArrayWriteJSON.Non-blocking
The earlier Windows compile failure is addressed by adding
APS5_VABIto both callback definitions.Sources
writeJSONhandlers still throw at the reviewed headNot verified
The updated Windows build was pending, and I did not run the standalone JSON suites, Linux build, title, or physical-console behavior.
To get this to a good state
Implement and test both JSON writers, or make both vtable callbacks throw and ensure the unsupported paths are recorded. I will recheck the new head and rerun the same available checks.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T15:01:58Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The new head makes the JSON vtable callbacks fail explicitly, but the
MediaTimereturn ABI still does not match the guest class definition.What I ran
Reviewed head
5b76cddbaf458b3dedceaf136d65136e9e1b866aagainst base73f4f7e06e4f210a8c6570e335fd654dc0a86134; the current-base merge preview is clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or run C++ tests.I also inspected the changed JSON callbacks and
MediaTimedeclaration/return definitions at the exact head.Results
Unedited precheck convention output
Findings
Blocking
MediaTypes.hppdeclaresWTF::MediaTimewithout a user-declared copy constructor, so this local 16-byte type is trivially copyable. The PR nevertheless implements the exportedMediaTimecopy-constructor symbol and exposes multiple functions returningMediaTimeby value. Under the Itanium C++ ABI, a class with a non-trivial copy constructor is returned through a hidden result pointer; a locally trivial declaration instead returns the two-word value in registers. This makes the implementation's calling sequence incompatible with guest callers for those return-by-value exports. Add the guest-compatible copy constructor to the type declaration and assert the intended ABI property, or implement/test wrappers that use the guest's hidden-result-pointer convention. The current tests call through this PR's own type declaration, so they cannot prove compatibility with the guest call sequence.Non-blocking
Sources
MediaTimedeclaration and layout at this head.Not verified
I did not build the Windows target, run the six standalone suites, or confirm the calling sequence against a console. Windows CI was pending; Linux and specialized product jobs were skipped.
To get this to a good state
Make the
MediaTimedeclaration and return-value ABI match the guest, then add a test that calls through the guest ABI shape and rerun the Windows build. I’ll recheck the new head and the same relevant commands.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-31T19:33:00Z.
Review: CHANGES_REQUESTED
Reviewed
59b102a72bec8c225e6dd54b7b6c2517eabe1d6e. The earlier hidden-result-pointer, JSON callback and range-cleanup fixes are present, but multiplication still has an independent overflow defect.[P1] Preserve the multiplicand when checked multiplication fails (
src/Media.cpp:708).__builtin_mul_overflow(a.m_timeValue, rhs, &a.m_timeValue)writes the wrapped product even on failure. The following sign check and rescaling therefore use corrupted input. Reproduced through the exported guest-ABI function:MediaTime(INT64_MAX, 1, Valid) * 2returns negative infinity, whileMediaTime(INT64_MAX - 1, 2, Valid) * 2returns-4/1instead of9223372036854775806/1. Calculate into a temporary and assign only after success, as the addition/subtraction fixes already do; add both saturation and finite-rescaling regressions.[P2] Integrate the ported third-party sources through a pinned source dependency. The PR explicitly identifies
src/Region.cppandsrc/DiagnosticLoggingKeys.cppas WebKit ports and retains Apple's notices, but adds them directly to the main source tree. CONTRIBUTING.md requires new third-party code to be a source-built submodule under3rdparty/. Please place the adapted files behind that integration (retaining their notices and source mapping), or obtain a maintainer-approved policy exception. This concerns the repository's contribution rule, not a legal determination.Validation: all six supplied suites pass with the real Windows guest System V ABI under MSYS2 GCC 16.2 Release. The independent multiplication test fails on submitted code; a diagnostic copy changing only the product temporary makes it and all six suites pass (7/7). An independent allocation counter covers 1,000 TimeRanges create/union/intersect/invert/destruction cycles: 11,000 allocations, zero live afterward. Hosted Windows ran the new suites and reported 2,529/2,529 selected tests passing, demonstrating that the submitted tests miss this multiplication boundary. Local WebKit tests link selected sources with minimal libc support, not the full JavaScriptCore/libc runtime. Whitespace passes; no title or console run is claimed.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-31T20:49:34Z.
Review: APPROVED
Re-reviewed
ef6ca18c9bf6c04daf915e237386e28ca9da39f5. My P1 multiplication finding is resolved: the product is calculated into a temporary and committed only on success, preserving the original sign and value during saturation/rescaling. The added positive/negative overflow and finite-rescaling cases cover the reported defect.Validation: all six supplied WebKit suites plus the independent multiplication and ownership checks pass (8/8) on Windows/MSYS2 GCC 16.2 Release with the real guest System V ABI. Running the updated tests against the previous multiplication implementation fails both
MediaTimeand the independent reproducer. The ownership check still records 11,000 allocations and zero live allocations after 1,000 cycles. Current-head hosted Windows also executes all six new suites and reports 2,539/2,539 selected tests passing. Whitespace passes; the review worktree is clean. Local checks use the previously documented focused harness, not the full JavaScriptCore/libc runtime.I withdraw P2 as a blocking finding. I verified the existing in-tree
CharactersToNumber.cppandDateParsing.cppports and their retained notices, including the cited notice commits. My categorical submodule request was too broad in light of that established practice; the integration choice for these adapted files can remain with the maintainers.No new actionable issue found in this follow-up. This approval supersedes my previous changes-requested review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T20:56:03Z.
Review: APPROVED
Re-checked — new head, looks good
The current head fixes the reported
MediaTimeoverflow and return-ABI issues, and an independent reviewer reports the focused regressions passing.What I ran
Reviewed head
ef6ca18c9bf6c04daf915e237386e28ca9da39f5against base0836dfdf4fecb1e0326100c490476e15d3a74da5. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I ran the repository's no-build precheck and inspected the exact-headMediaTimedeclaration and overflow fix. I did not build or run C++ tests locally.Results
Unedited local check output
Findings
Blocking
None found in this follow-up. The current
MediaTimetype declares a non-trivial copy constructor and asserts it is not trivially copyable; the new multiplication fix commits the result only after checked multiplication succeeds. These address my prior ABI and overflow findings.Non-blocking
The Linux build and console behavior remain unverified on this head.
Not verified
I did not run a local build, CTest, Linux build, title, or physical-console test. The focused Windows results above are from another reviewer, not my environment.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-01T15:08:02Z.
Review: APPROVED
Re-reviewed
b1e775f3b1d0ded46b7b1f08528cfb9b143299c9. No new actionable issue found. The multiplication implementation and regression test are unchanged from the fix I previously approved; the latest follow-up adjusts the debt inventory count.Rebuilt the focused Windows/MSYS2 GCC 16.2 Release harness with the real guest ABI: all six supplied suites plus the independent multiplication and allocation/ownership checks pass, 8/8. The main checkout was not modified. Current-head hosted checks were queued when inspected, so I am not claiming a new full-project CI pass. The local harness uses selected WebKit sources and minimal libc support; no console/title run was performed.