From e45770707bd843805e500b81a6a70badc062e755 Mon Sep 17 00:00:00 2001 From: Mason Chang Date: Fri, 6 Mar 2015 13:58:22 -0800 Subject: [PATCH] Bug 1138502. Reset vsync unobserve count if a force composite occurs. r=mstange --- gfx/layers/ipc/CompositorParent.cpp | 21 +++++++++++++++++++++ gfx/layers/ipc/CompositorParent.h | 1 + 2 files changed, 22 insertions(+) diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 44244ebd0be9..76d34928cf09 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -343,6 +343,23 @@ CompositorVsyncObserver::Composite(TimeStamp aVsyncTimestamp) DispatchTouchEvents(aVsyncTimestamp); } +void +CompositorVsyncObserver::OnForceComposeToTarget() +{ + /** + * bug 1138502 - There are cases such as during long-running window resizing events + * where we receive many sync RecvFlushComposites. We also get vsync notifications which + * will increment mVsyncNotificationsSkipped because a composite just occurred. After + * enough vsyncs and RecvFlushComposites occurred, we will disable vsync. Then at the next + * ScheduleComposite, we will enable vsync, then get a RecvFlushComposite, which will + * force us to unobserve vsync again. On some platforms, enabling/disabling vsync is not + * free and this oscillating behavior causes a performance hit. In order to avoid this problem, + * we reset the mVsyncNotificationsSkipped counter to keep vsync enabled. + */ + MOZ_ASSERT(CompositorParent::IsInCompositorThread()); + mVsyncNotificationsSkipped = 0; +} + bool CompositorVsyncObserver::NeedsComposite() { @@ -1040,6 +1057,10 @@ CompositorParent::ForceComposeToTarget(DrawTarget* aTarget, const nsIntRect* aRe PROFILER_LABEL("CompositorParent", "ForceComposeToTarget", js::ProfileEntry::Category::GRAPHICS); + if (mCompositorVsyncObserver) { + mCompositorVsyncObserver->OnForceComposeToTarget(); + } + AutoRestore override(mOverrideComposeReadiness); mOverrideComposeReadiness = true; diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 88c87fc71b1b..8a4f12697886 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -106,6 +106,7 @@ public: bool NeedsComposite(); void CancelCurrentCompositeTask(); void Destroy(); + void OnForceComposeToTarget(); private: virtual ~CompositorVsyncObserver();