Skip to content

feat(libSceNKWebKit): implement WebCore::BlobDataItem::length - #25169

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
XFlawless1:feat/nkwebkit-blob-data-item-length
Nov 22, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
XFlawless1:feat/nkwebkit-blob-data-item-length

Conversation

@XFlawless1

Copy link
Copy Markdown
Contributor

What

Export Pinned source Output
WebCore::BlobDataItem::length() const (_ZNK7WebCore12BlobDataItem6lengthEv, wAWyYd8-0Bk) BlobData.cpp#L44-L61, BlobDataFileReference.cpp#L58-L66 m_length unless it is toEndOfFile (-1); for a file item with -1, the file reference's m_size

Layouts: the 40-byte BlobDataItem (int Type @0, RefPtr<DataSegment> @8, RefPtr<BlobDataFileReference> @16, long long offset @24 and length @32, Type::Data = 0, Type::File = 1) follows the pinned BlobData.h#L43-L96 and is declared with static asserts in the new BlobDataItemExports.hpp. The file size is read at offset 32 of the existing BlobDataFileReference model (src/BlobDataFileReferenceAbi.hpp), which matches the pinned BlobDataFileReference.h#L56-L69 without FILE_REPLACEMENT. Neither layout is compared with a console module. The item and the size are read with GuestCopyIn_nid_no_patch; an unreadable pointer faults as not implemented, and a null item or a null file reference for an unknown length throws std::invalid_argument where the module would crash. A data item or an unknown type with -1 returns -1, as the release build does past ASSERT_NOT_REACHED.

Tested

Windows 11, MinGW GCC 15.2, Release.

  • nkwebkit_blobdataitem passes:
    • a known length is returned as is for data and file items (123, 0, 50 with an offset, and the -1/-2 values of a data item, as upstream returns m_length there after its debug assert);
    • a file item with toEndOfFile returns the referenced file's size (4096, 0 and 2^40) without changing the reference;
    • a file item with a known length never reads the file reference; an unknown type returns m_length;
    • a null item or a toEndOfFile file item without a reference throws std::invalid_argument; unreadable guest memory reports not-implemented.
  • Negative controls, each rebuilt and run, each makes the test fail: returning m_offset instead of m_length; reading the file size at the expectedModificationTime offset.
  • After a full build on current main, all nkwebkit_* tests pass, as do the registration|conventions_pr_template|pr_overlap_exports|conventions_unknown_nids tests and every public_headers_compile_* batch (the new header compiles on its own).
  • python tools/check_conventions.py --base origin/main passes. python tools/debt_fold.py --check currently fails on main itself (fix-libkernel-clock-id-15.md and docs-libkernel-clock-gettime-1360-divergence.md change the same libkernel entry); with that pre-existing pair set aside, it passes and folds this fragment.

Not tested on a console.

Overlap (python tools/pr_overlap.py --names and --branch feat/nkwebkit-blob-data-item-length):

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

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 d711c5f2c1:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_blobdataitem_tests built cleanly.
  • CTest (nkwebkit_blobdataitem):
    1/1 Test #4785: nkwebkit_blobdataitem ............   Passed    0.07 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/BlobDataItem.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WebCore::BlobDataItem layout matches upstream WebKit with 40-byte size, 8-byte alignment, and verified struct member offsets (type @ 0, data @ 8, file @ 16, offset @ 24, length @ 32).
    • Verified GuestCopyIn_nid_no_patch is used properly to read both BlobDataItem and BlobDataFileReference::size safely from guest memory.
    • Verified handling of length != kBlobDataItemToEndOfFile (-1), returning item.length directly for both data and file types.
    • Verified handling of kBlobDataItemToEndOfFile (-1): returns length directly for Data items, and copies/returns BlobDataFileReference::size cast to long long for File items.
    • Verified nullptr validation on self and item.file, throwing std::invalid_argument as specified in debt docs and verified by unit tests.
    • Verified AGENTS.md conventions, debt change fragment format, header inclusions in libSceNKWebKit.hpp, and removal of old stub in Export.cpp.

Looks Good To Me

@github-actions

Copy link
Copy Markdown

Progress report (8763aef → d711c5f)

📈 System libraries: 45.23% (+0.0025%, +1 implemented function)

✅ 1 implemented
Library Name
libSceNKWebKit _ZNK7WebCore12BlobDataItem6lengthEv

Changed libraries (implemented exports)

Library Before After Change
libSceNKWebKit 3859/11252 (34.30%) 3860/11252 (34.31%) +0.01%

@oneandonlydean
oneandonlydean merged commit 2500612 into boykopovar:main Nov 22, 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.

3 participants