Commit 28a311ff authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

VideoSurfaceLayer: handle context lost between scheduling and submission of frame.

Bug: 855051, 853609
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ieedad00a60f3a64cf256771dc234953a928b5073
Reviewed-on: https://chromium-review.googlesource.com/1110667Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: CJ DiMeglio <lethalantidote@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569417}
parent 4e46bc21
...@@ -200,7 +200,11 @@ void VideoFrameSubmitter::SubmitFrame( ...@@ -200,7 +200,11 @@ void VideoFrameSubmitter::SubmitFrame(
scoped_refptr<media::VideoFrame> video_frame) { scoped_refptr<media::VideoFrame> video_frame) {
TRACE_EVENT0("media", "VideoFrameSubmitter::SubmitFrame"); TRACE_EVENT0("media", "VideoFrameSubmitter::SubmitFrame");
DCHECK_CALLED_ON_VALID_THREAD(media_thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(media_thread_checker_);
DCHECK(compositor_frame_sink_);
// The context may have been destroyed between the call being scheduled and it
// running. The lack of compositor_frame_sink_ is used as a sign.
if (!compositor_frame_sink_)
return;
viz::CompositorFrame compositor_frame; viz::CompositorFrame compositor_frame;
std::unique_ptr<viz::RenderPass> render_pass = viz::RenderPass::Create(); std::unique_ptr<viz::RenderPass> render_pass = viz::RenderPass::Create();
......
...@@ -82,6 +82,8 @@ class PLATFORM_EXPORT VideoFrameSubmitter ...@@ -82,6 +82,8 @@ class PLATFORM_EXPORT VideoFrameSubmitter
void DidDeleteSharedBitmap(const viz::SharedBitmapId&) override; void DidDeleteSharedBitmap(const viz::SharedBitmapId&) override;
private: private:
FRIEND_TEST_ALL_PREFIXES(VideoFrameSubmitterTest, ContextLostDuringSubmit);
void StartSubmitting(); void StartSubmitting();
void SubmitFrame(viz::BeginFrameAck, scoped_refptr<media::VideoFrame>); void SubmitFrame(viz::BeginFrameAck, scoped_refptr<media::VideoFrame>);
......
...@@ -483,4 +483,29 @@ TEST_F(VideoFrameSubmitterTest, WaitingForAckPreventsNewFrame) { ...@@ -483,4 +483,29 @@ TEST_F(VideoFrameSubmitterTest, WaitingForAckPreventsNewFrame) {
scoped_task_environment_.RunUntilIdle(); scoped_task_environment_.RunUntilIdle();
} }
// Test that no crash happens if the context is lost during a frame submission.
TEST_F(VideoFrameSubmitterTest, ContextLostDuringSubmit) {
MakeSubmitter();
scoped_task_environment_.RunUntilIdle();
EXPECT_CALL(*sink_, SetNeedsBeginFrame(true));
submitter_->StartRendering();
scoped_task_environment_.RunUntilIdle();
EXPECT_CALL(*provider_, GetCurrentFrame())
.WillOnce(Return(media::VideoFrame::CreateFrame(
media::PIXEL_FORMAT_YV12, gfx::Size(8, 8), gfx::Rect(gfx::Size(8, 8)),
gfx::Size(8, 8), base::TimeDelta())));
EXPECT_CALL(*provider_, PutCurrentFrame());
// This will post a task that will later call SubmitFrame(). The call will
// happen after OnContextLost().
submitter_->SubmitSingleFrame();
submitter_->OnContextLost();
scoped_task_environment_.RunUntilIdle();
}
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment