Post OnRemotePlayStateChange
The FlingingRendererClient receives calls to OnRemotePlayStateChange on
the media task runner. It then propagates these changes to WMPI, which
calls into Blink. This might result in some crashes, when Blink tries
to allocate some resources on the wrong sequence.
This CL makes sure we are on the main task runner before calling into
Blink.
Bug: 983723
Change-Id: Ib3765c7dfd67c674e31becfc83c4ae7d4aeda612
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1802028
Commit-Queue: Thomas Guilbert <[email protected]>
Reviewed-by: Dan Sanders <[email protected]>
Cr-Commit-Position: refs/heads/master@{#696219}
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 9c1ba64c..f197763 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -414,8 +414,9 @@
media_metrics_provider_->SetIsAdMedia();
#if defined(OS_ANDROID)
- renderer_factory_selector_->SetRemotePlayStateChangeCB(base::BindRepeating(
- &WebMediaPlayerImpl::OnRemotePlayStateChange, weak_this_));
+ renderer_factory_selector_->SetRemotePlayStateChangeCB(
+ BindToCurrentLoop(base::BindRepeating(
+ &WebMediaPlayerImpl::OnRemotePlayStateChange, weak_this_)));
#endif // defined (OS_ANDROID)
}
@@ -2501,6 +2502,7 @@
void WebMediaPlayerImpl::OnRemotePlayStateChange(MediaStatus::State state) {
DCHECK(is_flinging_);
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
if (state == MediaStatus::State::PLAYING && Paused()) {
DVLOG(1) << __func__ << " requesting PLAY.";