зеркало из https://github.com/mozilla/gecko-dev.git
Bug 854421 - Part 10: Resume the refresh driver if we miss too many ticks. r=vlad
This commit is contained in:
Родитель
58a93da0d3
Коммит
43d5066053
|
@ -696,7 +696,7 @@ nsRefreshDriver::nsRefreshDriver(nsPresContext* aPresContext)
|
||||||
mRequestedHighPrecision(false),
|
mRequestedHighPrecision(false),
|
||||||
mInRefresh(false),
|
mInRefresh(false),
|
||||||
mWaitingForTransaction(false),
|
mWaitingForTransaction(false),
|
||||||
mSkippedPaint(false)
|
mSkippedPaints(0)
|
||||||
{
|
{
|
||||||
mMostRecentRefreshEpochTime = JS_Now();
|
mMostRecentRefreshEpochTime = JS_Now();
|
||||||
mMostRecentRefresh = TimeStamp::Now();
|
mMostRecentRefresh = TimeStamp::Now();
|
||||||
|
@ -737,7 +737,7 @@ nsRefreshDriver::AdvanceTimeAndRefresh(int64_t aMilliseconds)
|
||||||
if (mWaitingForTransaction) {
|
if (mWaitingForTransaction) {
|
||||||
// Disable any refresh driver throttling when entering test mode
|
// Disable any refresh driver throttling when entering test mode
|
||||||
mWaitingForTransaction = false;
|
mWaitingForTransaction = false;
|
||||||
mSkippedPaint = false;
|
mSkippedPaints = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,7 +1080,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||||
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
||||||
mRootRefresh = nullptr;
|
mRootRefresh = nullptr;
|
||||||
}
|
}
|
||||||
mSkippedPaint = false;
|
mSkippedPaints = 0;
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
|
nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
|
||||||
if (!presShell || (ObserverCount() == 0 && ImageRequestCount() == 0)) {
|
if (!presShell || (ObserverCount() == 0 && ImageRequestCount() == 0)) {
|
||||||
|
@ -1385,12 +1385,12 @@ void
|
||||||
nsRefreshDriver::FinishedWaitingForTransaction()
|
nsRefreshDriver::FinishedWaitingForTransaction()
|
||||||
{
|
{
|
||||||
mWaitingForTransaction = false;
|
mWaitingForTransaction = false;
|
||||||
if (mSkippedPaint &&
|
if (mSkippedPaints &&
|
||||||
!IsInRefresh() &&
|
!IsInRefresh() &&
|
||||||
(ObserverCount() || ImageRequestCount())) {
|
(ObserverCount() || ImageRequestCount())) {
|
||||||
DoRefresh();
|
DoRefresh();
|
||||||
}
|
}
|
||||||
mSkippedPaint = false;
|
mSkippedPaints = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
|
@ -1402,7 +1402,7 @@ nsRefreshDriver::GetTransactionId()
|
||||||
!mWaitingForTransaction &&
|
!mWaitingForTransaction &&
|
||||||
!mTestControllingRefreshes) {
|
!mTestControllingRefreshes) {
|
||||||
mWaitingForTransaction = true;
|
mWaitingForTransaction = true;
|
||||||
mSkippedPaint = false;
|
mSkippedPaints = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mPendingTransaction;
|
return mPendingTransaction;
|
||||||
|
@ -1414,7 +1414,7 @@ nsRefreshDriver::RevokeTransactionId(uint64_t aTransactionId)
|
||||||
MOZ_ASSERT(aTransactionId == mPendingTransaction);
|
MOZ_ASSERT(aTransactionId == mPendingTransaction);
|
||||||
if (mPendingTransaction == mCompletedTransaction + 2 &&
|
if (mPendingTransaction == mCompletedTransaction + 2 &&
|
||||||
mWaitingForTransaction) {
|
mWaitingForTransaction) {
|
||||||
MOZ_ASSERT(!mSkippedPaint, "How did we skip a paint when we're in the middle of one?");
|
MOZ_ASSERT(!mSkippedPaints, "How did we skip a paint when we're in the middle of one?");
|
||||||
FinishedWaitingForTransaction();
|
FinishedWaitingForTransaction();
|
||||||
}
|
}
|
||||||
mPendingTransaction--;
|
mPendingTransaction--;
|
||||||
|
@ -1439,7 +1439,7 @@ nsRefreshDriver::WillRefresh(mozilla::TimeStamp aTime)
|
||||||
{
|
{
|
||||||
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
||||||
mRootRefresh = nullptr;
|
mRootRefresh = nullptr;
|
||||||
if (mSkippedPaint) {
|
if (mSkippedPaints) {
|
||||||
DoRefresh();
|
DoRefresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1450,8 +1450,20 @@ nsRefreshDriver::IsWaitingForPaint()
|
||||||
if (mTestControllingRefreshes) {
|
if (mTestControllingRefreshes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// If we've skipped too many ticks then it's possible
|
||||||
|
// that something went wrong and we're waiting on
|
||||||
|
// a notification that will never arrive.
|
||||||
|
static const uint32_t kMaxSkippedPaints = 10;
|
||||||
|
if (mSkippedPaints > kMaxSkippedPaints) {
|
||||||
|
mSkippedPaints = 0;
|
||||||
|
mWaitingForTransaction = false;
|
||||||
|
if (mRootRefresh) {
|
||||||
|
mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (mWaitingForTransaction) {
|
if (mWaitingForTransaction) {
|
||||||
mSkippedPaint = true;
|
mSkippedPaints++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1469,7 +1481,7 @@ nsRefreshDriver::IsWaitingForPaint()
|
||||||
rootRefresh->AddRefreshObserver(this, Flush_Style);
|
rootRefresh->AddRefreshObserver(this, Flush_Style);
|
||||||
mRootRefresh = rootRefresh;
|
mRootRefresh = rootRefresh;
|
||||||
}
|
}
|
||||||
mSkippedPaint = true;
|
mSkippedPaints++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ private:
|
||||||
// True if Tick() was skipped because of mWaitingForTransaction and
|
// True if Tick() was skipped because of mWaitingForTransaction and
|
||||||
// we should schedule a new Tick immediately when resumed instead
|
// we should schedule a new Tick immediately when resumed instead
|
||||||
// of waiting until the next interval.
|
// of waiting until the next interval.
|
||||||
bool mSkippedPaint;
|
uint32_t mSkippedPaints;
|
||||||
|
|
||||||
int64_t mMostRecentRefreshEpochTime;
|
int64_t mMostRecentRefreshEpochTime;
|
||||||
mozilla::TimeStamp mMostRecentRefresh;
|
mozilla::TimeStamp mMostRecentRefresh;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче