Skip to content

fix(libSceNKWebKit): return a reference from ISOBox::boxType - #24651

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
ToRaNek:fix/nkwebkit-iso-box-type-reference
Nov 21, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
ToRaNek:fix/nkwebkit-iso-box-type-reference

Conversation

@ToRaNek

@ToRaNek ToRaNek commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What

ISOBox::boxType() returned the box's four-character code by value. In the module that exports it, it returns a reference.

The export is in the 3.20 inventory only. In the WebKit of that module the class is WEBCORE_EXPORT and the accessor is declared (ISOBox.h L51):

const FourCC& boxType() const { return m_boxType; }

so the caller receives the address of m_boxType and reads the code through it. The port followed the later revision, where the same accessor is FourCC boxType() const and the 32-bit value comes back in the register. A 3.20 caller would have taken that value, for example 0x7363686d, for a pointer and dereferenced it.

The export now returns &m_boxType, which is 16 bytes into the box (vtable pointer, 64-bit size, then the code). ISOBox.h is identical on 2020-06-13 (WebKit 34fe4d7c1658) and 2020-11-12 (9fd169d0da68), the window the 3.20 names allow.

The other 3.20 accessors of this class were checked against the same header and are unchanged: size() returns the 64-bit value, extendedType() already returns a reference.

Tested

Windows 11, MinGW GCC 15.2.

  • nkwebkit_isoboxaccessors passes: the returned pointer is the address of the field, it is 16 bytes from the start of the box, the code is read through it, and a later write to the field is visible through the same pointer.
  • Two negative controls, each rebuilt and run, each makes the test fail: returning the value in place of the address, which is what main does, and returning the address of the size field.
  • All 169 nkwebkit_* tests and patched_libraries pass on the branch.
  • python tools/check_conventions.py --base origin/main and python tools/debt_fold.py --check pass.

Not tested on a console.

Overlap (python tools/pr_overlap.py --branch fix/nkwebkit-iso-box-type-reference): no overlap with open pull requests.

It merges cleanly (git merge-tree) with the open PRs that work on the same files: #24534, mine, which fixes two other 3.20 getters in IsoBoxAccessors.cpp, and #22480, #22481 and #22482, which implement the ISO box parsers; none of them mentions boxType.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

boxType() is in the 3.20 inventory only. In the WebKit of that module
it is declared const FourCC& boxType() const, so the caller receives the
address of m_boxType and reads the code through it. The port returned
the 32-bit value itself, which is what the later revision's
FourCC boxType() const does; a 3.20 caller would have used that value
as a pointer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

The changed accessor and its test implement the stated reference return; the review bundle reports successful Windows tests, but I did not run them.

What I ran

Reviewed head 97276f896c8af766d2dea600be5c18c81ab1cc0a. No commands or tests were run; the prepared bundle and repository reader were used to inspect the change.

Results

Check Result Note
Changed source review passed Four changed files read
Tests and prechecks not run Results are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported test runs, negative controls, prechecks, PR overlap check, and merge-tree checks were not independently verified. No changed files were excluded; files.json was unavailable, so exclusions by rule are not verified.

To get this to a good state

Nothing is required.

@kiwe147

kiwe147 commented Nov 20, 2026

Copy link
Copy Markdown

Tested head 97276f896c, applied with git apply on main fd4aeed483 together with the other sixteen PRs of one batch (#24596, #24594, #24595, #24599, #24600, #24602, #24593, #24659, #24626, #24625, #24624, #24456, #24656, #22380, #24502, #24351). All seventeen applied without conflicts. The tree built except libSceAjm.prx: #24659 breaks it with duplicate patched export name: -qLsfDAywIY (checked alone on main, reported there). No other target failed to build.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
nkwebkit_isoboxaccessors (1 test) all pass outside the iGPU subset

Whole batch: the full ctest -j 12 (6524 tests) on the RTX 3080 has 4 failures, and all 4 also fail on main fd4aeed483 (agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10). The 2125 agc_/video tests on the iGPU fail agc_driver_stencil_plane_memory (also on main), agc_driver_store_over_untracked (also fails alone on main on this iGPU, 6 of 6) and agc_driver_image_table_packed_guards (passes 5 of 5 alone on this tree, known flaky). None of this batch touches AGC.

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 97276f896c:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_isoboxaccessors_tests built cleanly.
  • CTest (nkwebkit_isoboxaccessors):
    1/1 Test #4759: nkwebkit_isoboxaccessors .........   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/include/IsoBoxExports.hpp, core/libs/prx/libSceNKWebKit/src/IsoBoxAccessors.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified that ISOBox::boxType export signature matches WebKit 3.20 const FourCC& return type, returning const std::uint32_t* to match pointer/reference ABI in IsoBoxExports.hpp and IsoBoxAccessors.cpp.
    • Checked null-pointer verification in Checked(self, "ISOBox::boxType"), throwing std::invalid_argument when self is null.
    • Confirmed LP64 and LLP64 ABI compatibility for uint32_t pointer return across Linux and Windows GCC.
    • Verified technical debt documentation fragment docs/dev/debt/changes/fix-nkwebkit-iso-box-type-reference.md adheres to the required format and accurately describes the 3.20 inventory gap.
    • Audited IsoBoxAccessors.cpp test case in core/libs/prx/libSceNKWebKit/tests/IsoBoxAccessors.cpp for offset check (+16 bytes), pointer identity, and value mutability reflection.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 535da5c into boykopovar:main Nov 21, 2026
14 checks passed
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