Commit fa845ac5 authored by junov's avatar junov Committed by Commit bot

Adjust OffscreenCanvas throttling to allow two frames of backlog

The throttling fix landed in https://codereview.chromium.org/2817603004/
has severely impacted rendering throughput due to the delay in
compositor round trips.  To avoid blocking the renderer script's
animation loop, we need to allow the rendering proceed when there
is still a pending frame.

BUG=716138

Review-Url: https://codereview.chromium.org/2848553003
Cr-Commit-Position: refs/heads/master@{#468021}
parent 11971703
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
namespace blink { namespace blink {
enum {
kMaxPendingCompositorFrames = 2,
};
OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl( OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(
OffscreenCanvasFrameDispatcherClient* client, OffscreenCanvasFrameDispatcherClient* client,
uint32_t client_id, uint32_t client_id,
...@@ -399,14 +403,15 @@ void OffscreenCanvasFrameDispatcherImpl::DispatchFrame( ...@@ -399,14 +403,15 @@ void OffscreenCanvasFrameDispatcherImpl::DispatchFrame(
change_size_for_next_commit_ = false; change_size_for_next_commit_ = false;
} }
compositor_has_pending_frame_ = true; pending_compositor_frames_++;
sink_->SubmitCompositorFrame(current_local_surface_id_, std::move(frame)); sink_->SubmitCompositorFrame(current_local_surface_id_, std::move(frame));
} }
void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck( void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck(
const cc::ReturnedResourceArray& resources) { const cc::ReturnedResourceArray& resources) {
ReclaimResources(resources); ReclaimResources(resources);
compositor_has_pending_frame_ = false; pending_compositor_frames_--;
DCHECK_GE(pending_compositor_frames_, 0);
} }
void OffscreenCanvasFrameDispatcherImpl::SetNeedsBeginFrame( void OffscreenCanvasFrameDispatcherImpl::SetNeedsBeginFrame(
...@@ -426,7 +431,7 @@ void OffscreenCanvasFrameDispatcherImpl::OnBeginFrame( ...@@ -426,7 +431,7 @@ void OffscreenCanvasFrameDispatcherImpl::OnBeginFrame(
begin_frame_args.source_id, begin_frame_args.sequence_number, begin_frame_args.source_id, begin_frame_args.sequence_number,
begin_frame_args.sequence_number, false); begin_frame_args.sequence_number, false);
if (compositor_has_pending_frame_ || if (pending_compositor_frames_ >= kMaxPendingCompositorFrames ||
(begin_frame_args.type == cc::BeginFrameArgs::MISSED && (begin_frame_args.type == cc::BeginFrameArgs::MISSED &&
base::TimeTicks::Now() > begin_frame_args.deadline)) { base::TimeTicks::Now() > begin_frame_args.deadline)) {
sink_->BeginFrameDidNotSwap(current_begin_frame_ack_); sink_->BeginFrameDidNotSwap(current_begin_frame_ack_);
......
...@@ -64,7 +64,7 @@ class PLATFORM_EXPORT OffscreenCanvasFrameDispatcherImpl final ...@@ -64,7 +64,7 @@ class PLATFORM_EXPORT OffscreenCanvasFrameDispatcherImpl final
int height_; int height_;
bool change_size_for_next_commit_; bool change_size_for_next_commit_;
bool needs_begin_frame_; bool needs_begin_frame_;
bool compositor_has_pending_frame_ = false; int pending_compositor_frames_ = 0;
unsigned next_resource_id_; unsigned next_resource_id_;
HashMap<unsigned, RefPtr<StaticBitmapImage>> cached_images_; HashMap<unsigned, RefPtr<StaticBitmapImage>> cached_images_;
......
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