Skip to content

Commit

Permalink
Protect WMPI::ActivateSurfaceLayerForVideo From Multiple Invocations
Browse files Browse the repository at this point in the history
If ActivateSurfaceLayerForVideo is invoked more than once it will cause
a breakpoint crash when it attempts to run the OnceCallback
`create_bridge_callback_` a second time.

This change helps protect against this by moving the onus for checking
whether `surface_layer_for_video_enabled_` is set from the callers
of ActivateSurfaceLayerForVideo and instead adds a check directly in
ActivateSurfaceLayerForVideo.

Bug: 1502638
Change-Id: I49933b0b5b3d0f7ed0bb969e48eb4939187b8c2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5035701
Reviewed-by: Frank Liberato <liberato@chromium.org>
Reviewed-by: Frank Li <frankli@microsoft.com>
Commit-Queue: William Carr <wicarr@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1225689}
  • Loading branch information
WiCarr authored and Chromium LUCI CQ committed Nov 16, 2023
1 parent 69d3c4b commit 69d3bcc
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,7 @@ void WebMediaPlayerImpl::SetWasPlayedWithUserActivation(
}

void WebMediaPlayerImpl::OnRequestPictureInPicture() {
if (!surface_layer_for_video_enabled_)
ActivateSurfaceLayerForVideo();
ActivateSurfaceLayerForVideo();

DCHECK(bridge_);
DCHECK(bridge_->GetSurfaceId().is_valid());
Expand Down Expand Up @@ -2008,7 +2007,10 @@ void WebMediaPlayerImpl::OnMetadata(const media::PipelineMetadata& metadata) {

void WebMediaPlayerImpl::ActivateSurfaceLayerForVideo() {
// Note that we might or might not already be in VideoLayer mode.
DCHECK(!bridge_);
if (surface_layer_for_video_enabled_) {
// Surface layer has already been activated.
return;
}

surface_layer_for_video_enabled_ = true;

Expand Down

0 comments on commit 69d3bcc

Please sign in to comment.