feat(libwebrtc): implement the webrtc::EchoCanceller3Config copy constructor and assignment #15195

Merged
alvaroelpob merged 7 commits from upstream-pr/15195 into main 2026-11-07 02:33:02 +00:00
alvaroelpob commented 2026-11-02 20:26:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-02T20:26:15Z.


What

Implements webrtc::EchoCanceller3Config::EchoCanceller3Config(const EchoCanceller3Config&) and operator=(const EchoCanceller3Config&) in libwebrtc, which threw and were declared without parameters.

The module's WebRTC revision lies between M127 and M134, as recorded in the debt file. Both are = default in echo_canceller3_config.cc (M127, M134), and echo_canceller3_config.h is identical at both. Every member of its nested structs is a size_t, int, float or bool, so a default copy copies every member. This copies all 608 bytes; the firmware 13.42 copy leaves five padding ranges of the destination unwritten, which the debt entry records and the tests do not check. src/EchoCanceller3Config.cpp starts with that file's WebRTC notice and the BSD licence.

The fields are not modelled: WebRtcEchoCanceller3Config is 608 bytes aligned to 8, the size and alignment that compiling that header (with rtc_export.h) for x86-64 gives at both revisions. The assignment returns this. A null object or source throws. The default constructor and the fields stay as debt. It removes 2 exports from the inventory.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON.

  • New guest_webrtc_echo_canceller3_config test: a patterned 608-byte config copies into storage filled with 0xA5, assignment returns this and survives self-assignment, and null arguments throw std::invalid_argument without changing the object.
  • Full ctest -j16 on head 7d014e81ec: 3596/3596 pass. check_conventions.py --base upstream/main passes.
  • pr_overlap.py: no open pull request implements these functions. The shared lines are the pending-export count in docs/dev/debt/libwebrtc.md and the source, test and declaration lists in CMakeLists.txt and Api.hpp.
  • Not tested: Windows, a title.
  • Rebased on main 4f41f4c375, head e5cb0fa18e, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp and debt-file lines; both sides are kept and the debt count is recomputed from Export.cpp. Full build and ctest -j16: 3796/3800 pass; guest_sce_net, guest_poll, guest_select_wait and guest_memory failed under that load, pass when run alone, and main 4f41f4c375 passes all 3799 with -j16 on the same machine. check_conventions.py --base upstream/main passes.
  • Review follow-up, head 07942fb5ed: the tests compare every byte except the five padding ranges firmware 13.42 leaves unwritten, and the debt entry records the difference. A copy of only 0x60 bytes fails the test. Full build and ctest -j16: 3800/3800 pass. check_conventions.py --base upstream/main passes.

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:5126910688 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15195). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-02T20:26:15Z. --- ### What Implements `webrtc::EchoCanceller3Config::EchoCanceller3Config(const EchoCanceller3Config&)` and `operator=(const EchoCanceller3Config&)` in libwebrtc, which threw and were declared without parameters. The module's WebRTC revision lies between M127 and M134, as recorded in the debt file. Both are `= default` in `echo_canceller3_config.cc` ([M127](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/api/audio/echo_canceller3_config.cc), [M134](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/audio/echo_canceller3_config.cc)), and `echo_canceller3_config.h` is identical at both. Every member of its nested structs is a `size_t`, `int`, `float` or `bool`, so a default copy copies every member. This copies all 608 bytes; the firmware 13.42 copy leaves five padding ranges of the destination unwritten, which the debt entry records and the tests do not check. `src/EchoCanceller3Config.cpp` starts with that file's WebRTC notice and the BSD licence. The fields are not modelled: `WebRtcEchoCanceller3Config` is 608 bytes aligned to 8, the size and alignment that compiling that header (with `rtc_export.h`) for x86-64 gives at both revisions. The assignment returns `this`. A null object or source throws. The default constructor and the fields stay as debt. It removes 2 exports from the inventory. ### 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. --> Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON`. - New `guest_webrtc_echo_canceller3_config` test: a patterned 608-byte config copies into storage filled with 0xA5, assignment returns `this` and survives self-assignment, and null arguments throw `std::invalid_argument` without changing the object. - Full `ctest -j16` on head 7d014e81ec: 3596/3596 pass. `check_conventions.py --base upstream/main` passes. - `pr_overlap.py`: no open pull request implements these functions. The shared lines are the pending-export count in `docs/dev/debt/libwebrtc.md` and the source, test and declaration lists in `CMakeLists.txt` and `Api.hpp`. - Not tested: Windows, a title. - Rebased on `main` 4f41f4c375, head e5cb0fa18e, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp` and debt-file lines; both sides are kept and the debt count is recomputed from `Export.cpp`. Full build and `ctest -j16`: 3796/3800 pass; `guest_sce_net`, `guest_poll`, `guest_select_wait` and `guest_memory` failed under that load, pass when run alone, and `main` 4f41f4c375 passes all 3799 with `-j16` on the same machine. `check_conventions.py --base upstream/main` passes. - Review follow-up, head 07942fb5ed: the tests compare every byte except the five padding ranges firmware 13.42 leaves unwritten, and the debt entry records the difference. A copy of only 0x60 bytes fails the test. Full build and `ctest -j16`: 3800/3800 pass. `check_conventions.py --base upstream/main` passes. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-03 23:28:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T23:28:09Z.

