feat(libSceNKWebKit): implement WTF Cairo RefPtr helpers #24154

Closed
Nino4you wants to merge 1 commit from upstream-pr/24154 into main
Nino4you commented 2026-11-20 08:15:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nino4you on 2026-11-20T08:15:35Z.


What

Implement the four WTF::refIfNotNull and WTF::derefIfNotNull specializations for cairo_t and cairo_surface_t in libSceNKWebKit, following pinned WebKit Source/WebCore/platform/graphics/cairo/RefPtrCairo.cpp@c55364d53f971f63a709976f168d932d558b8909:

  • _ZN3WTF12refIfNotNullI6_cairoEEvPT_ -> forwards non-null handles to cairo_reference
  • _ZN3WTF14derefIfNotNullI6_cairoEEvPT_ -> forwards non-null handles to cairo_destroy
  • _ZN3WTF12refIfNotNullI14_cairo_surfaceEEvPT_ -> forwards non-null handles to cairo_surface_reference
  • _ZN3WTF14derefIfNotNullI14_cairo_surfaceEEvPT_ -> forwards non-null handles to cairo_surface_destroy

Removes the four throwing stubs from Export.cpp and include/LegacyExports.hpp, declares the typed SysV signatures in include/RefPtrCairoExports.hpp (included from libSceNKWebKit.hpp), adds tests/RefPtrCairo.cpp (nkwebkit_refptrcairo, linked with libcairo), and records technical debt in docs/dev/debt/changes/feat-nkwebkit-refptr-cairo.md.

Tested

