feat(libwebrtc): implement webrtc::TaskQueueBase::Current and CurrentTaskQueueSetter #14087

Merged
alvaroelpob merged 3 commits from upstream-pr/14087 into main 2026-11-02 19:46:06 +00:00
alvaroelpob commented 2026-10-31 18:35:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-31T18:35:28Z.


What

Implements webrtc::TaskQueueBase::Current() and the TaskQueueBase::CurrentTaskQueueSetter constructor and destructor 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 by #13687. api/task_queue/task_queue_base.cc has the same code at M127 branch-heads/6533 and M134 branch-heads/6998; only its includes differ. CurrentTaskQueueSetter in task_queue_base.h holds a single TaskQueueBase* const previous_ at both revisions.

The functions are adapted from task_queue_base.cc and live in src/TaskQueueBase.cpp, which starts with that file's WebRTC copyright notice and the BSD licence text from WebRTC's LICENSE. The debt entry says it is adapted from task_queue_base.cc.

  • Current() returns a thread-local pointer that starts null on every thread.
  • The constructor takes this and the queue, stores the current queue in previous_ and makes the queue current. Null is allowed and clears it.
  • The destructor makes previous_ current again.

task_queue_base.cc has a thread_local variant and a pthread-key variant for builds without thread_local; both keep one pointer per thread and behave the same. WebRtcCurrentTaskQueueSetter is the 8-byte setter, checked by a static_assert; the queue stays opaque. Upstream writes through a null setter, so a null setter throws. The inventory drops from 408 to 405.

Tested

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

  • New guest_webrtc_task_queue_base test:
    • Current() is null before any setter.
    • A setter stores the previous queue, makes its queue current, and its destructor restores the previous one.
    • Three nested setters, the innermost with a null queue, restore in reverse order.
    • The destructor restores whatever the setter's previous_ holds.
    • A second thread starts with no queue, sets and restores its own, and leaves the first thread's queue unchanged.
    • A null setter throws std::invalid_argument in the constructor and the destructor without changing the current queue.
  • Full ctest -j16 on head f290692326: 3033/3033 pass. check_conventions.py --base upstream/main passes. pr_overlap.py reports the open pull requests listed in Depends on.
  • Rebased onto main 1bc97b9527 after #13736 merged; the only conflicts were the include, CMake source and debt count lines. Full ctest -j16 on the top of the stack, #14148 head 0884de5716 (which contains this head, 0c385970b9): 3087/3087 pass. check_conventions.py --base upstream/main passes.
  • Rebased onto main dc9dc7eaae after #13764 and #13816 merged. The conflicts were the debt count line and, in the AudioDeviceGeneric commit, the Export.cpp stubs next to the removed VAD stubs; that commit keeps main's side and removes only its own seven stubs. The count is now set from the stubs left in Export.cpp plus the 60 bound by NID (382
    31 on this head, fb3a950650). Full ctest -j16 on the top of the stack, #14148 head 44e052f6dd: 3113/3113 pass. check_conventions.py --base upstream/main passes.
  • Not tested: Windows, 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5100412488 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14087). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-31T18:35:28Z. --- ### What Implements `webrtc::TaskQueueBase::Current()` and the `TaskQueueBase::CurrentTaskQueueSetter` constructor and destructor 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 by #13687. `api/task_queue/task_queue_base.cc` has the same code at [M127 branch-heads/6533](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d/api/task_queue/task_queue_base.cc) and [M134 branch-heads/6998](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/task_queue/task_queue_base.cc); only its includes differ. `CurrentTaskQueueSetter` in `task_queue_base.h` holds a single `TaskQueueBase* const previous_` at both revisions. The functions are adapted from `task_queue_base.cc` and live in `src/TaskQueueBase.cpp`, which starts with that file's WebRTC copyright notice and the BSD licence text from WebRTC's `LICENSE`. The debt entry says it is adapted from `task_queue_base.cc`. - `Current()` returns a thread-local pointer that starts null on every thread. - The constructor takes `this` and the queue, stores the current queue in `previous_` and makes the queue current. Null is allowed and clears it. - The destructor makes `previous_` current again. `task_queue_base.cc` has a `thread_local` variant and a pthread-key variant for builds without `thread_local`; both keep one pointer per thread and behave the same. `WebRtcCurrentTaskQueueSetter` is the 8-byte setter, checked by a `static_assert`; the queue stays opaque. Upstream writes through a null setter, so a null setter throws. The inventory drops from 408 to 405. ### 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_task_queue_base` test: - `Current()` is null before any setter. - A setter stores the previous queue, makes its queue current, and its destructor restores the previous one. - Three nested setters, the innermost with a null queue, restore in reverse order. - The destructor restores whatever the setter's `previous_` holds. - A second thread starts with no queue, sets and restores its own, and leaves the first thread's queue unchanged. - A null setter throws `std::invalid_argument` in the constructor and the destructor without changing the current queue. - Full `ctest -j16` on head f290692326: 3033/3033 pass. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports the open pull requests listed in Depends on. - Rebased onto main 1bc97b9527 after #13736 merged; the only conflicts were the include, CMake source and debt count lines. Full `ctest -j16` on the top of the stack, #14148 head 0884de5716 (which contains this head, 0c385970b9): 3087/3087 pass. `check_conventions.py --base upstream/main` passes. - Rebased onto main dc9dc7eaae after #13764 and #13816 merged. The conflicts were the debt count line and, in the AudioDeviceGeneric commit, the `Export.cpp` stubs next to the removed VAD stubs; that commit keeps `main`'s side and removes only its own seven stubs. The count is now set from the stubs left in `Export.cpp` plus the 60 bound by NID (382 31 on this head, fb3a950650). Full `ctest -j16` on the top of the stack, #14148 head 44e052f6dd: 3113/3113 pass. `check_conventions.py --base upstream/main` passes. - Not tested: Windows, 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) - [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
