feat(libwebrtc): implement the SequenceCheckerImpl constructor #17313

Merged
jacknieland merged 3 commits from upstream-pr/17313 into main 2026-11-12 03:06:17 +00:00
jacknieland commented 2026-11-08 17:36:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jacknieland on 2026-11-08T17:36:16Z.


What

Implements the webrtc::webrtc_sequence_checker_internal::SequenceCheckerImpl(bool) constructor (C2Eb) in libwebrtc, which threw.

sequence_checker_internal.cc is the same at M127 branch-heads/6533 and M134 branch-heads/6998, the revisions the debt file pins, and the MutexImpl constructor of mutex_pthread.h differs between them only in a comment. src/SequenceChecker.cpp follows both, with their WebRTC copyright notices and BSD licence at the top, as CpuFeatures.cpp does:

  • lock_ becomes a default guest mutex through libkernel's pthread_mutexattr_init, pthread_mutex_init and pthread_mutexattr_destroy, as MutexImpl does off macOS.
  • attached_ takes the argument, valid_thread_ is pthread_self(), which is what rtc::CurrentThreadRef() returns on POSIX, and valid_queue_ is TaskQueueBase::Current(), from TaskQueueBase.cpp.
  • include/SequenceChecker.hpp gives the 32-byte layout: lock_ at 0, attached_ at 8, valid_thread_ at 16 and valid_queue_ at 24. This holds for a build without RTC_DCHECK_IS_ON, where RTC_NO_UNIQUE_ADDRESS ([[no_unique_address]] under clang) leaves MutexImpl's empty owner record no space. With RTC_DCHECK_IS_ON the record holds a bool and a pthread_t, and the last three fields move 16 bytes on. Whether the module is such a build is unknown. The LogMessage and RecursiveCriticalSection entries already assume a build without it, and the debt entry says so.
  • A non-zero return from a guest pthread call throws, where upstream ignores it, and a null checker throws std::invalid_argument.
  • The pending count drops from 279 to 278.

Tested

Windows 11 Pro (26300), WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r7), Release, BUILD_TESTING=ON, Ninja, on head 07ec9041a1 (this branch, on main ef9ab2ea44).

  • New guest_webrtc_sequence_checker test, on storage filled with 0xA5 first:
    • With true, attached_ is set, valid_thread_ equals pthread_self() and valid_queue_ is null; with false, only attached_ differs.
    • Under a CurrentTaskQueueSetter, valid_queue_ is that queue.
    • Constructed on another thread, valid_thread_ is that thread, not the main one.
    • lock_ is a working mutex: free when constructed, EBUSY to a trylock from another thread while held, free again after unlocking, and destroyed cleanly.
    • A null checker throws std::invalid_argument.
  • ctest -R ^guest_webrtc_ --repeat until-fail:3: all 44 libwebrtc tests pass 3/3. ctest -R public_headers: 65/65 pass.
  • Negative control: with NotImplemented_nid_no_patch(__func__) at the top of the constructor, as the main stub does, the test fails 3/3 with _ZN6webrtc32webrtc_sequence_checker_internal19SequenceCheckerImplC2Eb_nid_postfix not implemented.
  • check_conventions.py --base upstream/main passes. No open pull request implements SequenceCheckerImpl.
  • Not tested: Linux, a title. Only the targets above were built, not the full test suite.

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; no title is known to reach this constructor yet
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5213528915 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17313). Originally posted by [jacknieland](https://github.com/jacknieland) on 2026-11-08T17:36:16Z. --- ### What Implements the `webrtc::webrtc_sequence_checker_internal::SequenceCheckerImpl(bool)` constructor (`C2Eb`) in libwebrtc, which threw. [`sequence_checker_internal.cc`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/synchronization/sequence_checker_internal.cc) is the same at [M127 branch-heads/6533](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/rtc_base/synchronization/sequence_checker_internal.cc) and M134 branch-heads/6998, the revisions the debt file pins, and the `MutexImpl` constructor of [`mutex_pthread.h`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/synchronization/mutex_pthread.h) differs between them only in a comment. `src/SequenceChecker.cpp` follows both, with their WebRTC copyright notices and BSD licence at the top, as `CpuFeatures.cpp` does: - `lock_` becomes a default guest mutex through libkernel's `pthread_mutexattr_init`, `pthread_mutex_init` and `pthread_mutexattr_destroy`, as `MutexImpl` does off macOS. - `attached_` takes the argument, `valid_thread_` is `pthread_self()`, which is what `rtc::CurrentThreadRef()` returns on POSIX, and `valid_queue_` is `TaskQueueBase::Current()`, from `TaskQueueBase.cpp`. - `include/SequenceChecker.hpp` gives the 32-byte layout: `lock_` at 0, `attached_` at 8, `valid_thread_` at 16 and `valid_queue_` at 24. This holds for a build without `RTC_DCHECK_IS_ON`, where `RTC_NO_UNIQUE_ADDRESS` (`[[no_unique_address]]` under clang) leaves `MutexImpl`'s empty owner record no space. With `RTC_DCHECK_IS_ON` the record holds a `bool` and a `pthread_t`, and the last three fields move 16 bytes on. Whether the module is such a build is unknown. The `LogMessage` and `RecursiveCriticalSection` entries already assume a build without it, and the debt entry says so. - A non-zero return from a guest pthread call throws, where upstream ignores it, and a null checker throws `std::invalid_argument`. - The pending count drops from 279 to 278. ### 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. --> Windows 11 Pro (26300), WinLibs GCC 15.2.0 (`x86_64-ucrt-posix-seh`, r7), Release, `BUILD_TESTING=ON`, Ninja, on head `07ec9041a1` (this branch, on `main` `ef9ab2ea44`). - New `guest_webrtc_sequence_checker` test, on storage filled with `0xA5` first: - With `true`, `attached_` is set, `valid_thread_` equals `pthread_self()` and `valid_queue_` is null; with `false`, only `attached_` differs. - Under a `CurrentTaskQueueSetter`, `valid_queue_` is that queue. - Constructed on another thread, `valid_thread_` is that thread, not the main one. - `lock_` is a working mutex: free when constructed, `EBUSY` to a trylock from another thread while held, free again after unlocking, and destroyed cleanly. - A null checker throws `std::invalid_argument`. - `ctest -R ^guest_webrtc_ --repeat until-fail:3`: all 44 libwebrtc tests pass 3/3. `ctest -R public_headers`: 65/65 pass. - Negative control: with `NotImplemented_nid_no_patch(__func__)` at the top of the constructor, as the `main` stub does, the test fails 3/3 with `_ZN6webrtc32webrtc_sequence_checker_internal19SequenceCheckerImplC2Eb_nid_postfix not implemented`. - `check_conventions.py --base upstream/main` passes. No open pull request implements `SequenceCheckerImpl`. - Not tested: Linux, a title. Only the targets above were built, not the full test suite. ### 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; no title is known to reach this constructor yet - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PrivacyOnion commented 2026-11-08 17:40:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-08T17:40:51Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 07ec9041a1:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_sequence_checker_tests, libwebrtc built cleanly.
  • CTest (guest_webrtc_sequence_checker):
    1/1 Test #4302: guest_webrtc_sequence_checker ....   Passed    0.06 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified SequenceCheckerImpl constructor in core/libs/prx/libwebrtc/src/SequenceChecker.cpp validates non-null input, initializes guest mutex attributes, handles pthread failures, and sets attached, validThread, and validQueue fields.
    • Verified struct WebRtcSequenceCheckerImpl layout and static asserts in core/libs/prx/libwebrtc/include/SequenceChecker.hpp match the 32-byte layout without RTC_DCHECK_IS_ON.
    • Verified export stub replacement in core/libs/prx/libwebrtc/Export.cpp and signature declaration in core/libs/prx/libwebrtc/include/Api.hpp.
    • Verified guest_webrtc_sequence_checker test suite in core/libs/prx/libwebrtc/tests/SequenceChecker.cpp covers attached and detached states, CurrentTaskQueueSetter propagation, thread identity across threads, mutex locking semantics, and null pointer validation.
    • Verified docs/dev/debt/libwebrtc.md accurately decrements the unknown export count and documents the RTC_DCHECK_IS_ON layout assumption and closure criteria.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5818902178 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17313#pullrequestreview-5818902178). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-08T17:40:51Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `07ec9041a1`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_sequence_checker_tests`, `libwebrtc` built cleanly. - **CTest** (`guest_webrtc_sequence_checker`): ``` 1/1 Test #4302: guest_webrtc_sequence_checker .... Passed 0.06 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified SequenceCheckerImpl constructor in core/libs/prx/libwebrtc/src/SequenceChecker.cpp validates non-null input, initializes guest mutex attributes, handles pthread failures, and sets attached, validThread, and validQueue fields. - Verified struct WebRtcSequenceCheckerImpl layout and static asserts in core/libs/prx/libwebrtc/include/SequenceChecker.hpp match the 32-byte layout without RTC_DCHECK_IS_ON. - Verified export stub replacement in core/libs/prx/libwebrtc/Export.cpp and signature declaration in core/libs/prx/libwebrtc/include/Api.hpp. - Verified guest_webrtc_sequence_checker test suite in core/libs/prx/libwebrtc/tests/SequenceChecker.cpp covers attached and detached states, CurrentTaskQueueSetter propagation, thread identity across threads, mutex locking semantics, and null pointer validation. - Verified docs/dev/debt/libwebrtc.md accurately decrements the unknown export count and documents the RTC_DCHECK_IS_ON layout assumption and closure criteria. - Minor: please drop the `Generated with` footer from the description; the AI-assisted checkbox can stay. Looks Good To Me
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!17313
No description provided.