Skip to content

feat(libSceNKWebKit): implement refIfNotNull and derefIfNotNull for cairo - #19105

Closed
KernelPanicNT wants to merge 4 commits into
boykopovar:mainfrom
KernelPanicNT:feat/nkwebkit-refptr-cairo
Closed

KernelPanicNT wants to merge 4 commits into
boykopovar:mainfrom
KernelPanicNT:feat/nkwebkit-refptr-cairo

Conversation

@KernelPanicNT

Copy link
Copy Markdown
Contributor

What

Implements the four cairo specializations of WTF::refIfNotNull and WTF::derefIfNotNull in libSceNKWebKit. They threw through NotImplemented_nid_no_patch among the older callable exports.

Export NID Calls
WTF::refIfNotNull<_cairo>(_cairo*) HHnnPwUh7oM cairo_reference
WTF::derefIfNotNull<_cairo>(_cairo*) arCP3jQ+Jbo cairo_destroy
WTF::refIfNotNull<_cairo_surface>(_cairo_surface*) bZYKXT+p6Rw cairo_surface_reference
WTF::derefIfNotNull<_cairo_surface>(_cairo_surface*) 2kDZb3V0F5g cairo_surface_destroy
  • New src/RefPtrCairo.cpp and include/RefPtrCairoExports.hpp. Each function returns at once for a null pointer and otherwise forwards to the tree's libcairo implementation of that call, as WebKit's RefPtrCairo.cpp does.
  • core/libs/prx/libSceNKWebKit/CMakeLists.txt adds libcairo to libSceNKWebKit's private link libraries. This is the same prx-to-prx link that libSceFreeTypeOptOl -> libSceFreeType, libSceFontGs -> libSceFont and libSceNKWebKit's own libSceJsc/libSceIcu links use. No symbol is defined in both libraries. A cairo_t or cairo_surface_t that a title gets from libcairo therefore keeps a single reference count when WebKit code refs or derefs it here. The only test that calls cairo directly (nkwebkit_refptrcairo) also links libcairo, following the existing wtf -> libkernel case in the same loop.
  • Debt: the four names leave include/LegacyExports.hpp and Export.cpp. The older-export counts are left as they are (the debt file keeps historical inventory counts). A new entry records that the result is not compared with a console module and that the objects must come from the tree's libcairo.

Source of the behaviour

  • WebKit c55364d53f97 RefPtrCairo.cpp#L28-L50: if (LIKELY(ptr)) cairo_reference(ptr);, cairo_destroy, cairo_surface_reference, cairo_surface_destroy. This is the only source; the reference counting itself is the existing libcairo code (Context.cpp, Surface.cpp).

Tested

Linux x86-64 (Ubuntu 24.04, GCC 14), on main 09ab49de9649. The new nkwebkit_refptrcairo test tracks each object's lifetime with a cairo_surface_set_user_data destroy callback:

  • An image surface that gets one refIfNotNull survives cairo_surface_destroy and is released by the matching derefIfNotNull.
  • A context from cairo_create keeps its target alive through refIfNotNull and cairo_destroy, and derefIfNotNull releases it and its target.
  • Null pointers are ignored.

Results:

  • ctest -R '^(nkwebkit_(refptrcairo|noops)|guest_nkwebkit_dates)$' passed in 2 of 2 runs.
  • Negative control: with the four bodies replaced by NotImplemented_nid_no_patch, nkwebkit_refptrcairo aborts and the other two still pass.
  • tools/progress.py --compare: +4 implemented.
  • tools/check_conventions.py --base origin/main passes.

Not tested on Windows, on a device or with 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
  • 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

…airo

The cairo_t and cairo_surface_t specializations of WTF::refIfNotNull and
derefIfNotNull ignore a null pointer and otherwise call cairo_reference,
cairo_destroy, cairo_surface_reference or cairo_surface_destroy, as WebKit
c55364d53f97 RefPtrCairo.cpp does. libSceNKWebKit now links the tree's
libcairo so the objects keep one reference count.
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 13515 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
docs/dev/debt/libSceNKWebKit.md
PR 14138 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 14164 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 14259 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
docs/dev/debt/libSceNKWebKit.md
PR 14478 core/libs/prx/libSceNKWebKit/Export.cpp
PR 14860 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 15170 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 15184 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 15853 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 16510 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17550 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 17569 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17695 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17771 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 17793 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17805 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17864 docs/dev/debt/libSceNKWebKit.md
PR 17886 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17912 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
docs/dev/debt/libSceNKWebKit.md
PR 17917 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 17922 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 17927 core/libs/prx/libSceNKWebKit/Export.cpp
PR 17933 core/libs/prx/libSceNKWebKit/Export.cpp
PR 18377 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
PR 18395 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 18414 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19486 core/libs/prx/libSceNKWebKit/Export.cpp
docs/dev/debt/libSceNKWebKit.md
PR 19523 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19590 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19638 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19656 core/libs/prx/libSceNKWebKit/Export.cpp
PR 19659 core/libs/prx/libSceNKWebKit/Export.cpp
PR 19678 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19693 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19719 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19771 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
PR 19773 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19780 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19822 core/libs/prx/libSceNKWebKit/Export.cpp
PR 19823 core/libs/prx/libSceNKWebKit/CMakeLists.txt
core/libs/prx/libSceNKWebKit/Export.cpp
PR 19830 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 19839 core/libs/prx/libSceNKWebKit/Export.cpp
PR 19841 core/libs/prx/libSceNKWebKit/Export.cpp
PR 20291 core/libs/prx/libSceNKWebKit/Export.cpp
PR 20304 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20314 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20316 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20326 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20327 core/libs/prx/libSceNKWebKit/CMakeLists.txt
core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20393 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20400 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20404 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 20771 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
docs/dev/debt/libSceNKWebKit.md
PR 20938 core/libs/prx/libSceNKWebKit/Export.cpp
PR 21089 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 21432 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 21668 core/libs/prx/libSceNKWebKit/Export.cpp
PR 21670 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
PR 21957 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 21979 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22449 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22450 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22451 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22454 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22455 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22456 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22480 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22481 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22482 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22555 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22556 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22557 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22561 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22666 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
docs/dev/debt/libSceNKWebKit.md
PR 22674 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22678 core/libs/prx/libSceNKWebKit/CMakeLists.txt
core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22680 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22682 core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22684 core/libs/prx/libSceNKWebKit/CMakeLists.txt
core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
PR 22689 core/libs/prx/libSceNKWebKit/CMakeLists.txt
core/libs/prx/libSceNKWebKit/Export.cpp
core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp

@JJenkx

JJenkx commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 16a8cd8dc4, merged onto main 1e821b1cb3 (96617c1dfa, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • nkwebkit_refptrcairo passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Progress report (85f73c1 → f9b5255)

📈 System libraries: 42.9% (+0.02%, +4 implemented functions)

✅ 4 implemented
Library Name
libSceNKWebKit _ZN3WTF12refIfNotNullI14_cairo_surfaceEEvPT_
libSceNKWebKit _ZN3WTF12refIfNotNullI6_cairoEEvPT_
libSceNKWebKit _ZN3WTF14derefIfNotNullI14_cairo_surfaceEEvPT_
libSceNKWebKit _ZN3WTF14derefIfNotNullI6_cairoEEvPT_

Changed libraries (implemented exports)

Library Before After Change
libSceNKWebKit 3428/11275 (30.40%) 3432/11275 (30.44%) +0.04%

@c1b3r-p3d1a

Copy link
Copy Markdown
Contributor

Source check of head 16a8cd8dc4 against upstream WebKit's RefPtrCairo.cpp. Code reading only; I did not build or run it.

  • The four specializations match WebKit's RefPtrCairo.cpp: each calls cairo_reference/cairo_destroy or cairo_surface_reference/cairo_surface_destroy only for a non-null pointer.
  • They are older (3.20) callable exports, so the inventory count line is untouched, which is right.

Minor: the new src/RefPtrCairo.cpp has no Derived from line or upstream notice. The bodies are one line each, but on #17960 a maintainer asked for code ported from WebKit to keep the upstream notice with a Derived from line, so it may come up.

AI-assisted: yes.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 15, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 17, 2026

@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 — no blocking findings

Nothing blocks this; the points below are optional. Head ea997d6894dc, base main.

What I ran

  • Read the description, commits, manifest and the diff of the head.
  • Checked the cairo calls in the new code against the libcairo headers in the tree (include/Context.hpp, include/Surface.hpp).
  • Searched the tree for every remaining use of the four removed names.
  • Checked the test loop in CMakeLists.txt.
  • No build and no test run in this review.

Results

Check Result Note
Diff read against the description passed All hunks read
cairo API used by the new code passed Signatures match the libcairo headers
Leftover references to the removed names passed Only the new files and the new test
Test registration in CMake passed refptrcairo links libcairo
Build and ctest not run No build in this review
Author-reported tests and tools not run ctest, negative control, progress.py, check_conventions.py are the author's results

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • Full text of Export.cpp, include/LegacyExports.hpp and docs/dev/debt/libSceNKWebKit.md was not read. Only their changed hunks were read, plus a search for the removed names. Those hunks are removals and one added debt entry.
  • Runtime behaviour of cairo_reference, cairo_destroy and the surface reference counts in libcairo. The test that checks it was not run here.
  • The NIDs in the description and the export table they feed were not checked against a console module. The debt entry says this too.
  • The author's ctest runs, the negative control and the tools/progress.py and tools/check_conventions.py results are author-reported and were not run here.

To get this to a good state

Nothing is required.

Optional:

  • Read the full text of the three large files above before any formal approval.
  • Note in the debt entry which libcairo build the reference counts were checked against.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 18, 2026
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