Review: COMMENTED


@alvaroelpob thanks. The 608-byte size and the this return check out against the firmware, and the PR passes on Windows. One small fidelity point and a question.

What I ran: this head merged onto main (merge 98e71ab1a8), Windows 11, WinLibs GCC, Release. guest_webrtc_echo_canceller3_config and public_headers pass (2 of 2). That covers the Windows run your description lists as not tested.

Firmware: system/common/lib/libwebrtc.sprx 13.42 (sha256 d59d0caf6967329b39201a2a0bd6df7b994516f21701b9801908db6735ae5314), read from disassembly, not run:

  • _ZN6webrtc20EchoCanceller3ConfigC1ERKS0_ at 0x3f3920 (to its ret at 0x3f3ac5).
  • _ZN6webrtc20EchoCanceller3ConfigaSERKS0_ at 0x3f3ad0 (to its ret at 0x3f3c78).
  • The assignment sets rax = rdi (3f3ad4: mov %rdi,%rax), which matches your return config.
  • Neither checks for null. Throwing there is the usual host guard, and I have no issue with it.

The point: the firmware copy is member by member, not a block copy. Its last stores (before 3f3ac5) reach byte 607, which fits 608, but they skip the padding. For example:

3f3928: movzbl 0x70(%rsi),%eax
3f392c: mov    %al,0x70(%rdi)
3f392f: vmovups 0x10(%rsi),%ymm0

Byte 0x70 is copied on its own, and nothing writes 0x71 to 0x77. I listed every destination store from both bodies with a small script. Both leave the same five ranges unwritten:

0x71–0x77, 0x14e–0x14f, 0x179–0x17f, 0x184–0x187 and 0x249–0x24f (27 bytes).

So on the console those destination bytes keep whatever they held. std::memmove over all 608 bytes overwrites them, and TestCopyConstructor/TestAssignment pin that with a full memcmp against a 0xA5-filled target.

Nothing is likely to read padding, so this isn't a blocker for me. Still, the PR text says a default copy "copies the whole object", and the test asserts more than the console does. Two ways to match it:

  • copy only the member ranges (0x00–0x70, 0x78–0x14d, 0x150–0x178, 0x180–0x183, 0x188–0x248, 0x250–0x25f), and have the test check that the padding keeps its 0xA5 fill;
  • or keep the block copy, compare only the member ranges in the test, and add a line to the debt entry saying padding is copied, unlike firmware 13.42.

Question: do you know whether the PS5 module was built from a revision where these structs are identical to the ones you pinned? The padding positions above fit bool members followed by wider fields, so they look consistent with your header. If you derived the 608 from a compile of that header, the gaps should match its offsetofs too.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5760947515 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15195#pullrequestreview-5760947515). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T23:28:09Z. **Review:** COMMENTED --- @alvaroelpob thanks. The 608-byte size and the `this` return check out against the firmware, and the PR passes on Windows. One small fidelity point and a question. **What I ran:** this head merged onto `main` (merge `98e71ab1a8`), Windows 11, WinLibs GCC, Release. `guest_webrtc_echo_canceller3_config` and `public_headers` pass (2 of 2). That covers the Windows run your description lists as not tested. **Firmware:** `system/common/lib/libwebrtc.sprx` 13.42 (sha256 `d59d0caf6967329b39201a2a0bd6df7b994516f21701b9801908db6735ae5314`), read from disassembly, not run: - `_ZN6webrtc20EchoCanceller3ConfigC1ERKS0_` at `0x3f3920` (to its `ret` at `0x3f3ac5`). - `_ZN6webrtc20EchoCanceller3ConfigaSERKS0_` at `0x3f3ad0` (to its `ret` at `0x3f3c78`). - The assignment sets `rax = rdi` (`3f3ad4: mov %rdi,%rax`), which matches your `return config`. - Neither checks for null. Throwing there is the usual host guard, and I have no issue with it. **The point:** the firmware copy is member by member, not a block copy. Its last stores (before `3f3ac5`) reach byte 607, which fits 608, but they skip the padding. For example: ``` 3f3928: movzbl 0x70(%rsi),%eax 3f392c: mov %al,0x70(%rdi) 3f392f: vmovups 0x10(%rsi),%ymm0 ``` Byte `0x70` is copied on its own, and nothing writes `0x71` to `0x77`. I listed every destination store from both bodies with a small script. Both leave the same five ranges unwritten: `0x71`–`0x77`, `0x14e`–`0x14f`, `0x179`–`0x17f`, `0x184`–`0x187` and `0x249`–`0x24f` (27 bytes). So on the console those destination bytes keep whatever they held. `std::memmove` over all 608 bytes overwrites them, and `TestCopyConstructor`/`TestAssignment` pin that with a full `memcmp` against a 0xA5-filled target. Nothing is likely to read padding, so this isn't a blocker for me. Still, the PR text says a default copy "copies the whole object", and the test asserts more than the console does. Two ways to match it: - copy only the member ranges (`0x00`–`0x70`, `0x78`–`0x14d`, `0x150`–`0x178`, `0x180`–`0x183`, `0x188`–`0x248`, `0x250`–`0x25f`), and have the test check that the padding keeps its 0xA5 fill; - or keep the block copy, compare only the member ranges in the test, and add a line to the debt entry saying padding is copied, unlike firmware 13.42. **Question:** do you know whether the PS5 module was built from a revision where these structs are identical to the ones you pinned? The padding positions above fit `bool` members followed by wider fields, so they look consistent with your header. If you derived the 608 from a compile of that header, the gaps should match its `offsetof`s too.
BunnyFl commented 2026-11-04 14:56:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T14:56:42Z.

Review: APPROVED


@alvaroelpob thanks for answering the question and for the padding check. That settles it. The second option works for me.

  • MembersEqual (core/libs/prx/libwebrtc/tests/EchoCanceller3Config.cpp:34) compares every byte except the five ranges in FirmwareUnwrittenPadding (:32), which are the ones I listed from the 13.42 disassembly. So the tests no longer pin bytes the console leaves alone. The self-assignment case compares against a copy taken before it (:65), which keeps it a full-object check without depending on padding.
  • The debt entry now leads with the gap: the copy writes all 608 bytes, while the 13.42 copy leaves those five padding ranges unwritten. It is marked as read from disassembly and not measured on a console.

What I ran: head 07942fb5ed merged onto main b11c7bf84f (merge b0da3deca1), Windows 11, WinLibs GCC, Release, BUILD_TESTING=ON:

  • guest_webrtc_echo_canceller3_config and public_headers: 2 of 2 pass.
  • Mutation: with both copies moving 8 bytes fewer than sizeof(WebRtcEchoCanceller3Config) in src/EchoCanceller3Config.cpp, guest_webrtc_echo_canceller3_config fails. The last 8 bytes are a member, not padding. A plain negative control doesn't apply, since src/EchoCanceller3Config.cpp is a file this PR adds.
  • check_conventions.py --base upstream/main passes.
  • pr_overlap.py --branch: 32 open PRs touch the same files (the libwebrtc CMakeLists.txt, header and debt lines), none the same exports.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5770445678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15195#pullrequestreview-5770445678). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T14:56:42Z. **Review:** APPROVED --- @alvaroelpob thanks for answering the question and for the padding check. That settles it. The second option works for me. - `MembersEqual` (`core/libs/prx/libwebrtc/tests/EchoCanceller3Config.cpp:34`) compares every byte except the five ranges in `FirmwareUnwrittenPadding` (`:32`), which are the ones I listed from the 13.42 disassembly. So the tests no longer pin bytes the console leaves alone. The self-assignment case compares against a copy taken before it (`:65`), which keeps it a full-object check without depending on padding. - The debt entry now leads with the gap: the copy writes all 608 bytes, while the 13.42 copy leaves those five padding ranges unwritten. It is marked as read from disassembly and not measured on a console. **What I ran:** head `07942fb5ed` merged onto `main` `b11c7bf84f` (merge `b0da3deca1`), Windows 11, WinLibs GCC, Release, `BUILD_TESTING=ON`: - `guest_webrtc_echo_canceller3_config` and `public_headers`: 2 of 2 pass. - Mutation: with both copies moving 8 bytes fewer than `sizeof(WebRtcEchoCanceller3Config)` in `src/EchoCanceller3Config.cpp`, `guest_webrtc_echo_canceller3_config` fails. The last 8 bytes are a member, not padding. A plain negative control doesn't apply, since `src/EchoCanceller3Config.cpp` is a file this PR adds. - `check_conventions.py --base upstream/main` passes. - `pr_overlap.py --branch`: 32 open PRs touch the same files (the libwebrtc `CMakeLists.txt`, header and debt lines), none the same exports.
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!15195
No description provided.