Linux x86-64 (Debian 12, GCC 12.2.0, Ninja Release, BUILD_TESTING=ON), base upstream/main 7d2270cb86:

  • Compiled RefPtrCairo.cpp.o, Export.cpp.o, tests/RefPtrCairo.cpp.o, and libcairo.prx cleanly (full libSceNKWebKit link on GCC 12.2 hits pre-existing DragImageAbi.hpp union default-constructor error from #22977).
  • Linked RefPtrCairo.cpp.o + tests/RefPtrCairo.cpp.o against libcairo.prx and libc.prx and ran the test binary: passed (exit 0; verified null no-ops, CairoSurface refcounting via destroy user-data callback, CairoContext refcounting via tracked target surface lifetime, and interop with cairo_destroy / cairo_surface_destroy).
  • ctest --test-dir build -R '^public_headers$' --output-on-failure: 1/1 passed.
  • python3 tools/debt_fold.py --check: passed.
  • python3 tools/check_test_registration.py build: passed.
  • python3 tools/check_conventions.py --base upstream/main: all conventions checks passed (0 errors, 0 warnings).
  • python3 tools/guest_pointer_audit.py libSceNKWebKit: 0 findings in RefPtrCairo.cpp.
  • tools/pr_overlap.py --names (all 4 exports open: none) and tools/pr_overlap.py --branch feat/nkwebkit-refptr-cairo: 0 overlapping exports or new files.
  • Not run: Windows, a console or a title.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5410083279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24154). Originally posted by [Nino4you](https://github.com/Nino4you) on 2026-11-20T08:15:35Z. --- ### What Implement the four `WTF::refIfNotNull` and `WTF::derefIfNotNull` specializations for `cairo_t` and `cairo_surface_t` in `libSceNKWebKit`, following pinned WebKit `Source/WebCore/platform/graphics/cairo/RefPtrCairo.cpp@c55364d53f971f63a709976f168d932d558b8909`: - `_ZN3WTF12refIfNotNullI6_cairoEEvPT_` -> forwards non-null handles to `cairo_reference` - `_ZN3WTF14derefIfNotNullI6_cairoEEvPT_` -> forwards non-null handles to `cairo_destroy` - `_ZN3WTF12refIfNotNullI14_cairo_surfaceEEvPT_` -> forwards non-null handles to `cairo_surface_reference` - `_ZN3WTF14derefIfNotNullI14_cairo_surfaceEEvPT_` -> forwards non-null handles to `cairo_surface_destroy` Removes the four throwing stubs from `Export.cpp` and `include/LegacyExports.hpp`, declares the typed SysV signatures in `include/RefPtrCairoExports.hpp` (included from `libSceNKWebKit.hpp`), adds `tests/RefPtrCairo.cpp` (`nkwebkit_refptrcairo`, linked with `libcairo`), and records technical debt in `docs/dev/debt/changes/feat-nkwebkit-refptr-cairo.md`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86-64 (Debian 12, GCC 12.2.0, Ninja Release, `BUILD_TESTING=ON`), base `upstream/main` `7d2270cb86`: - Compiled `RefPtrCairo.cpp.o`, `Export.cpp.o`, `tests/RefPtrCairo.cpp.o`, and `libcairo.prx` cleanly (full `libSceNKWebKit` link on GCC 12.2 hits pre-existing `DragImageAbi.hpp` union default-constructor error from #22977). - Linked `RefPtrCairo.cpp.o` + `tests/RefPtrCairo.cpp.o` against `libcairo.prx` and `libc.prx` and ran the test binary: passed (exit 0; verified null no-ops, `CairoSurface` refcounting via destroy user-data callback, `CairoContext` refcounting via tracked target surface lifetime, and interop with `cairo_destroy` / `cairo_surface_destroy`). - `ctest --test-dir build -R '^public_headers$' --output-on-failure`: 1/1 passed. - `python3 tools/debt_fold.py --check`: passed. - `python3 tools/check_test_registration.py build`: passed. - `python3 tools/check_conventions.py --base upstream/main`: all conventions checks passed (0 errors, 0 warnings). - `python3 tools/guest_pointer_audit.py libSceNKWebKit`: 0 findings in `RefPtrCairo.cpp`. - `tools/pr_overlap.py --names` (all 4 exports `open: none`) and `tools/pr_overlap.py --branch feat/nkwebkit-refptr-cairo`: 0 overlapping exports or new files. - Not run: Windows, a console or a title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-20 08:17:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T08:17:49Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 3f9fed0369:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_refptrcairo_tests built cleanly.
  • CTest (nkwebkit_refptrcairo):
    1/1 Test #4751: nkwebkit_refptrcairo .............   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/RefPtrCairo.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 all 4 WTF ref/deref symbols (ZN3WTF12refIfNotNullI6_cairoEEvPT, ZN3WTF14derefIfNotNullI6_cairoEEvPT, ZN3WTF12refIfNotNullI14_cairo_surfaceEEvPT, ZN3WTF14derefIfNotNullI14_cairo_surfaceEEvPT) match WebKit upstream signatures with void return type and pointer parameter.
    • Verified null pointer safety in RefPtrCairo.cpp lines 8, 12, 16, 20 where nullptr handles are safely ignored as no-ops.
    • Verified that non-null handles properly delegate to libcairo cairo_reference, cairo_destroy, cairo_surface_reference, and cairo_surface_destroy.
    • Verified removal of old throwing stubs from Export.cpp and declarations from include/LegacyExports.hpp, avoiding duplicate symbol collisions.
    • Verified technical debt fragment format in docs/dev/debt/changes/feat-nkwebkit-refptr-cairo.md and CMakeLists.txt test target linkage with libcairo.
    • Verified unit tests in tests/RefPtrCairo.cpp comprehensively test null pointer no-op behavior and surface/context reference count increments/decrements with destruction callbacks.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5989493340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24154#pullrequestreview-5989493340). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T08:17:49Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `3f9fed0369`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_refptrcairo_tests` built cleanly. - **CTest** (`nkwebkit_refptrcairo`): ``` 1/1 Test #4751: nkwebkit_refptrcairo ............. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/RefPtrCairo.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 all 4 WTF ref/deref symbols (_ZN3WTF12refIfNotNullI6_cairoEEvPT_, _ZN3WTF14derefIfNotNullI6_cairoEEvPT_, _ZN3WTF12refIfNotNullI14_cairo_surfaceEEvPT_, _ZN3WTF14derefIfNotNullI14_cairo_surfaceEEvPT_) match WebKit upstream signatures with void return type and pointer parameter. - Verified null pointer safety in RefPtrCairo.cpp lines 8, 12, 16, 20 where nullptr handles are safely ignored as no-ops. - Verified that non-null handles properly delegate to libcairo cairo_reference, cairo_destroy, cairo_surface_reference, and cairo_surface_destroy. - Verified removal of old throwing stubs from Export.cpp and declarations from include/LegacyExports.hpp, avoiding duplicate symbol collisions. - Verified technical debt fragment format in docs/dev/debt/changes/feat-nkwebkit-refptr-cairo.md and CMakeLists.txt test target linkage with libcairo. - Verified unit tests in tests/RefPtrCairo.cpp comprehensively test null pointer no-op behavior and surface/context reference count increments/decrements with destruction callbacks. Looks Good To Me
MarcZX10 commented 2026-11-20 09:03:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:03:38Z.

Review: APPROVED


Reviewed — looks good

The implementation matches the described null-safe Cairo reference forwarding, and the source and tests included in the review bundle show no verified blocking defect.

What I ran

Reviewed head 3f9fed0369c0367e120b0649a509da301a1ea1ca. No commands or tests were run during this review; repo_read.py was used to inspect the prepared diff and targeted source files. The author reports Linux x86-64 build and test checks in the PR description; those were not run by me.

Results

Check Result Note
Diff and included source review passed No blocking defect verified
Reported build and test checks not run Reported by author
Excluded Export.cpp full text not run Diff hunks reviewed

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

The full text of core/libs/prx/libSceNKWebKit/Export.cpp was excluded from the review bundle because it was too large; its changed hunks in diff.patch were reviewed. review/files.json was unavailable through the reader, so other exclusions could not be confirmed. No tests were run by me, and Windows, console, and title behavior were not verified. The PR description reports author-run checks, but this review does not independently confirm them.

Files read: description.md, commits.md, manifest.json, diff.patch, core/libs/prx/libSceNKWebKit/CMakeLists.txt, core/libs/prx/libSceNKWebKit/include/RefPtrCairoExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/RefPtrCairo.cpp, core/libs/prx/libSceNKWebKit/tests/RefPtrCairo.cpp, docs/dev/debt/changes/feat-nkwebkit-refptr-cairo.md, core/libs/prx/libcairo/include/Context.hpp, and matching declarations in core/libs/prx/libcairo/include/Surface.hpp. Export.cpp full text was excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5990033695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24154#pullrequestreview-5990033695). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T09:03:38Z. **Review:** APPROVED --- # Reviewed — looks good The implementation matches the described null-safe Cairo reference forwarding, and the source and tests included in the review bundle show no verified blocking defect. ## What I ran Reviewed head `3f9fed0369c0367e120b0649a509da301a1ea1ca`. No commands or tests were run during this review; `repo_read.py` was used to inspect the prepared diff and targeted source files. The author reports Linux x86-64 build and test checks in the PR description; those were not run by me. ## Results | Check | Result | Note | |---|---|---| | Diff and included source review | passed | No blocking defect verified | | Reported build and test checks | not run | Reported by author | | Excluded `Export.cpp` full text | not run | Diff hunks reviewed | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified The full text of `core/libs/prx/libSceNKWebKit/Export.cpp` was excluded from the review bundle because it was too large; its changed hunks in `diff.patch` were reviewed. `review/files.json` was unavailable through the reader, so other exclusions could not be confirmed. No tests were run by me, and Windows, console, and title behavior were not verified. The PR description reports author-run checks, but this review does not independently confirm them. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `core/libs/prx/libSceNKWebKit/CMakeLists.txt`, `core/libs/prx/libSceNKWebKit/include/RefPtrCairoExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/RefPtrCairo.cpp`, `core/libs/prx/libSceNKWebKit/tests/RefPtrCairo.cpp`, `docs/dev/debt/changes/feat-nkwebkit-refptr-cairo.md`, `core/libs/prx/libcairo/include/Context.hpp`, and matching declarations in `core/libs/prx/libcairo/include/Surface.hpp`. `Export.cpp` full text was excluded. ## To get this to a good state Nothing is required.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!24154
No description provided.