Commit f5096612 authored by lionel.g.landwerlin's avatar lionel.g.landwerlin Committed by Commit bot

media: VideoRenderImpl: display last available frame

With a few webgl aquarium demo windows open and a 1080p video playing
at the same time, you can notice the video dropping a lot frames. From
time to time being stuck on a same frame for a second or more.

This is due to the VideoRendererImpl dropping frames. It takes too
much time for the compositor to paint its content, keeping the GPU
busy and delaying decoded video frames too long. Decoded frames arrive
too late and are never presented and we stick to an old frame.

This changes the behavior of VideoRendererImpl to a best effort
strategy where we might start displaying images past their display
time, but at least we're not stuck on a same image for too long.

BUG=chrome-os-partner:37786
TEST=run the test as explained on the bug

Review URL: https://codereview.chromium.org/1005303004

Cr-Commit-Position: refs/heads/master@{#322100}
parent 5f0cd338
......@@ -246,11 +246,13 @@ void VideoRendererImpl::ThreadMain() {
// Remain idle until we've reached our target paint window.
if (now < target_paint_timestamp) {
UpdateStatsAndWait_Locked(kIdleTimeDelta);
UpdateStatsAndWait_Locked(
std::min(target_paint_timestamp - now, kIdleTimeDelta));
continue;
}
if (now > latest_paint_timestamp && drop_frames_) {
if (ready_frames_.size() > 1 && now > latest_paint_timestamp &&
drop_frames_) {
DropNextReadyFrame_Locked();
continue;
}
......
......@@ -472,20 +472,31 @@ TEST_F(VideoRendererImplTest, VideoDecoder_InitFailure) {
TEST_F(VideoRendererImplTest, Underflow) {
Initialize();
QueueFrames("0 10 20 30");
EXPECT_CALL(mock_cb_, Display(HasTimestamp(0)));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
StartPlayingFrom(0);
{
WaitableMessageLoopEvent event;
EXPECT_CALL(mock_cb_, Display(HasTimestamp(0)))
.Times(1)
.WillOnce(RunClosure(event.GetClosure()));
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
StartPlayingFrom(0);
event.RunAndWait();
}
// Advance time slightly. Frames should be dropped and we should NOT signal
// having nothing.
AdvanceTimeInMs(100);
// Advance time more. Now we should signal having nothing.
// Advance time more. Now we should signal having nothing. And put
// the last frame up for display.
{
SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING");
WaitableMessageLoopEvent event;
EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING))
.WillOnce(RunClosure(event.GetClosure()));
EXPECT_CALL(mock_cb_, Display(HasTimestamp(10))).Times(0);
EXPECT_CALL(mock_cb_, Display(HasTimestamp(20))).Times(0);
EXPECT_CALL(mock_cb_, Display(HasTimestamp(30))).Times(1);
AdvanceTimeInMs(3000); // Must match kTimeToDeclareHaveNothing.
event.RunAndWait();
}
......
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