MarcZX10 commented 2026-10-31 19:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T19:17:01Z.

Review: APPROVED


Reviewed — looks good

The thread-local current-queue implementation matches the cited WebRTC implementation, and I found no blocking issue in the reviewed stack head.

What I ran

Reviewed head f2906923264c7dbd21449d58adeca231b34aabdf against base ca073ec3ad0d766ea9f4658e418a5c977001a353; the PR stack check reported a clean merge preview. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0 (c++). No local build or C++ test was run.

git diff --check ca073ec3ad0d766ea9f4658e418a5c977001a353...f2906923264c7dbd21449d58adeca231b34aabdf
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14087
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base ca073ec3ad0d766ea9f4658e418a5c977001a353 --head f2906923264c7dbd21449d58adeca231b34aabdf --json
python3 tools/pr_test_quality.py --root <isolated-head-worktree> --json core/libs/prx/libwebrtc/src/TaskQueueBase.cpp core/libs/prx/libwebrtc/tests/TaskQueueBase.cpp

Results

Check Result
Diff check Passed; no whitespace errors.
Conventions and PR template Passed.
Dependency and mergeability preview Each exact PR head previewed cleanly against current main. The checker notes newer heads of #13736, #13764 and #13816 are not included in this dependent branch; those dependencies remain open and should retain their declared landing order.
ABI audit Passed with warnings. The three new TaskQueueBase symbols each have one declaration and one definition; 60 lexical alias/hash warnings were on existing libwebrtcUnknown* symbols, not these additions.
Test registration heuristic Flagged TaskQueueBase.cpp as a possible unregistered C++ test; manual inspection confirmed CMake registers tests/TaskQueueBase.cpp as guest_webrtc_task_queue_base.
Hosted CI Windows, conventions, eligibility, intake, labels, library portability and report passed. Linux and specialized jobs were skipped.
C++ tests/build Not run locally. The author reports a Linux full build and the focused test; the full suite is pending.
Unedited convention-check output
All conventions checks passed.

Sources

Not verified

I did not run a local build or C++ test, test on a console, or independently reproduce the author's Linux run. The full suite remains pending, and CI skipped Linux and specialized jobs.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5724484788 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14087#pullrequestreview-5724484788). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T19:17:01Z. **Review:** APPROVED --- # Reviewed — looks good The thread-local current-queue implementation matches the cited WebRTC implementation, and I found no blocking issue in the reviewed stack head. ## What I ran Reviewed head `f2906923264c7dbd21449d58adeca231b34aabdf` against base `ca073ec3ad0d766ea9f4658e418a5c977001a353`; the PR stack check reported a clean merge preview. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0 (`c++`). No local build or C++ test was run. ```sh git diff --check ca073ec3ad0d766ea9f4658e418a5c977001a353...f2906923264c7dbd21449d58adeca231b34aabdf python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14087 python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base ca073ec3ad0d766ea9f4658e418a5c977001a353 --head f2906923264c7dbd21449d58adeca231b34aabdf --json python3 tools/pr_test_quality.py --root <isolated-head-worktree> --json core/libs/prx/libwebrtc/src/TaskQueueBase.cpp core/libs/prx/libwebrtc/tests/TaskQueueBase.cpp ``` ## Results | Check | Result | |---|---| | Diff check | Passed; no whitespace errors. | | Conventions and PR template | Passed. | | Dependency and mergeability preview | Each exact PR head previewed cleanly against current `main`. The checker notes newer heads of #13736, #13764 and #13816 are not included in this dependent branch; those dependencies remain open and should retain their declared landing order. | | ABI audit | Passed with warnings. The three new TaskQueueBase symbols each have one declaration and one definition; 60 lexical alias/hash warnings were on existing `libwebrtcUnknown*` symbols, not these additions. | | Test registration heuristic | Flagged `TaskQueueBase.cpp` as a possible unregistered C++ test; manual inspection confirmed CMake registers `tests/TaskQueueBase.cpp` as `guest_webrtc_task_queue_base`. | | Hosted CI | Windows, conventions, eligibility, intake, labels, library portability and report passed. Linux and specialized jobs were skipped. | | C++ tests/build | Not run locally. The author reports a Linux full build and the focused test; the full suite is pending. | <details><summary>Unedited convention-check output</summary> ```text All conventions checks passed. ``` </details> ## Sources - The implementation follows the `thread_local` branch in WebRTC [`task_queue_base.cc` at commit 8d78f5de6c27b2c793039989ea381f1428fb0100](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/task_queue/task_queue_base.cc#20). - The reviewed implementation is [`TaskQueueBase.cpp` at the PR head](https://github.com/boykopovar/AnyPS5/blob/f2906923264c7dbd21449d58adeca231b34aabdf/core/libs/prx/libwebrtc/src/TaskQueueBase.cpp#L49-L70); the test covers null initial state, nested restore, null queue, and thread isolation ([test at the PR head](https://github.com/boykopovar/AnyPS5/blob/f2906923264c7dbd21449d58adeca231b34aabdf/core/libs/prx/libwebrtc/tests/TaskQueueBase.cpp#L40-L108)). ## Not verified I did not run a local build or C++ test, test on a console, or independently reproduce the author's Linux run. The full suite remains pending, and CI skipped Linux and specialized jobs.
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!14087
No description provided.