diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 39a8c99c7154..42f3cdbf9247 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -28,7 +28,6 @@ #include "nsPoint.h" // for nsIntPoint #include "nsThreadUtils.h" // for NS_IsMainThread #include "OverscrollHandoffState.h" // for OverscrollHandoffState -#include "TaskThrottler.h" // for TaskThrottler #include "TreeTraversal.h" // for generic tree traveral algorithms #include "LayersLogging.h" // for Stringify #include "Units.h" // for ParentlayerPixel @@ -110,11 +109,10 @@ APZCTreeManager::~APZCTreeManager() AsyncPanZoomController* APZCTreeManager::NewAPZCInstance(uint64_t aLayersId, - GeckoContentController* aController, - TaskThrottler* aPaintThrottler) + GeckoContentController* aController) { return new AsyncPanZoomController(aLayersId, this, mInputQueue, - aController, aPaintThrottler, AsyncPanZoomController::USE_GESTURE_DETECTOR); + aController, AsyncPanZoomController::USE_GESTURE_DETECTOR); } TimeStamp @@ -200,32 +198,6 @@ APZCTreeManager::UpdateHitTestingTree(CompositorParent* aCompositor, #endif } -void -APZCTreeManager::InitializeForLayersId(uint64_t aLayersId) -{ - MOZ_ASSERT(NS_IsMainThread()); - auto throttlerInsertResult = mPaintThrottlerMap.insert( - std::make_pair(aLayersId, RefPtr())); - if (throttlerInsertResult.second) { - throttlerInsertResult.first->second = new TaskThrottler( - GetFrameTime(), TimeDuration::FromMilliseconds(500)); - } -} - -void -APZCTreeManager::AdoptLayersId(uint64_t aLayersId, APZCTreeManager* aOldManager) -{ - MOZ_ASSERT(aOldManager); - if (aOldManager == this) { - return; - } - auto iter = aOldManager->mPaintThrottlerMap.find(aLayersId); - if (iter != aOldManager->mPaintThrottlerMap.end()) { - mPaintThrottlerMap[aLayersId] = iter->second; - aOldManager->mPaintThrottlerMap.erase(iter); - } -} - // Compute the clip region to be used for a layer with an APZC. This function // is only called for layers which actually have scrollable metrics and an APZC. static ParentLayerIntRegion @@ -461,12 +433,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer, // a destroyed APZC and so we need to throw that out and make a new one. bool newApzc = (apzc == nullptr || apzc->IsDestroyed()); if (newApzc) { - // Look up the paint throttler for this layers id, or create it if - // this is the first APZC for this layers id. - RefPtr throttler = mPaintThrottlerMap[aLayersId]; - MOZ_ASSERT(throttler); - - apzc = NewAPZCInstance(aLayersId, state->mController, throttler); + apzc = NewAPZCInstance(aLayersId, state->mController); apzc->SetCompositorParent(aState.mCompositor); if (state->mCrossProcessParent != nullptr) { apzc->ShareFrameMetricsAcrossProcesses(); @@ -656,23 +623,10 @@ WillHandleInput(const PanGestureOrScrollWheelInput& aPanInput) void APZCTreeManager::FlushApzRepaints(uint64_t aLayersId) { + // Previously, paints were throttled and therefore this method was used to + // ensure any pending paints were flushed. Now, paints are flushed + // immediately, so it is safe to simply send a notification now. APZCTM_LOG("Flushing repaints for layers id %" PRIu64, aLayersId); - { // scope lock - MonitorAutoLock lock(mTreeLock); - mTreeLock.AssertCurrentThreadOwns(); - - ForEachNode(mRootNode.get(), - [aLayersId](HitTestingTreeNode* aNode) - { - if (aNode->IsPrimaryHolder()) { - AsyncPanZoomController* apzc = aNode->GetApzc(); - MOZ_ASSERT(apzc); - if (apzc->GetGuid().mLayersId == aLayersId) { - apzc->FlushRepaintIfPending(); - } - } - }); - } const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId); MOZ_ASSERT(state && state->mController); NS_DispatchToMainThread(NS_NewRunnableMethod( diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 49904541f5d7..f6b9fd4b633e 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -52,7 +52,6 @@ class LayerMetricsWrapper; class InputQueue; class GeckoContentController; class HitTestingTreeNode; -class TaskThrottler; /** * ****************** NOTE ON LOCK ORDERING IN APZ ************************** @@ -137,17 +136,6 @@ public: uint64_t aOriginatingLayersId, uint32_t aPaintSequenceNumber); - /** - * Do any per-layers-id setup needed. This will be called on the main thread, - * and may be called multiple times for the same layers id. - */ - void InitializeForLayersId(uint64_t aLayersId); - - /** - * Move any per-layers-id state from the old APZCTreeManager to this one. - */ - void AdoptLayersId(uint64_t aLayersId, APZCTreeManager* aOldManager); - /** * Walk the tree of APZCs and flushes the repaint requests for all the APZCS * corresponding to the given layers id. Finally, sends a flush complete @@ -419,8 +407,7 @@ protected: // Protected hooks for gtests subclass virtual AsyncPanZoomController* NewAPZCInstance(uint64_t aLayersId, - GeckoContentController* aController, - TaskThrottler* aPaintThrottler); + GeckoContentController* aController); public: // Public hooks for gtests subclass virtual TimeStamp GetFrameTime(); @@ -535,10 +522,6 @@ private: /* Holds the zoom constraints for scrollable layers, as determined by the * the main-thread gecko code. */ std::map mZoomConstraints; - /* Stores a paint throttler for each layers id. There is one for each layers - * id to ensure that one child process painting slowly doesn't hold up - * another. */ - std::map> mPaintThrottlerMap; /* This tracks the APZC that should receive all inputs for the current input event block. * This allows touch points to move outside the thing they started on, but still have the * touch events delivered to the same initial APZC. This will only ever be touched on the diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 86c6582e1942..a4424c13e488 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -18,7 +18,6 @@ #include "InputBlockState.h" // for InputBlockState, TouchBlockState #include "InputQueue.h" // for InputQueue #include "OverscrollHandoffState.h" // for OverscrollHandoffState -#include "TaskThrottler.h" // for TaskThrottler #include "Units.h" // for CSSRect, CSSPoint, etc #include "UnitTransforms.h" // for TransformTo #include "base/message_loop.h" // for MessageLoop @@ -848,10 +847,8 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId, APZCTreeManager* aTreeManager, const RefPtr& aInputQueue, GeckoContentController* aGeckoContentController, - TaskThrottler* aPaintThrottler, GestureBehavior aGestures) : mLayersId(aLayersId), - mPaintThrottler(aPaintThrottler), mGeckoContentController(aGeckoContentController), mRefPtrMonitor("RefPtrMonitor"), // mTreeManager must be initialized before GetFrameTime() is called @@ -2764,9 +2761,6 @@ void AsyncPanZoomController::FlushRepaintForNewInputBlock() { UpdateSharedCompositorFrameMetrics(); } -void AsyncPanZoomController::FlushRepaintIfPending() { -} - bool AsyncPanZoomController::SnapBackIfOverscrolled() { ReentrantMonitorAutoEnter lock(mMonitor); // It's possible that we're already in the middle of an overscroll diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index ac59b2425c5c..ad968c878b81 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -24,7 +24,6 @@ #include "APZUtils.h" #include "Layers.h" // for Layer::ScrollDirection #include "LayersTypes.h" -#include "TaskThrottler.h" #include "mozilla/gfx/Matrix.h" #include "nsRegion.h" @@ -104,7 +103,6 @@ public: APZCTreeManager* aTreeManager, const RefPtr& aInputQueue, GeckoContentController* aController, - TaskThrottler* aPaintThrottler, GestureBehavior aGestures = DEFAULT_GESTURES); // -------------------------------------------------------------------------- @@ -186,11 +184,6 @@ public: */ void NotifyLayersUpdated(const FrameMetrics& aLayerMetrics, bool aIsFirstPaint); - /** - * Flush any pending repaint request. - */ - void FlushRepaintIfPending(); - /** * The platform implementation must set the compositor parent so that we can * request composites. @@ -650,7 +643,6 @@ protected: uint64_t mLayersId; RefPtr mCompositorParent; - RefPtr mPaintThrottler; /* Access to the following two fields is protected by the mRefPtrMonitor, since they are accessed on the UI thread but can be cleared on the diff --git a/gfx/layers/apz/src/TaskThrottler.cpp b/gfx/layers/apz/src/TaskThrottler.cpp deleted file mode 100644 index 415bf984d964..000000000000 --- a/gfx/layers/apz/src/TaskThrottler.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */ -/* vim: set sw=2 sts=2 ts=8 et tw=80 : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "TaskThrottler.h" - -#include "mozilla/layers/APZThreadUtils.h" - -#define TASK_LOG(...) -// #define TASK_LOG(...) printf_stderr("TASK: " __VA_ARGS__) - -namespace mozilla { -namespace layers { - -TaskThrottler::TaskThrottler(const TimeStamp& aTimeStamp, const TimeDuration& aMaxWait) - : mMonitor("TaskThrottler") - , mOutstanding(false) - , mQueuedTask(nullptr) - , mStartTime(aTimeStamp) - , mMaxWait(aMaxWait) - , mMean(1) - , mTimeoutTask(nullptr) -{ -} - -TaskThrottler::~TaskThrottler() -{ - // The timeout task holds a strong reference to the TaskThrottler, so if the - // TaskThrottler is being destroyed, there's no need to cancel the task. -} - -void -TaskThrottler::PostTask(const tracked_objects::Location& aLocation, - UniquePtr aTask, const TimeStamp& aTimeStamp) -{ - MonitorAutoLock lock(mMonitor); - - TASK_LOG("%p got a task posted; mOutstanding=%d\n", this, mOutstanding); - aTask->SetBirthPlace(aLocation); - - if (mOutstanding) { - CancelPendingTask(lock); - if (TimeSinceLastRequest(aTimeStamp, lock) < mMaxWait) { - mQueuedTask = Move(aTask); - TASK_LOG("%p queued task %p\n", this, mQueuedTask.get()); - // Make sure the queued task is sent after mMaxWait time elapses, - // even if we don't get a TaskComplete() until then. - TimeDuration timeout = mMaxWait - TimeSinceLastRequest(aTimeStamp, lock); - mTimeoutTask = NewRunnableMethod(this, &TaskThrottler::OnTimeout); - APZThreadUtils::RunDelayedTaskOnCurrentThread(mTimeoutTask, timeout); - return; - } - // we've been waiting for more than the max-wait limit, so just fall through - // and send the new task already. - } - - mStartTime = aTimeStamp; - aTask->Run(); - mOutstanding = true; -} - -void -TaskThrottler::OnTimeout() -{ - MonitorAutoLock lock(mMonitor); - if (mQueuedTask) { - RunQueuedTask(TimeStamp::Now(), lock); - } - // The message loop will delete the posted timeout task. Make sure we don't - // keep a dangling pointer to it. - mTimeoutTask = nullptr; -} - -void -TaskThrottler::TaskComplete(const TimeStamp& aTimeStamp) -{ - MonitorAutoLock lock(mMonitor); - - if (!mOutstanding) { - return; - } - - mMean.insert(aTimeStamp - mStartTime); - - if (mQueuedTask) { - RunQueuedTask(aTimeStamp, lock); - CancelTimeoutTask(lock); - } else { - mOutstanding = false; - } -} - -TimeDuration -TaskThrottler::AverageDuration() -{ - MonitorAutoLock lock(mMonitor); - - return mMean.empty() ? TimeDuration() : mMean.mean(); -} - -void -TaskThrottler::RunQueuedTask(const TimeStamp& aTimeStamp, - const MonitorAutoLock& aProofOfLock) -{ - TASK_LOG("%p running task %p\n", this, mQueuedTask.get()); - mStartTime = aTimeStamp; - mQueuedTask->Run(); - mQueuedTask = nullptr; -} - -void -TaskThrottler::CancelPendingTask() -{ - MonitorAutoLock lock(mMonitor); - CancelPendingTask(lock); -} - -void -TaskThrottler::CancelPendingTask(const MonitorAutoLock& aProofOfLock) -{ - if (mQueuedTask) { - TASK_LOG("%p cancelling task %p\n", this, mQueuedTask.get()); - mQueuedTask->Cancel(); - mQueuedTask = nullptr; - CancelTimeoutTask(aProofOfLock); - } -} - -void -TaskThrottler::CancelTimeoutTask(const MonitorAutoLock& aProofOfLock) -{ - if (mTimeoutTask) { - mTimeoutTask->Cancel(); - mTimeoutTask = nullptr; // the MessageLoop will destroy it - } -} - -TimeDuration -TaskThrottler::TimeSinceLastRequest(const TimeStamp& aTimeStamp) -{ - MonitorAutoLock lock(mMonitor); - return TimeSinceLastRequest(aTimeStamp, lock); -} - -TimeDuration -TaskThrottler::TimeSinceLastRequest(const TimeStamp& aTimeStamp, - const MonitorAutoLock& aProofOfLock) -{ - return aTimeStamp - mStartTime; -} - -void -TaskThrottler::ClearHistory() -{ - MonitorAutoLock lock(mMonitor); - - mMean.clear(); -} - -void -TaskThrottler::SetMaxDurations(uint32_t aMaxDurations) -{ - MonitorAutoLock lock(mMonitor); - - if (aMaxDurations != mMean.maxValues()) { - mMean = RollingMean(aMaxDurations); - } -} - -} // namespace layers -} // namespace mozilla diff --git a/gfx/layers/apz/src/TaskThrottler.h b/gfx/layers/apz/src/TaskThrottler.h deleted file mode 100644 index 50a799bb6ab2..000000000000 --- a/gfx/layers/apz/src/TaskThrottler.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 2; -*- */ -/* vim: set sw=4 ts=8 et tw=80 : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_TaskThrottler_h -#define mozilla_dom_TaskThrottler_h - -#include // for uint32_t -#include "base/task.h" // for CancelableTask -#include "mozilla/Monitor.h" // for Monitor -#include "mozilla/mozalloc.h" // for operator delete -#include "mozilla/RollingMean.h" // for RollingMean -#include "mozilla/TimeStamp.h" // for TimeDuration, TimeStamp -#include "mozilla/UniquePtr.h" // for UniquePtr -#include "nsCOMPtr.h" // for nsCOMPtr -#include "nsISupportsImpl.h" // for NS_INLINE_DECL_THREADSAFE_REFCOUNTING -#include "nsTArray.h" // for nsTArray - -namespace tracked_objects { -class Location; -} // namespace tracked_objects - -namespace mozilla { -namespace layers { - -/** The TaskThrottler prevents update event overruns. It is used in cases where - * you're sending an async message and waiting for a reply. You need to call - * PostTask to queue a task and TaskComplete when you get a response. - * - * The call to TaskComplete will run the most recent task posted since the last - * request was sent, if any. This means that at any time there can be at most 1 - * outstanding request being processed and at most 1 queued behind it. - * - * However, to guard against task runs that error out and fail to call TaskComplete, - * the TaskThrottler also has a max-wait timeout. If the caller requests a new - * task be posted, and it has been greater than the max-wait timeout since the - * last one was sent, then we send the new one regardless of whether or not the - * last one was marked as completed. - * - * This is used in the context of repainting a scrollable region. While another - * process is painting you might get several updates from the UI thread but when - * the paint is complete you want to send the most recent. - */ - -class TaskThrottler { -public: - TaskThrottler(const TimeStamp& aTimeStamp, const TimeDuration& aMaxWait); - - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TaskThrottler) - - /** Post a task to be run as soon as there are no outstanding tasks, or - * post it immediately if it has been more than the max-wait time since - * the last task was posted. - * - * @param aLocation Use the macro FROM_HERE - * @param aTask Ownership of this object is transferred to TaskThrottler - * which will delete it when it is either run or becomes - * obsolete or the TaskThrottler is destructed. - */ - void PostTask(const tracked_objects::Location& aLocation, - UniquePtr aTask, const TimeStamp& aTimeStamp); - /** - * Mark the task as complete and process the next queued task. - */ - void TaskComplete(const TimeStamp& aTimeStamp); - - /** - * Calculate the average time between processing the posted task and getting - * the TaskComplete() call back. - */ - TimeDuration AverageDuration(); - - /** - * Cancel the queued task if there is one. - */ - void CancelPendingTask(); - - /** - * Return the time elapsed since the last request was processed - */ - TimeDuration TimeSinceLastRequest(const TimeStamp& aTimeStamp); - - /** - * Clear average history. - */ - void ClearHistory(); - - /** - * @param aMaxDurations The maximum number of durations to measure. - */ - - void SetMaxDurations(uint32_t aMaxDurations); - -private: - mutable Monitor mMonitor; - bool mOutstanding; - UniquePtr mQueuedTask; - TimeStamp mStartTime; - TimeDuration mMaxWait; - RollingMean mMean; - CancelableTask* mTimeoutTask; // not owned because it's posted to a MessageLoop - // which deletes it - - ~TaskThrottler(); - void RunQueuedTask(const TimeStamp& aTimeStamp, - const MonitorAutoLock& aProofOfLock); - void CancelPendingTask(const MonitorAutoLock& aProofOfLock); - TimeDuration TimeSinceLastRequest(const TimeStamp& aTimeStamp, - const MonitorAutoLock& aProofOfLock); - void OnTimeout(); - void CancelTimeoutTask(const MonitorAutoLock& aProofOfLock); -}; - -} // namespace layers -} // namespace mozilla - -#endif // mozilla_dom_TaskThrottler_h diff --git a/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp b/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp index 39491bd379ae..602dccc7587f 100644 --- a/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp @@ -154,8 +154,7 @@ public: protected: AsyncPanZoomController* NewAPZCInstance(uint64_t aLayersId, - GeckoContentController* aController, - TaskThrottler* aPaintThrottler) override; + GeckoContentController* aController) override; TimeStamp GetFrameTime() override { return mcc->Time(); @@ -169,10 +168,9 @@ class TestAsyncPanZoomController : public AsyncPanZoomController { public: TestAsyncPanZoomController(uint64_t aLayersId, MockContentControllerDelayed* aMcc, TestAPZCTreeManager* aTreeManager, - TaskThrottler* aPaintThrottler, GestureBehavior aBehavior = DEFAULT_GESTURES) : AsyncPanZoomController(aLayersId, aTreeManager, aTreeManager->GetInputQueue(), - aMcc, aPaintThrottler, aBehavior) + aMcc, aBehavior) , mWaitForMainThread(false) , mcc(aMcc) {} @@ -261,11 +259,10 @@ private: AsyncPanZoomController* TestAPZCTreeManager::NewAPZCInstance(uint64_t aLayersId, - GeckoContentController* aController, - TaskThrottler* aPaintThrottler) + GeckoContentController* aController) { MockContentControllerDelayed* mcc = static_cast(aController); - return new TestAsyncPanZoomController(aLayersId, mcc, this, aPaintThrottler, + return new TestAsyncPanZoomController(aLayersId, mcc, this, AsyncPanZoomController::USE_GESTURE_DETECTOR); } @@ -297,9 +294,8 @@ protected: APZThreadUtils::SetControllerThread(MessageLoop::current()); mcc = new NiceMock(); - mPaintThrottler = new TaskThrottler(mcc->Time(), TimeDuration::FromMilliseconds(500)); tm = new TestAPZCTreeManager(mcc); - apzc = new TestAsyncPanZoomController(0, mcc, tm, mPaintThrottler, mGestureBehavior); + apzc = new TestAsyncPanZoomController(0, mcc, tm, mGestureBehavior); apzc->SetFrameMetrics(TestFrameMetrics()); } @@ -382,7 +378,6 @@ protected: AsyncPanZoomController::GestureBehavior mGestureBehavior; RefPtr mcc; - RefPtr mPaintThrottler; RefPtr tm; RefPtr apzc; }; @@ -1142,7 +1137,7 @@ TEST_F(APZCBasicTester, ComplexTransform) { // sides. RefPtr childApzc = - new TestAsyncPanZoomController(0, mcc, tm, mPaintThrottler); + new TestAsyncPanZoomController(0, mcc, tm); const char* layerTreeSyntax = "c(c)"; // LayerID 0 1 @@ -3493,89 +3488,3 @@ public: private: TaskRunMetrics& mMetrics; }; - -class APZTaskThrottlerTester : public ::testing::Test { -public: - APZTaskThrottlerTester() - { - now = TimeStamp::Now(); - throttler = new TaskThrottler(now, TimeDuration::FromMilliseconds(100)); - } - -protected: - TimeStamp Advance(int aMillis = 5) - { - now = now + TimeDuration::FromMilliseconds(aMillis); - return now; - } - - UniquePtr NewTask() - { - return MakeUnique(metrics); - } - - TimeStamp now; - RefPtr throttler; - TaskRunMetrics metrics; -}; - -TEST_F(APZTaskThrottlerTester, BasicTest) { - // Check that posting the first task runs right away - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 1 - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - - // Check that posting the second task doesn't run until the first one is done - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 2 - EXPECT_EQ(0, metrics.GetAndClearRunCount()); - throttler->TaskComplete(Advance()); // for task 1 - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - EXPECT_EQ(0, metrics.GetAndClearCancelCount()); - - // Check that tasks are coalesced: dispatch 5 tasks - // while there is still one outstanding, and ensure - // that only one of the 5 runs - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 3 - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 4 - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 5 - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 6 - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 7 - EXPECT_EQ(0, metrics.GetAndClearRunCount()); - EXPECT_EQ(4, metrics.GetAndClearCancelCount()); - - throttler->TaskComplete(Advance()); // for task 2 - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - throttler->TaskComplete(Advance()); // for task 7 (tasks 3..6 were cancelled) - EXPECT_EQ(0, metrics.GetAndClearRunCount()); - EXPECT_EQ(0, metrics.GetAndClearCancelCount()); -} - -TEST_F(APZTaskThrottlerTester, TimeoutTest) { - // Check that posting the first task runs right away - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 1 - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - - // Because we let 100ms pass, the second task should - // run immediately even though the first one isn't - // done yet - throttler->PostTask(FROM_HERE, NewTask(), Advance(100)); // task 2; task 1 is assumed lost - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - throttler->TaskComplete(Advance()); // for task 1, but TaskThrottler thinks it's for task 2 - throttler->TaskComplete(Advance()); // for task 2, TaskThrottler ignores it - EXPECT_EQ(0, metrics.GetAndClearRunCount()); - EXPECT_EQ(0, metrics.GetAndClearCancelCount()); - - // This time queue up a few tasks before the timeout expires - // and ensure cancellation still works as expected - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 3 - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 4 - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 5 - throttler->PostTask(FROM_HERE, NewTask(), Advance()); // task 6 - EXPECT_EQ(0, metrics.GetAndClearRunCount()); - throttler->PostTask(FROM_HERE, NewTask(), Advance(100)); // task 7; task 3 is assumed lost - EXPECT_EQ(1, metrics.GetAndClearRunCount()); - EXPECT_EQ(3, metrics.GetAndClearCancelCount()); // tasks 4..6 should have been cancelled - throttler->TaskComplete(Advance()); // for task 7 - EXPECT_EQ(0, metrics.GetAndClearRunCount()); - EXPECT_EQ(0, metrics.GetAndClearCancelCount()); -} diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index a6b0809d7081..484ba4e48e90 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -1546,10 +1546,6 @@ CompositorParent::RecvNotifyChildCreated(const uint64_t& child) void CompositorParent::NotifyChildCreated(const uint64_t& aChild) { - if (mApzcTreeManager) { - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg( - mApzcTreeManager, &APZCTreeManager::InitializeForLayersId, aChild)); - } sIndirectLayerTreesLock->AssertCurrentThreadOwns(); sIndirectLayerTrees[aChild].mParent = this; sIndirectLayerTrees[aChild].mLayerManager = mLayerManager; @@ -1559,9 +1555,6 @@ bool CompositorParent::RecvAdoptChild(const uint64_t& child) { MonitorAutoLock lock(*sIndirectLayerTreesLock); - if (mApzcTreeManager) { - mApzcTreeManager->AdoptLayersId(child, sIndirectLayerTrees[child].mParent->mApzcTreeManager.get()); - } NotifyChildCreated(child); if (sIndirectLayerTrees[child].mLayerTree) { sIndirectLayerTrees[child].mLayerTree->mLayerManager = mLayerManager; @@ -1633,7 +1626,6 @@ ScopedLayerTreeRegistration::ScopedLayerTreeRegistration(APZCTreeManager* aApzct : mLayersId(aLayersId) { EnsureLayerTreeMapReady(); - aApzctm->InitializeForLayersId(aLayersId); MonitorAutoLock lock(*sIndirectLayerTreesLock); sIndirectLayerTrees[aLayersId].mRoot = aRoot; sIndirectLayerTrees[aLayersId].mController = aController; @@ -1649,9 +1641,6 @@ ScopedLayerTreeRegistration::~ScopedLayerTreeRegistration() CompositorParent::SetControllerForLayerTree(uint64_t aLayersId, GeckoContentController* aController) { - if (APZCTreeManager* apzctm = GetAPZCTreeManager(aLayersId)) { - apzctm->InitializeForLayersId(aLayersId); - } // This ref is adopted by UpdateControllerForLayersId(). aController->AddRef(); CompositorLoop()->PostTask(FROM_HERE, diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 93efe2d97044..9858f53ea9a0 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -249,7 +249,6 @@ UNIFIED_SOURCES += [ 'apz/src/InputBlockState.cpp', 'apz/src/InputQueue.cpp', 'apz/src/OverscrollHandoffState.cpp', - 'apz/src/TaskThrottler.cpp', 'apz/src/TouchCounter.cpp', 'apz/src/WheelScrollAnimation.cpp', 'apz/testutil/APZTestData.cpp',