diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 7bb17b01c2..19d64392e3 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -774,18 +774,33 @@ void VideoStreamEncoder::MaybeEncodeVideoFrame(const VideoFrame& video_frame, stats_proxy_->OnInitialQualityResolutionAdaptDown(); } ++initial_rampup_; - pending_frame_ = video_frame; - pending_frame_post_time_us_ = time_when_posted_us; + // Storing references to a native buffer risks blocking frame capture. + if (video_frame.video_frame_buffer()->type() != + VideoFrameBuffer::Type::kNative) { + pending_frame_ = video_frame; + pending_frame_post_time_us_ = time_when_posted_us; + } else { + // Ensure that any previously stored frame is dropped. + pending_frame_.reset(); + } return; } initial_rampup_ = kMaxInitialFramedrop; if (EncoderPaused()) { - if (pending_frame_) + // Storing references to a native buffer risks blocking frame capture. + if (video_frame.video_frame_buffer()->type() != + VideoFrameBuffer::Type::kNative) { + if (pending_frame_) + TraceFrameDropStart(); + pending_frame_ = video_frame; + pending_frame_post_time_us_ = time_when_posted_us; + } else { + // Ensure that any previously stored frame is dropped. + pending_frame_.reset(); TraceFrameDropStart(); - pending_frame_ = video_frame; - pending_frame_post_time_us_ = time_when_posted_us; + } return; }