Bug 1117870. Compositor unobserve vsync after configurable number of notifications. r=benwa

This commit is contained in:
Mason Chang 2015-01-05 13:52:49 -08:00
parent a4ecf73623
commit 686385caee
3 changed files with 8 additions and 0 deletions

View File

@ -199,6 +199,7 @@ static void SetThreadPriority()
CompositorVsyncObserver::CompositorVsyncObserver(CompositorParent* aCompositorParent, nsIWidget* aWidget) CompositorVsyncObserver::CompositorVsyncObserver(CompositorParent* aCompositorParent, nsIWidget* aWidget)
: mNeedsComposite(false) : mNeedsComposite(false)
, mIsObservingVsync(false) , mIsObservingVsync(false)
, mVsyncNotificationsSkipped(0)
, mCompositorParent(aCompositorParent) , mCompositorParent(aCompositorParent)
, mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor") , mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor")
, mCurrentCompositeTask(nullptr) , mCurrentCompositeTask(nullptr)
@ -285,6 +286,9 @@ CompositorVsyncObserver::Composite(TimeStamp aVsyncTimestamp)
if (mNeedsComposite && mCompositorParent) { if (mNeedsComposite && mCompositorParent) {
mNeedsComposite = false; mNeedsComposite = false;
mCompositorParent->CompositeCallback(aVsyncTimestamp); mCompositorParent->CompositeCallback(aVsyncTimestamp);
mVsyncNotificationsSkipped = 0;
} else if (mVsyncNotificationsSkipped++ > gfxPrefs::CompositorUnobserveCount()) {
UnobserveVsync();
} }
DispatchTouchEvents(aVsyncTimestamp); DispatchTouchEvents(aVsyncTimestamp);

View File

@ -117,6 +117,7 @@ private:
bool mNeedsComposite; bool mNeedsComposite;
bool mIsObservingVsync; bool mIsObservingVsync;
int32_t mVsyncNotificationsSkipped;
nsRefPtr<CompositorParent> mCompositorParent; nsRefPtr<CompositorParent> mCompositorParent;
nsRefPtr<CompositorVsyncDispatcher> mCompositorVsyncDispatcher; nsRefPtr<CompositorVsyncDispatcher> mCompositorVsyncDispatcher;

View File

@ -219,6 +219,9 @@ private:
// Use vsync events generated by hardware // Use vsync events generated by hardware
DECL_GFX_PREF(Once, "gfx.vsync.hw-vsync.enabled", HardwareVsyncEnabled, bool, false); DECL_GFX_PREF(Once, "gfx.vsync.hw-vsync.enabled", HardwareVsyncEnabled, bool, false);
DECL_GFX_PREF(Once, "gfx.vsync.compositor", VsyncAlignedCompositor, bool, false); DECL_GFX_PREF(Once, "gfx.vsync.compositor", VsyncAlignedCompositor, bool, false);
// On b2g, in really bad cases, I've seen up to 80 ms delays between touch events and the main thread
// processing them. So 80 ms / 16 = 5 vsync events. Double it up just to be on the safe side, so 10.
DECL_GFX_PREF(Once, "gfx.vsync.compositor.unobserve-count", CompositorUnobserveCount, int32_t, 10);
DECL_GFX_PREF(Once, "gfx.touch.resample", TouchResampling, bool, false); DECL_GFX_PREF(Once, "gfx.touch.resample", TouchResampling, bool, false);
// These times should be in milliseconds // These times should be in milliseconds
DECL_GFX_PREF(Once, "gfx.touch.resample.max-predict", TouchResampleMaxPredict, int32_t, 8); DECL_GFX_PREF(Once, "gfx.touch.resample.max-predict", TouchResampleMaxPredict, int32_t, 8);