feat(libwebrtc): implement FileWrapper output and ownership #14246

Merged
mkrieger95 merged 1 commit from upstream-pr/14246 into main 2026-11-06 18:18:09 +00:00
mkrieger95 commented 2026-11-01 03:41:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mkrieger95 on 2026-11-01T03:41:36Z.


What

Implement four previously throwing libwebrtc exports: webrtc::FileWrapper::Close, Flush, Write(const void*, size_t) and the move constructor. Operations use the existing guest libc FileStream APIs, preserving guest stream tracking and platform handling.

Supersedes boykopovar/AnyPS5#13882.

The eight-byte object owns one stream pointer. Write reports whether all requested bytes were accepted; Flush forwards stream errors; Close clears ownership even when the close reports a write failure and succeeds when already empty. Move construction transfers ownership and empties the source without reading uninitialized destination storage.

Source evidence: compared file_wrapper.h and file_wrapper.cc at M127 with M134 header and implementation. These four methods, signatures and one-pointer layout are identical. Those versions bracket the module's inferred revision from its rtc namespace and InterleavedView exports, as investigated in boykopovar/AnyPS5#13687. This code is written against that contract; no new third-party dependency or copied source is added.

PS5 ABI and behavior have not been measured. Invalid wrappers/move objects, Flush or Write without an open stream, and nonempty writes from null data throw for upstream contract violations. These limitations are recorded in docs/dev/debt/libwebrtc.md. No title unblock is claimed.

Tested

Linux x86-64, GCC 14.2, Release, BUILD_TESTING=ON; based on upstream ba627802e2210187d417deb64c8f2fed8e33011f on 2026-11-01 UTC.

  • Built the production library and all focused test targets listed below.
  • 7/7 focused CTests pass: guest_webrtc_file_wrapper, guest_webrtc_vad, guest_webrtc_fast_int_to_buffer, guest_webrtc_time, guest_webrtc_exp_filter, guest_webrtc_rtcp_common_header, guest_webrtc_opus.
  • python3 core/libs/tests/test_public_headers.py --audit-only: 399 libraries, 26,227 exports pass.
  • python3 tools/check_conventions.py --base origin/main and git diff --check: pass.
  • Binary writes split across calls, exact byte count and read-back, zero-length writes, successful flush, close and repeated close.
  • Move into prefilled destination storage, source detachment, destination usability, closing the moved-from object without closing its transferred stream, and moving an empty object.
  • Rejected writes on read-only streams retain ownership. Linux /dev/full checks failed flush, failed implicit flush during close, and pointer clearing even when close returns false.
  • Null/closed object preconditions and nonempty null-data writes.
  • Original mutation checks (before this rebase): five deliberate mutations fail at their intended assertions: Write always reports success; Close always reports success; move leaves the source attached; Flush does nothing; Close keeps its stream pointer.
  • FileWrapper implementation, object-layout header and regression-test source are unchanged from the original head. The debt entry is inserted before the existing source-revision note, with blank lines around it; the shared derived export tally and end-of-file insertion point are no longer edited.

Not tested: Windows, a title or a PS5. No console-parity claim; no full-suite or whole-project-build claim.

Overlap check at ed8d036367a423d4131eda0488751fc3c9d56d0b: python3 tools/pr_overlap.py --branch feat/webrtc-file-wrapper-v2 --repo boykopovar/AnyPS5 scanned 1,662 open PRs against ba627802e2210187d417deb64c8f2fed8e33011f. The reported same exports/new files are this PR itself (#14246), whose remote head was still the previous revision during the scan. No other completed comparison reports conflicting lines, exports or new files. Full pairwise merge previews are clean with #14087, #14095, #14116, #14120, #14129, #14148, #14232 and #14381. This resolves the same-line debt overlaps raised in review by revising our edits, so no landing-order dependency is needed.

The helper still exits 2 because existing conflicts with main prevent complete comparisons for #5021, #7275, #8650, #9156, #9162, #9293, #9297, #9302, #9383, #12642, #13253, #13256 (shared CMake file) and #14212 (shared debt file). Each shared-file patch was inspected manually. Three-way merges of those files using this head have exactly the same conflict hunks as merges using unmodified main; this PR adds no conflict hunks. The CMake edits register unrelated targets or configure macOS linking, with no FileWrapper references; #14212 changes debt formatting/counts and its pre-existing conflict hunks do not contain our new entry.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5104080754 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14246). Originally posted by [mkrieger95](https://github.com/mkrieger95) on 2026-11-01T03:41:36Z. --- ### What Implement four previously throwing libwebrtc exports: `webrtc::FileWrapper::Close`, `Flush`, `Write(const void*, size_t)` and the move constructor. Operations use the existing guest libc `FileStream` APIs, preserving guest stream tracking and platform handling. Supersedes [boykopovar/AnyPS5#13882](https://github.com/boykopovar/AnyPS5/pull/13882). The eight-byte object owns one stream pointer. Write reports whether all requested bytes were accepted; Flush forwards stream errors; Close clears ownership even when the close reports a write failure and succeeds when already empty. Move construction transfers ownership and empties the source without reading uninitialized destination storage. Source evidence: compared [`file_wrapper.h`](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/rtc_base/system/file_wrapper.h) and [`file_wrapper.cc`](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/rtc_base/system/file_wrapper.cc) at M127 with [M134 header](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/system/file_wrapper.h) and [implementation](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/system/file_wrapper.cc). These four methods, signatures and one-pointer layout are identical. Those versions bracket the module's inferred revision from its rtc namespace and InterleavedView exports, as investigated in [boykopovar/AnyPS5#13687](https://github.com/boykopovar/AnyPS5/pull/13687). This code is written against that contract; no new third-party dependency or copied source is added. PS5 ABI and behavior have not been measured. Invalid wrappers/move objects, Flush or Write without an open stream, and nonempty writes from null data throw for upstream contract violations. These limitations are recorded in `docs/dev/debt/libwebrtc.md`. No title unblock is claimed. ### 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, GCC 14.2, Release, `BUILD_TESTING=ON`; based on upstream `ba627802e2210187d417deb64c8f2fed8e33011f` on 2026-11-01 UTC. - Built the production library and all focused test targets listed below. - 7/7 focused CTests pass: `guest_webrtc_file_wrapper`, `guest_webrtc_vad`, `guest_webrtc_fast_int_to_buffer`, `guest_webrtc_time`, `guest_webrtc_exp_filter`, `guest_webrtc_rtcp_common_header`, `guest_webrtc_opus`. - `python3 core/libs/tests/test_public_headers.py --audit-only`: 399 libraries, 26,227 exports pass. - `python3 tools/check_conventions.py --base origin/main` and `git diff --check`: pass. - Binary writes split across calls, exact byte count and read-back, zero-length writes, successful flush, close and repeated close. - Move into prefilled destination storage, source detachment, destination usability, closing the moved-from object without closing its transferred stream, and moving an empty object. - Rejected writes on read-only streams retain ownership. Linux `/dev/full` checks failed flush, failed implicit flush during close, and pointer clearing even when close returns false. - Null/closed object preconditions and nonempty null-data writes. - Original mutation checks (before this rebase): five deliberate mutations fail at their intended assertions: Write always reports success; Close always reports success; move leaves the source attached; Flush does nothing; Close keeps its stream pointer. - FileWrapper implementation, object-layout header and regression-test source are unchanged from the original head. The debt entry is inserted before the existing source-revision note, with blank lines around it; the shared derived export tally and end-of-file insertion point are no longer edited. Not tested: Windows, a title or a PS5. No console-parity claim; no full-suite or whole-project-build claim. Overlap check at `ed8d036367a423d4131eda0488751fc3c9d56d0b`: `python3 tools/pr_overlap.py --branch feat/webrtc-file-wrapper-v2 --repo boykopovar/AnyPS5` scanned 1,662 open PRs against `ba627802e2210187d417deb64c8f2fed8e33011f`. The reported same exports/new files are this PR itself (#14246), whose remote head was still the previous revision during the scan. No other completed comparison reports conflicting lines, exports or new files. Full pairwise merge previews are clean with #14087, #14095, #14116, #14120, #14129, #14148, #14232 and #14381. This resolves the same-line debt overlaps raised in review by revising our edits, so no landing-order dependency is needed. The helper still exits 2 because existing conflicts with main prevent complete comparisons for #5021, #7275, #8650, #9156, #9162, #9293, #9297, #9302, #9383, #12642, #13253, #13256 (shared CMake file) and #14212 (shared debt file). Each shared-file patch was inspected manually. Three-way merges of those files using this head have exactly the same conflict hunks as merges using unmodified main; this PR adds no conflict hunks. The CMake edits register unrelated targets or configure macOS linking, with no FileWrapper references; #14212 changes debt formatting/counts and its pre-existing conflict hunks do not contain our new entry. ### 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) - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-11-01 04:00:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T04:00:00Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The implementation and focused tests look coherent on source inspection, but the PR's own overlap report leaves required landing-order coordination unresolved.

What I ran

Reviewed head df83dac6c54f75d1a55ad77bdd31a65b9302576c against PR base 5d3ad2112f60f35d463dc2c9d96d1c9d35871015; the merge preview against current main 8c91f25b3924a8419096aa368ce44043a5894558 was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0, Git 2.39.5. I did not build or run CTest.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14246
python3 tools/pr_abi_audit.py --base 5d3ad2112f60f35d463dc2c9d96d1c9d35871015 --head df83dac6c54f75d1a55ad77bdd31a65b9302576c
python3 tools/pr_test_quality.py --root /marc/AnyPS5 core/libs/CMakeLists.txt core/libs/prx/libwebrtc/Export.cpp core/libs/prx/libwebrtc/include/Api.hpp core/libs/prx/libwebrtc/include/FileWrapper.hpp core/libs/prx/libwebrtc/libwebrtc.hpp core/libs/prx/libwebrtc/src/FileWrapper.cpp core/libs/tests/GuestWebrtcFileWrapper.cpp docs/dev/debt/libwebrtc.md
python3 tools/pr_stack_check.py 14246 --repo boykopovar/AnyPS5
python3 tools/pr_overlap.py --branch refs/review/pr-14246 --repo boykopovar/AnyPS5 --jobs 8
gh pr view 14246 --repo boykopovar/AnyPS5 --json state,headRefOid,updatedAt,statusCheckRollup

Results

Check Result
Diff check, conventions and PR template Passed in precheck.
ABI audit Passed with warnings: the four new FileWrapper symbols each have a declaration and definition; the 60 warnings concern the existing NID-bound libwebrtcUnknown00–59 exports. This lexical check does not certify binary ABI.
Test-quality heuristic One possible-unregistered-test warning; manually confirmed GuestWebrtcFileWrapper.cpp is registered in core/libs/CMakeLists.txt. The heuristic is a false positive here.
Merge preview Clean against current main 8c91f25b3924a8419096aa368ce44043a5894558.
Hosted CI Eligibility, conventions, portability, intake, labels and report passed; Windows was in progress. Linux and specialized jobs were skipped.
Author-reported tests The description reports a Linux Release build, seven focused CTests passing, and mutation checks from before the rebase. I did not independently run them; the mutation checks are explicitly from before the rebase.
Local build and CTest Not run.
Open-PR overlap check The local helper could not complete because it failed parsing the GitHub response. The PR description's own scan reports shared CMake/debt metadata edits with open #14087, #14095, #14116, #14120, #14129, #14148 and #14232, while stating that no order agreement is claimed. I verified those PRs remain open.
Raw output excerpts

Precheck conventions output:

All conventions checks passed.

ABI audit summary:

ABI audit: passed_with_warnings

Test-quality heuristic output for the changed C++ test:

core/libs/tests/GuestWebrtcFileWrapper.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage.
Heuristic findings require manual interpretation.

Overlap-helper error:

pr_overlap: Invalid \\uXXXX escape: line 1 column 1193051 (char 1193050)

Findings

Blocking

The PR's description says its overlap scan found shared CMake/debt metadata edits with open PRs #14087, #14095, #14116, #14120, #14129, #14148 and #14232, and explicitly says no landing-order agreement is claimed. CONTRIBUTING.md requires the authors of PRs that change the same lines to agree which lands first and declare that order with Depends on. The checklist currently says Depends on: none. Please coordinate the order with the affected authors and update the checklist (or revise the changes so the overlap no longer applies).

Non-blocking

No source-level defect was established in this pass. The test-registration heuristic warning is resolved by the registration visible in the changed CMake file.

Sources

Not verified

I did not build or run the focused CTests or the negative controls. The reported focused tests are author-provided, and the mutation checks predate this rebase. Hosted Windows was still running; Linux and specialized jobs were skipped. No PS5 or title behavior was tested.

To get this to a good state

Agree and record the landing order for the reported open overlaps, then update Depends on and rerun the overlap check. I will recheck the exact new head and rerun the applicable no-build checks.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5726315605 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14246#pullrequestreview-5726315605). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T04:00:00Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The implementation and focused tests look coherent on source inspection, but the PR's own overlap report leaves required landing-order coordination unresolved. ## What I ran Reviewed head `df83dac6c54f75d1a55ad77bdd31a65b9302576c` against PR base `5d3ad2112f60f35d463dc2c9d96d1c9d35871015`; the merge preview against current `main` `8c91f25b3924a8419096aa368ce44043a5894558` was clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0, Git 2.39.5. I did not build or run CTest. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14246 python3 tools/pr_abi_audit.py --base 5d3ad2112f60f35d463dc2c9d96d1c9d35871015 --head df83dac6c54f75d1a55ad77bdd31a65b9302576c python3 tools/pr_test_quality.py --root /marc/AnyPS5 core/libs/CMakeLists.txt core/libs/prx/libwebrtc/Export.cpp core/libs/prx/libwebrtc/include/Api.hpp core/libs/prx/libwebrtc/include/FileWrapper.hpp core/libs/prx/libwebrtc/libwebrtc.hpp core/libs/prx/libwebrtc/src/FileWrapper.cpp core/libs/tests/GuestWebrtcFileWrapper.cpp docs/dev/debt/libwebrtc.md python3 tools/pr_stack_check.py 14246 --repo boykopovar/AnyPS5 python3 tools/pr_overlap.py --branch refs/review/pr-14246 --repo boykopovar/AnyPS5 --jobs 8 gh pr view 14246 --repo boykopovar/AnyPS5 --json state,headRefOid,updatedAt,statusCheckRollup ``` ## Results | Check | Result | |---|---| | Diff check, conventions and PR template | Passed in precheck. | | ABI audit | Passed with warnings: the four new FileWrapper symbols each have a declaration and definition; the 60 warnings concern the existing NID-bound `libwebrtcUnknown00`–`59` exports. This lexical check does not certify binary ABI. | | Test-quality heuristic | One possible-unregistered-test warning; manually confirmed `GuestWebrtcFileWrapper.cpp` is registered in `core/libs/CMakeLists.txt`. The heuristic is a false positive here. | | Merge preview | Clean against current `main` `8c91f25b3924a8419096aa368ce44043a5894558`. | | Hosted CI | Eligibility, conventions, portability, intake, labels and report passed; Windows was in progress. Linux and specialized jobs were skipped. | | Author-reported tests | The description reports a Linux Release build, seven focused CTests passing, and mutation checks from before the rebase. I did not independently run them; the mutation checks are explicitly from before the rebase. | | Local build and CTest | Not run. | | Open-PR overlap check | The local helper could not complete because it failed parsing the GitHub response. The PR description's own scan reports shared CMake/debt metadata edits with open #14087, #14095, #14116, #14120, #14129, #14148 and #14232, while stating that no order agreement is claimed. I verified those PRs remain open. | <details><summary>Raw output excerpts</summary> Precheck conventions output: ```text All conventions checks passed. ``` ABI audit summary: ```text ABI audit: passed_with_warnings ``` Test-quality heuristic output for the changed C++ test: ```text core/libs/tests/GuestWebrtcFileWrapper.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage. Heuristic findings require manual interpretation. ``` Overlap-helper error: ```text pr_overlap: Invalid \\uXXXX escape: line 1 column 1193051 (char 1193050) ``` </details> ## Findings ### Blocking The PR's description says its overlap scan found shared CMake/debt metadata edits with open PRs #14087, #14095, #14116, #14120, #14129, #14148 and #14232, and explicitly says no landing-order agreement is claimed. `CONTRIBUTING.md` requires the authors of PRs that change the same lines to agree which lands first and declare that order with `Depends on`. The checklist currently says `Depends on: none`. Please coordinate the order with the affected authors and update the checklist (or revise the changes so the overlap no longer applies). ### Non-blocking No source-level defect was established in this pass. The test-registration heuristic warning is resolved by the registration visible in the changed CMake file. ## Sources - [Overlap-order rule at the PR base](https://github.com/boykopovar/AnyPS5/blob/5d3ad2112f60f35d463dc2c9d96d1c9d35871015/CONTRIBUTING.md#L70) - [PR description with the overlap scan and current `Depends on` entry](https://github.com/boykopovar/AnyPS5/pull/14246) - [CMake registration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/df83dac6c54f75d1a55ad77bdd31a65b9302576c/core/libs/CMakeLists.txt#L1275-L1288) ## Not verified I did not build or run the focused CTests or the negative controls. The reported focused tests are author-provided, and the mutation checks predate this rebase. Hosted Windows was still running; Linux and specialized jobs were skipped. No PS5 or title behavior was tested. ## To get this to a good state Agree and record the landing order for the reported open overlaps, then update `Depends on` and rerun the overlap check. I will recheck the exact new head and rerun the applicable no-build checks.
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!14246
No description provided.