Commit 3b77b8a5 authored by Fady Samuel's avatar Fady Samuel Committed by Commit Bot

Surface Synchronization: Don't use CompositorLock if enabled

Don't use the CompositorLock if surface synchronization is enabled.
This was causing issues on telemetry bots where the CompositorLock
was preventing the UI from submitting CompositorFrames for a long
period of time and so input latency was very high.

Before:
https://pinpoint-dot-chromeperf.appspot.com/job/11675b9b240000
After:
https://pinpoint-dot-chromeperf.appspot.com/job/152a7367240000

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I95407531216b543fb4c192387bd67fe690bee0b4
Bug: 672962
Reviewed-on: https://chromium-review.googlesource.com/1119191
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571414}
parent aba525ad
...@@ -198,7 +198,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( ...@@ -198,7 +198,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
if (using_browser_compositor_) { if (using_browser_compositor_) {
delegated_frame_host_ = std::make_unique<ui::DelegatedFrameHostAndroid>( delegated_frame_host_ = std::make_unique<ui::DelegatedFrameHostAndroid>(
&view_, CompositorImpl::GetHostFrameSinkManager(), this, &view_, CompositorImpl::GetHostFrameSinkManager(), this,
host()->GetFrameSinkId()); host()->GetFrameSinkId(), features::IsSurfaceSynchronizationEnabled());
if (is_showing_) { if (is_showing_) {
delegated_frame_host_->WasShown( delegated_frame_host_->WasShown(
local_surface_id_allocator_.GetCurrentLocalSurfaceId(), local_surface_id_allocator_.GetCurrentLocalSurfaceId(),
......
...@@ -60,14 +60,14 @@ DelegatedFrameHostAndroid::DelegatedFrameHostAndroid( ...@@ -60,14 +60,14 @@ DelegatedFrameHostAndroid::DelegatedFrameHostAndroid(
ui::ViewAndroid* view, ui::ViewAndroid* view,
viz::HostFrameSinkManager* host_frame_sink_manager, viz::HostFrameSinkManager* host_frame_sink_manager,
Client* client, Client* client,
const viz::FrameSinkId& frame_sink_id) const viz::FrameSinkId& frame_sink_id,
bool enable_surface_synchronization)
: frame_sink_id_(frame_sink_id), : frame_sink_id_(frame_sink_id),
view_(view), view_(view),
host_frame_sink_manager_(host_frame_sink_manager), host_frame_sink_manager_(host_frame_sink_manager),
client_(client), client_(client),
begin_frame_source_(this), begin_frame_source_(this),
enable_surface_synchronization_( enable_surface_synchronization_(enable_surface_synchronization),
features::IsSurfaceSynchronizationEnabled()),
enable_viz_( enable_viz_(
base::FeatureList::IsEnabled(features::kVizDisplayCompositor)), base::FeatureList::IsEnabled(features::kVizDisplayCompositor)),
frame_evictor_(std::make_unique<viz::FrameEvictor>(this)) { frame_evictor_(std::make_unique<viz::FrameEvictor>(this)) {
...@@ -221,8 +221,10 @@ void DelegatedFrameHostAndroid::AttachToCompositor( ...@@ -221,8 +221,10 @@ void DelegatedFrameHostAndroid::AttachToCompositor(
// browser in cases where the renderer hangs or another factor prevents a // browser in cases where the renderer hangs or another factor prevents a
// frame from being produced. If we already have delegated content, no need // frame from being produced. If we already have delegated content, no need
// to take the lock. // to take the lock.
if (!enable_viz_ && compositor->IsDrawingFirstVisibleFrame() && // If surface synchronization is enabled, then it will block browser UI until
!HasDelegatedContent()) { // a renderer frame is available instead.
if (!enable_surface_synchronization_ &&
compositor->IsDrawingFirstVisibleFrame() && !HasDelegatedContent()) {
compositor_attach_until_frame_lock_ = compositor->GetCompositorLock( compositor_attach_until_frame_lock_ = compositor->GetCompositorLock(
this, base::TimeDelta::FromSeconds(kFirstFrameTimeoutSeconds)); this, base::TimeDelta::FromSeconds(kFirstFrameTimeoutSeconds));
} }
......
...@@ -57,7 +57,8 @@ class UI_ANDROID_EXPORT DelegatedFrameHostAndroid ...@@ -57,7 +57,8 @@ class UI_ANDROID_EXPORT DelegatedFrameHostAndroid
DelegatedFrameHostAndroid(ViewAndroid* view, DelegatedFrameHostAndroid(ViewAndroid* view,
viz::HostFrameSinkManager* host_frame_sink_manager, viz::HostFrameSinkManager* host_frame_sink_manager,
Client* client, Client* client,
const viz::FrameSinkId& frame_sink_id); const viz::FrameSinkId& frame_sink_id,
bool enable_surface_synchronization);
~DelegatedFrameHostAndroid() override; ~DelegatedFrameHostAndroid() override;
......
...@@ -82,11 +82,19 @@ class DelegatedFrameHostAndroidTest : public testing::Test { ...@@ -82,11 +82,19 @@ class DelegatedFrameHostAndroidTest : public testing::Test {
lock_manager_(task_runner_, &lock_manager_client_) { lock_manager_(task_runner_, &lock_manager_client_) {
host_frame_sink_manager_.SetLocalManager(&frame_sink_manager_impl_); host_frame_sink_manager_.SetLocalManager(&frame_sink_manager_impl_);
frame_sink_manager_impl_.SetLocalClient(&host_frame_sink_manager_); frame_sink_manager_impl_.SetLocalClient(&host_frame_sink_manager_);
}
void SetUp() override {
view_.SetLayer(cc::SolidColorLayer::Create()); view_.SetLayer(cc::SolidColorLayer::Create());
frame_host_ = std::make_unique<DelegatedFrameHostAndroid>( frame_host_ = std::make_unique<DelegatedFrameHostAndroid>(
&view_, &host_frame_sink_manager_, &client_, frame_sink_id_); &view_, &host_frame_sink_manager_, &client_, frame_sink_id_,
ShouldEnableSurfaceSynchronization());
} }
void TearDown() override { frame_host_.reset(); }
virtual bool ShouldEnableSurfaceSynchronization() const { return false; }
ui::CompositorLock* GetLock(CompositorLockClient* client, ui::CompositorLock* GetLock(CompositorLockClient* client,
base::TimeDelta time_delta) { base::TimeDelta time_delta) {
return lock_manager_.GetCompositorLock(client, time_delta).release(); return lock_manager_.GetCompositorLock(client, time_delta).release();
...@@ -130,6 +138,24 @@ class DelegatedFrameHostAndroidTest : public testing::Test { ...@@ -130,6 +138,24 @@ class DelegatedFrameHostAndroidTest : public testing::Test {
CompositorLockManager lock_manager_; CompositorLockManager lock_manager_;
}; };
class DelegatedFrameHostAndroidSurfaceSynchronizationTest
: public DelegatedFrameHostAndroidTest {
public:
DelegatedFrameHostAndroidSurfaceSynchronizationTest() = default;
~DelegatedFrameHostAndroidSurfaceSynchronizationTest() override = default;
bool ShouldEnableSurfaceSynchronization() const override { return true; }
};
// If surface synchronization is enabled then we should not be acquiring a
// compositor lock on attach.
TEST_F(DelegatedFrameHostAndroidSurfaceSynchronizationTest,
NoCompositorLockOnAttach) {
EXPECT_CALL(compositor_, IsDrawingFirstVisibleFrame()).Times(0);
EXPECT_CALL(compositor_, DoGetCompositorLock(_, _)).Times(0);
frame_host_->AttachToCompositor(&compositor_);
}
TEST_F(DelegatedFrameHostAndroidTest, CompositorLockDuringFirstFrame) { TEST_F(DelegatedFrameHostAndroidTest, CompositorLockDuringFirstFrame) {
// Attach during the first frame, lock will be taken. // Attach during the first frame, lock will be taken.
EXPECT_CALL(compositor_, IsDrawingFirstVisibleFrame()).WillOnce(Return(true)); EXPECT_CALL(compositor_, IsDrawingFirstVisibleFrame()).WillOnce(Return(true));
......
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