Skip to content

media: Restore paused video frame on reveal after conceal suspend - #13360

Merged
andrewsavage1 merged 1 commit into
youtube:mainfrom
andrewsavage1:fix-b573530009-paused-video-resume-frame
Oct 20, 2026
Merged

andrewsavage1 merged 1 commit into
youtube:mainfrom
andrewsavage1:fix-b573530009-paused-video-resume-frame

Conversation

@andrewsavage1

@andrewsavage1 andrewsavage1 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

When Cobalt conceals the application, SuspendForFrameClosed() is invoked and tears down the underlying SbPlayer, clearing the hardware video plane. Upon reveal (OnPageShown), if the video was paused with video tracks, UpdatePlayState_ComputePlayState() computes can_stay_suspended = true because pipeline_controller_->IsSuspended() is still true, preventing the pipeline from resuming and leaving a black screen.

To fix this with minimal upstream impact, when OnPageShown() is called after a frame-closed suspension on a paused video player:

  1. Clear any stale flag on the delegate (delegate_->ClearStaleFlag(delegate_id_)) so idle_suspended does not trigger.
  2. Call SetSuspendState(false) to resume the pipeline, which immediately flips pipeline_controller_->IsSuspended() to false so the subsequent UpdatePlayState() call keeps the pipeline resumed and decodes/renders the paused video frame.

Bug: 573530009
TAG=agy
CONV=cece9c0a-9ef6-4434-bffa-ac7e3bff2f8d

@andrewsavage1
andrewsavage1 requested a review from a team as a code owner October 14, 2026 22:48
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ❌ FAIL Some checks failed
CI / android ✅ PASS Passed
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ❌ FAIL Failed
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


media: Restore paused video frame on reveal

When Cobalt conceals the application, the underlying SbPlayer is torn
down. Upon reveal, if the video was paused, the pipeline remains
suspended because it assumes it can stay in that state. This results
in a black screen instead of showing the last paused frame.

This change forces the pipeline to resume and decode a single frame
when revealing a paused video. It hooks into the compositor to
trigger a repaint once the frame is processed, then allows the
player to return to an idle suspended state to save resources.

Bug: 573530009

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces Cobalt-specific logic to restore the first video frame after resuming playback from a suspended state. It updates WebMediaPlayerImpl to track first-frame needs when suspended and schedules a repaint via OnFirstFrameAfterResume upon resuming. The review feedback suggests simplifying the complex callback binding chain in MaybeRestoreFirstFrameAfterResume by reducing redundant conversions between Blink and Chromium callback types.

When Cobalt conceals the application, SuspendForFrameClosed() is invoked
and tears down the underlying SbPlayer, clearing the hardware video plane.
Upon reveal (OnPageShown), if the video was paused with video tracks,
UpdatePlayState_ComputePlayState() computes can_stay_suspended = true
because pipeline_controller_->IsSuspended() is still true, preventing the
pipeline from resuming and leaving a black screen.

To fix this with minimal upstream impact, when OnPageShown() is called
after a frame-closed suspension on a paused video player:
1. Clear any stale flag on the delegate so idle_suspended does not trigger.
2. Call SetSuspendState(false) to resume the pipeline, which immediately
   flips pipeline_controller_->IsSuspended() to false so the subsequent
   UpdatePlayState() call keeps the pipeline resumed and decodes/renders
   the paused video frame.

Bug: 573530009
TAG=agy
CONV=cece9c0a-9ef6-4434-bffa-ac7e3bff2f8d
@andrewsavage1
andrewsavage1 force-pushed the fix-b573530009-paused-video-resume-frame branch from 8d77532 to a1a8d9c Compare October 14, 2026 23:41
@andrewsavage1

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces Cobalt-specific logic within 'WebMediaPlayerImpl::OnPageShown' to clear the stale flag and update the suspend state when the player is paused, has video, and was suspended due to a closed frame. The review feedback highlights a potential null pointer dereference on 'delegate_' and suggests adding a null check before invoking 'ClearStaleFlag'.

@andrewsavage1
andrewsavage1 requested a review from borongc October 20, 2026 23:33

@yell0wd0g yell0wd0g left a comment

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.

RS LGTM since it only affects WMP and it has been approved by a media dev.

@andrewsavage1
andrewsavage1 merged commit 3ed873d into youtube:main Oct 20, 2026
1196 of 1218 checks passed
@andrewsavage1
andrewsavage1 deleted the fix-b573530009-paused-video-resume-frame branch October 20, 2026 23:46
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 21, 2026
…ter conceal suspend

