feat(libwebrtc): implement the rtc::LogMessage statics and PendingTaskSafetyFlag state accessors #15211
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15211"
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 simnJS on 2026-11-02T20:47:59Z.
What
Implements 11 libwebrtc exports: the nine
rtc::LogMessagestatics (GetMinLogSeverity,GetLogToDebug,LogToDebug,LogThreads,LogTimestamps,SetLogToStderr,AddLogToStream,RemoveLogToStream,IsNoop) andwebrtc::PendingTaskSafetyFlag::SetNotAliveandalive.They are adapted from
rtc_base/logging.ccandapi/task_queue/pending_task_safety_flag.cc, whose logic is the same at M127 (e0b28a6a81a989c1f5c89e30fcd247870047390d) and M134 (8d78f5de6c27b2c793039989ea381f1428fb0100), the two bounds the debt file gives for the module, apart from a[[maybe_unused]]and includes. Adding a null or already registered sink throws, where upstream writes through it or loops.The debt file records what these exports assume about the console build and what a comparison with the console would close:
NDEBUG, so the default severity isLS_NONE;RTC_LOG_ENABLED(), which placesLogSink::next_at offset 8 andmin_severity_at 16; and disabledDCHECKs, so theRTC_DCHECK_RUN_ONofSetNotAliveandalivedoes not apply.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release:
guest_webrtc_log_messageandguest_webrtc_pending_task_safety_flagpass (severities, ordering, sink removal, invalid arguments, safety flag state). Only these tests were run, not the full suite. Not run on Linux or on a title.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 BunnyFl on 2026-11-03T23:36:05Z.
Review: APPROVED
@simnJS approved at
ea45c4dc50. The firmware agrees with each assumption your debt entry lists.What I ran: this head merged onto
main(merge593238cc56), Windows 11, WinLibs GCC, Release.guest_webrtc_log_message,guest_webrtc_pending_task_safety_flagandpublic_headerspass (3 of 3).g_minSeveritystarting atWebRtcLsInfoinstead ofWebRtcLsNone,guest_webrtc_log_messagefails atLogMessage.cpp:142, the initial-default check (1 of 1 failed). A swap ofmain's files has nothing to restore: the definitions are in the newsrc/LogMessage.cpp.Firmware: 13.42
system/common/lib/libwebrtc.sprx(sha256d59d0caf6967329b39201a2a0bd6df7b994516f21701b9801908db6735ae5314), read from disassembly, not run.0x9c0060hold01 01 00 00 04 00 00 00 04 00 00 00. That is stderr logging on and streams empty, then the debug severity (0x9c0064) and the minimum severity (0x9c0068) both 4,LS_NONE. These are writable, so I also disassembled the whole code segment: every store to0x9c0064or0x9c0068is insideLogToDebug,AddLogToStreamorRemoveLogToStream, and no initializer writes them. So theNDEBUGdefault is the starting value.AddLogToStream(0x153bd0):0x10(%rbx)(153bf3) and linksnext_at0x8(%rbx)(153bfd). That gives the offsets 8 and 16 yourstatic_asserts pin.0x9c0770) and clears streams-empty (153c08).153c20–153c31).153bf3, and that is what your throw replaces.RemoveLogToStream(0x153c90): unlinks the first match, sets streams-empty to whether the list is now empty, then recomputes the minimum. If the sink isn't found, it still runs both updates. Your loop does the same.LogToDebug(0x153a20): stores the debug severity, then recomputes the minimum under the lock.IsNoop(0x154040): returns false when the severity is at least the debug or the minimum severity, otherwise the streams-empty byte. That is your condition.PendingTaskSafetyFlag:SetNotAlive(0x3be5b0) ismovb $0x0,0x4(%rdi)andalive(0x3be5d0) ismovzbl 0x4(%rdi),%eax. Soaliveis at offset 4, as yourstatic_assertsays, and neither does a sequence check.One thing for whoever wires up more of
LogMessagelater: the firmware creates its logging mutex lazily (the guard at0x9c07a8, around153c43–153c7d). The function-localstatic std::mutexhere behaves the same as far as these exports can tell.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T18:34:35Z.
Review: COMMENTED
@simnJS re-checked at
2f22d9f03d. The code is unchanged, but there is one count I should have caught at my approval.The debt count is one too high, at my approval too.
docs/dev/debt/libwebrtc.md:5says 329 exports. Counted from the files, the entry's number is the throwing stubs incore/libs/prx/libwebrtc/Export.cppplus the 60 bound by NID:4f41f4c375main9fb6149d12ea45c4dc50(my approval)2f22d9f03dThe PR removes 11 stubs (the nine
rtc::LogMessagefunctions and the twoPendingTaskSafetyFlagaccessors), but the count drops by 10. So it should read 328. My approval atea45c4dc50missed this, sorry about that.One unrelated change from a merge, non-blocking. One of the two
mainmerges since my approval reordered two includes incore/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, a file this PR doesn't otherwise touch.MediaExports.hppmoved belowJsonExports.hpp(:17-18), andWtfValueExports.hppmoved to:22, wheremainhas them at:17,:18and:20. It builds either way. Takingmain's version of that file would keep it out of the diff.What I ran
The PR's own +/- lines in
Export.cppare the same as atea45c4dc50; only the hunk boundaries moved withmain. Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this head merged onto currentmain(mergedcac827b51):guest_webrtc_log_message,guest_webrtc_pending_task_safety_flagandpublic_headers: 3 of 3 pass.f6327979fb): withg_minSeveritystarting atWebRtcLsInfoinstead ofWebRtcLsNone(src/LogMessage.cpp:52),guest_webrtc_log_messageaborts (0xc0000409), 0 of 1 pass.tools/check_conventions.py --base upstream/main --headon this head: all checks pass.With the count fixed, my approval stands.
AI-assisted: yes (Claude Code)