feat(libwebrtc): release the frame buffer in the VideoFrame::Builder destructor #17419
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17419"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by primesoul-web on 2026-11-08T19:17:43Z.
What
webrtc::VideoFrame::Builder's destructor threw throughNotImplemented_nid_no_patchfor every builder that held a frame buffer, so aVideoFramebuilt from a buffer stopped the process. It now releases that reference through the buffer's virtualRelease, at slot 1 of the guest vtable:rtc::RefCountInterfacedeclaresAddRefand thenReleasein ref_count.h, andVideoFrameBufferinherits that pair before its own virtuals. The vtable pointer is read withGuestCopyIn_nid_no_patch, so an unreadable buffer throws instead of faulting, and a buffer whoseReleaseslot is null throws too.Packet infos still throw:
packet_infos_is a gueststd::vector<RtpPacketInfo>whose elements own guest allocations, and the host cannot run the guest destructor of an element. Upstream destroys members in reverse declaration order, so that throw comes before the buffer is released, as it does here. Thelibwebrtctechnical debt entry is cut to that remaining gap.Tested
No console and no title. The project build was not run here: this machine has no CMake and no C++ toolchain for the project's build, so
ctestwas not run and the first project build of this change is the reviewer's CI run.What was run: the changed
src/VideoFrameBuilder.cppand the updatedtests/VideoFrameBuilder.cppcompiled as C++20 with-Wall -Wextra -Werroragainst the repository headers, withGuestCopyIn_nid_no_patchandNotImplemented_nid_no_patchstubbed, on Linux x86-64, and the resulting test binary passed. The new checks cover: a builder holding a buffer callsReleaseonce with the buffer pointer and changes no other field; a builder without a buffer calls nothing; a buffer whoseReleaseslot is null throwsstd::invalid_argument; packet infos still throwstd::runtime_error; a null builder throwsstd::invalid_argument.python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/pr_overlap.py --branch feat/libwebrtc-builder-destructor-releasereports no open pull request changing the same lines or exports.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T19:39:17Z.
Review: COMMENTED
Windows run of head
704ae38ace, merged ontomain095ff72367. To save builds, this ran in one tree together with 24 other open PRs that touch different code; all 25 merged cleanly. Setup: Windows 11, WinLibs GCC 15.2 (x86_64-ucrt-posix-seh), Release,BUILD_TESTING=ON.guest_webrtc_video_frame_builderwith--repeat until-fail:5: 5 / 5 pass.main'sVideoFrameBuilder.cppand this PR's test: 5 / 5 runs fail withVideoFrame::Builder destructor with a buffer or packet infos: releasing guest references not implemented.From reading:
Releaseis slot 1 ofrtc::RefCountInterface, afterAddRef, sovtable[1]is the right entry. Throwing for packet infos before the buffer is released also matches the destruction order:packet_infos_is declared aftervideo_frame_buffer_invideo_frame.h, so it's destroyed first.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T06:08:30Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
704ae38ace:tools/check_conventions.pypassed;git diff --checkclean.guest_webrtc_video_frame_builder_testsbuilt cleanly.guest_webrtc_video_frame_builder):core/libs/prx/libwebrtc/src/VideoFrameBuilder.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me