Refer to original PR: #13360

When Cobalt conceals the application, `SuspendForFrameClosed()` is
invoked and tears down the underlying `SbPlayer`, clearing the hardware
video plane. Upon reveal (`OnPageShown`), if the video was paused with
video tracks, `UpdatePlayState_ComputePlayState()` computes
`can_stay_suspended = true` because
`pipeline_controller_->IsSuspended()` is still `true`, preventing the
pipeline from resuming and leaving a black screen.

To fix this with minimal upstream impact, when `OnPageShown()` is called
after a frame-closed suspension on a paused video player:
1. Clear any stale flag on the delegate
(`delegate_->ClearStaleFlag(delegate_id_)`) so `idle_suspended` does not
trigger.
2. Call `SetSuspendState(false)` to resume the pipeline, which
immediately flips `pipeline_controller_->IsSuspended()` to `false` so
the subsequent `UpdatePlayState()` call keeps the pipeline resumed and
decodes/renders the paused video frame.

Bug: 573530009
TAG=agy
CONV=cece9c0a-9ef6-4434-bffa-ac7e3bff2f8d

(cherry picked from commit 3ed873d)
briantting pushed a commit that referenced this pull request Oct 21, 2026
…ter conceal suspend

Refer to original PR: #13360

When Cobalt conceals the application, `SuspendForFrameClosed()` is
invoked and tears down the underlying `SbPlayer`, clearing the hardware
video plane. Upon reveal (`OnPageShown`), if the video was paused with
video tracks, `UpdatePlayState_ComputePlayState()` computes
`can_stay_suspended = true` because
`pipeline_controller_->IsSuspended()` is still `true`, preventing the
pipeline from resuming and leaving a black screen.

To fix this with minimal upstream impact, when `OnPageShown()` is called
after a frame-closed suspension on a paused video player:
1. Clear any stale flag on the delegate
(`delegate_->ClearStaleFlag(delegate_id_)`) so `idle_suspended` does not
trigger.
2. Call `SetSuspendState(false)` to resume the pipeline, which
immediately flips `pipeline_controller_->IsSuspended()` to `false` so
the subsequent `UpdatePlayState()` call keeps the pipeline resumed and
decodes/renders the paused video frame.

Bug: 573530009
TAG=agy
CONV=cece9c0a-9ef6-4434-bffa-ac7e3bff2f8d

(cherry picked from commit 3ed873d)
briantting pushed a commit that referenced this pull request Oct 26, 2026
…reveal after conceal suspend

Refer to original PR: #13360

When Cobalt conceals the application, `SuspendForFrameClosed()` is
invoked and tears down the underlying `SbPlayer`, clearing the hardware
video plane. Upon reveal (`OnPageShown`), if the video was paused with
video tracks, `UpdatePlayState_ComputePlayState()` computes
`can_stay_suspended = true` because
`pipeline_controller_->IsSuspended()` is still `true`, preventing the
pipeline from resuming and leaving a black screen.

To fix this with minimal upstream impact, when `OnPageShown()` is called
after a frame-closed suspension on a paused video player:
1. Clear any stale flag on the delegate
(`delegate_->ClearStaleFlag(delegate_id_)`) so `idle_suspended` does not
trigger.
2. Call `SetSuspendState(false)` to resume the pipeline, which
immediately flips `pipeline_controller_->IsSuspended()` to `false` so
the subsequent `UpdatePlayState()` call keeps the pipeline resumed and
decodes/renders the paused video frame.

Bug: 573530009
TAG=agy
CONV=cece9c0a-9ef6-4434-bffa-ac7e3bff2f8d

(cherry picked from commit 3ed873d)
briantting pushed a commit that referenced this pull request Oct 26, 2026
…n reveal after conceal suspend (#13628)

Automated cherry-pick roll to staging.

Original pull requests:
- #13360

CONFLICTED files:
```
third_party/blink/renderer/platform/media/web_media_player_impl.cc
```

⚠️ This PR has conflicts that must be resolved manually (don't forget to
update the `.github/AUTOROLL` file). Use the following commands to
checkout the branch locally and resolve the conflicts in a separate
commit:

```bash
gh pr checkout <pull_request_number> -R youtube/cobalt

# Resolve conflicts and update .github/AUTOROLL then
git add <resolved_files>

# Copy CONFLICTED commit's message and metadata
# Replace CONFLICTED in title with RESOLVED
git commit -c <conflicted_sha>

git push origin autoroll-main-to-staging
```

---------

Co-authored-by: Andrew Savage <andrewsavage@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants