[MM] Fix player.pl app resume failed issue 08/321908/3
authorwuxiaoliang <xliang.wu@samsung.com>
Tue, 1 Apr 2025 09:39:25 +0000 (17:39 +0800)
committerBot Blink <blinkbot@samsung.com>
Fri, 2 May 2025 04:46:04 +0000 (04:46 +0000)
There are 2 issues when resume:

case1: when resume, it's black screen.
1. WebMediaPlayerImpl::OnBeforePipelineResume try to enable video track, but video track is not disabled when suspend, it do nothing
2. WebMediaPlayerImpl::OnPipelineResumed and check hidden=true, then disable video track
3. WebMediaPlayerImpl::OnFrameShown comes and try to enable video track, but state is seeking/resuming, so ignore enable video track
4. OnReadyToPrepare comes and begin to read frames, as video track is disabled, so the first frame is eos

case2: play for some time after resume, and then video eos
1. WebMediaPlayerImpl::OnBeforePipelineResume try to enable video track, but video track is not disabled when suspend, it do nothing
2. OnReadyToPrepare is very quickly and push some frames to espp
3. WebMediaPlayerImpl::OnPipelineResumed and check hidden=true, then disable video track and send eos to espp
4. WebMediaPlayerImpl::OnFrameShown comes and check hidden=false, then enable video track, but eos is already sent to espp

OnReadyToPrepare is in browser process, OnPipelineResumed/OnPipelineSeeked is in render process.
we can't ensure the sequence of OnReadyToPrepare/OnPipelineResumed/OnFrameShown.
when suspend, it didn't disable video track.
when OnPipelineResumed, it should not disable video track.

Change-Id: Icf5af6d83df5b13f297a4b45273560408f46e582
Signed-off-by: wuxiaoliang <xliang.wu@samsung.com>
third_party/blink/renderer/platform/media/web_media_player_impl.cc

index f4d74b8fe93fe27ed825c39ce22ce58a6b138cd7..c55c43ad338e79cbc87fd7d53e5a021b4681de82 100644 (file)
@@ -1961,6 +1961,7 @@ void WebMediaPlayerImpl::OnCdmAttached(bool success) {
 void WebMediaPlayerImpl::OnPipelineSeeked(bool time_updated) {
   TRACE_EVENT2("media", "WebMediaPlayerImpl::OnPipelineSeeked", "target",
                seek_time_.InSecondsF(), "id", media_player_id_);
+  LOG(INFO) << "OnPipelineSeeked, this:" << (void*)this;
   seeking_ = false;
   seek_time_ = base::TimeDelta();
 
@@ -2081,8 +2082,17 @@ void WebMediaPlayerImpl::OnBeforePipelineResume() {
 }
 
 void WebMediaPlayerImpl::OnPipelineResumed() {
+  LOG(INFO) << "OnPipelineResumed, this:" << (void*)this;
   is_pipeline_resuming_ = false;
 
+// OnFrameShown and OnPipelineResumed sequence is not definitely
+// if OnFrameShown is later than OnPipelineResumed
+// when this fucntion called, hidden =true, then it will disable video track
+// set video_track_disabled_ = true to prevent disable video track
+#if BUILDFLAG(IS_TIZEN_TV)
+  video_track_disabled_ = true;
+#endif
+
   UpdateBackgroundVideoOptimizationState();
 }
 
@@ -3250,6 +3260,8 @@ void WebMediaPlayerImpl::OnPrePlayerReload(bool is_reload) {
 void WebMediaPlayerImpl::OnFrameHidden() {
   DCHECK(main_task_runner_->BelongsToCurrentThread());
 
+  LOG(INFO) << "OnFrameHidden, this:" << (void*)this;
+
   // Backgrounding a video requires a user gesture to resume playback.
   if (IsHidden())
     video_locked_when_paused_when_hidden_ = true;
@@ -3284,6 +3296,7 @@ void WebMediaPlayerImpl::SuspendForFrameClosed() {
 
 void WebMediaPlayerImpl::OnFrameShown() {
   DCHECK(main_task_runner_->BelongsToCurrentThread());
+  LOG(INFO) << "OnFrameShown, this:" << (void*)this;
   background_pause_timer_.Stop();
 
   // Foreground videos don't require user gesture to continue playback.