Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions webrtc-sys/src/frame_cryptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ FrameCryptor::~FrameCryptor() {
if (observer_) {
unregister_observer();
}
// Detach the transformer from the sender/receiver it was attached to in
// the constructor. Without this the RtpSender/RtpReceiver keeps the
// FrameCryptorTransformer (and the thread it owns) alive for as long as
// it exists, which outlives this object -- one leaked
// FrameCryptorTransformer thread per cryptor per room.
if (sender_) {
sender_->SetEncoderToPacketizerFrameTransformer(nullptr);
}
if (receiver_) {
receiver_->SetDepacketizerToDecoderFrameTransformer(nullptr);
Comment on lines +177 to +181

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Cryptor destruction removes other transforms

Dropping a cryptor after set_packet_trailer_handler also detaches the retained packet-trailer handler. A stale cryptor can likewise detach a replacement cryptor.

Prompt for agents
FrameCryptor::~FrameCryptor unconditionally sets the sender or receiver transformer to null. FrameCryptor::set_packet_trailer_handler replaces that slot with chained_transformer_, which contains both the cryptor and a PacketTrailerTransformer. Clearing the slot therefore disables packet-trailer processing even when the independently retained PacketTrailerHandler remains alive. The same ownership problem lets an older FrameCryptor clear a newer transformer installed on the same sender or receiver when its final SharedPtr is dropped later. Redesign teardown so a cryptor removes only the transformer installation it owns and preserves or restores other processing. Account for replacement cryptors and chained packet-trailer handlers rather than blindly clearing the shared endpoint slot.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

}
}

void FrameCryptor::register_observer(
Expand Down