Bug 1378966 - Don't cause immediate throttling of the refresh driver on repeat transactions. r?mattwoodrow
MozReview-Commit-ID: 8orAmdpIRTF
--- a/gfx/layers/TransactionIdAllocator.h
+++ b/gfx/layers/TransactionIdAllocator.h
@@ -19,19 +19,21 @@ protected:
public:
NS_INLINE_DECL_REFCOUNTING(TransactionIdAllocator)
/**
* Allocate a unique id number for the current refresh tick, can
* only be called while IsInRefresh().
*
* If too many id's are allocated without being returned then
- * the refresh driver will suspend until they catch up.
+ * the refresh driver will suspend until they catch up. This
+ * "throttling" behaviour can be skipped by passing aThrottle=false.
+ * Otherwise call sites should generally be passing aThrottle=true.
*/
- virtual uint64_t GetTransactionId() = 0;
+ virtual uint64_t GetTransactionId(bool aThrottle) = 0;
/**
* Return the transaction id that for the last non-revoked transaction.
* This allows the caller to tell whether a composite was triggered by
* a paint that occurred after a call to TransactionId().
*/
virtual uint64_t LastTransactionId() const = 0;
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -721,17 +721,17 @@ ClientLayerManager::ForwardTransaction(b
if (mForwarder->GetSyncObject() &&
mForwarder->GetSyncObject()->IsSyncObjectValid()) {
mForwarder->GetSyncObject()->FinalizeFrame();
}
}
mPhase = PHASE_FORWARD;
- mLatestTransactionId = mTransactionIdAllocator->GetTransactionId();
+ mLatestTransactionId = mTransactionIdAllocator->GetTransactionId(!mIsRepeatTransaction);
TimeStamp transactionStart;
if (!mTransactionIdAllocator->GetTransactionStart().IsNull()) {
transactionStart = mTransactionIdAllocator->GetTransactionStart();
} else {
transactionStart = mTransactionStart;
}
if (gfxPrefs::AlwaysPaint() && XRE_IsContentProcess()) {
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -431,17 +431,17 @@ WebRenderLayerManager::EndTransactionInt
}
scrollData.SetPaintSequenceNumber(mPaintSequenceNumber);
if (mRoot) {
PopulateScrollData(scrollData, mRoot.get());
}
}
bool sync = mTarget != nullptr;
- mLatestTransactionId = mTransactionIdAllocator->GetTransactionId();
+ mLatestTransactionId = mTransactionIdAllocator->GetTransactionId(/*aThrottle*/ true);
{
AutoProfilerTracing
tracing("Paint", sync ? "ForwardDPTransactionSync":"ForwardDPTransaction");
WrBridge()->DPEnd(builder, size.ToUnknownSize(), sync, mLatestTransactionId, scrollData);
}
MakeSnapshotIfRequired(size);
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -2156,21 +2156,22 @@ nsRefreshDriver::FinishedWaitingForTrans
AutoProfilerTracing tracing("Paint", "RefreshDriverTick");
DoRefresh();
}
mSkippedPaints = false;
mWarningThreshold = 1;
}
uint64_t
-nsRefreshDriver::GetTransactionId()
+nsRefreshDriver::GetTransactionId(bool aThrottle)
{
++mPendingTransaction;
- if (mPendingTransaction >= mCompletedTransaction + 2 &&
+ if (aThrottle &&
+ mPendingTransaction >= mCompletedTransaction + 2 &&
!mWaitingForTransaction &&
!mTestControllingRefreshes) {
mWaitingForTransaction = true;
mSkippedPaints = false;
mWarningThreshold = 1;
}
return mPendingTransaction;
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -312,17 +312,17 @@ public:
* time.
*
* Return `false` if `aJank` needs to be grown to accomodate the
* data but we didn't have enough memory.
*/
static bool GetJankLevels(mozilla::Vector<uint64_t>& aJank);
// mozilla::layers::TransactionIdAllocator
- uint64_t GetTransactionId() override;
+ uint64_t GetTransactionId(bool aThrottle) override;
uint64_t LastTransactionId() const override;
void NotifyTransactionCompleted(uint64_t aTransactionId) override;
void RevokeTransactionId(uint64_t aTransactionId) override;
void ClearPendingTransactions() override;
void ResetInitialTransactionId(uint64_t aTransactionId) override;
mozilla::TimeStamp GetTransactionStart() override;
bool IsWaitingForPaint(mozilla::TimeStamp aTime);