From aef8f7bd7e7d13428274c6cf8ece56cbb3cb856d Mon Sep 17 00:00:00 2001 From: v-kryachko Date: Tue, 9 Jan 2024 00:27:15 +0300 Subject: [PATCH] Fix crash upon attempting to replay video. (#2162) b/318420573 Change-Id: Icc959ad87aafe10adea0d737984bd6e781e28835 --- starboard/xb1/shared/gpu_base_video_decoder.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/starboard/xb1/shared/gpu_base_video_decoder.cc b/starboard/xb1/shared/gpu_base_video_decoder.cc index 84bab910f24a..6cdc999fa054 100644 --- a/starboard/xb1/shared/gpu_base_video_decoder.cc +++ b/starboard/xb1/shared/gpu_base_video_decoder.cc @@ -555,11 +555,14 @@ int GpuVideoDecoderBase::OnOutputRetrieved( { ScopedLock input_queue_lock(written_inputs_mutex_); const auto iter = FindByTimestamp(written_inputs_, timestamp); - SB_DCHECK(iter != written_inputs_.cend()); - if (is_hdr_video_) { - image->AttachColorMetadata((*iter)->video_stream_info().color_metadata); + // Reset might be called too early, cause clearing of written_inputs_ and + // absence of requested timestamp. + if (iter != written_inputs_.cend()) { + if (is_hdr_video_) { + image->AttachColorMetadata((*iter)->video_stream_info().color_metadata); + } + written_inputs_.erase(iter); } - written_inputs_.erase(iter); } scoped_refptr frame(new VideoFrameImpl( timestamp, std::bind(&GpuVideoDecoderBase::DeleteVideoFrame, this,