Bug 1434996 - Update WebRenderLayerManager::SetTransactionIdAllocator to match ClientLayerManager. r=sotaro

Changing the transaction id allocator is now handled better in
ClientLayerManager than before in that it resets the transaction id on
the new allocator to match the old allocator and avoid discontinuities
in the transaction ids. We should apply this behaviour to
WebRenderLayerManager as well, because WebRenderLayerManager was
assuming that any time the allocator changed it would automatically
start the transaction id at 1, which is not the case. In particular,
when navigating to something in the bfcache, we can reuse a pre-existing
refresh driver which might have a transaction id already greater than 1.

MozReview-Commit-ID: 8IUn1Dhnh7c

--HG--
extra : rebase_source : 0e98c96d9636c3a3ee0489ff6b6161bce7677dd7
This commit is contained in:
Kartikaya Gupta 2018-02-09 13:41:18 -05:00
Родитель 6782014750
Коммит 3df53735f9
4 изменённых файлов: 26 добавлений и 11 удалений

Просмотреть файл

@ -1264,14 +1264,7 @@ WebRenderBridgeParent::HoldPendingTransactionId(uint32_t aWrEpoch,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime)
{
// The transaction ID might get reset to 1 if the page gets reloaded, see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1145295#c41
// Otherwise, it should be continually increasing.
MOZ_ASSERT(aTransactionId == 1 || aTransactionId > LastPendingTransactionId());
// Handle TransactionIdAllocator(RefreshDriver) change.
if (aTransactionId == 1) {
FlushPendingTransactionIds();
}
MOZ_ASSERT(aTransactionId > LastPendingTransactionId());
mPendingTransactionIds.push(PendingTransactionId(wr::NewEpoch(aWrEpoch), aTransactionId, aTxnStartTime, aFwdTime));
}

Просмотреть файл

@ -155,7 +155,10 @@ public:
void SendPendingAsyncMessages() override;
void SetAboutToSendAsyncMessages() override;
void HoldPendingTransactionId(uint32_t aWrEpoch, uint64_t aTransactionId, const TimeStamp& aTxnStartTime, const TimeStamp& aFwdTime);
void HoldPendingTransactionId(uint32_t aWrEpoch,
uint64_t aTransactionId,
const TimeStamp& aTxnStartTime,
const TimeStamp& aFwdTime);
uint64_t LastPendingTransactionId();
uint64_t FlushPendingTransactionIds();
uint64_t FlushTransactionIdsForEpoch(const wr::Epoch& aEpoch, const TimeStamp& aEndTime);

Просмотреть файл

@ -562,6 +562,26 @@ WebRenderLayerManager::GetTextureFactoryIdentifier()
return WrBridge()->GetTextureFactoryIdentifier();
}
void
WebRenderLayerManager::SetTransactionIdAllocator(TransactionIdAllocator* aAllocator)
{
// When changing the refresh driver, the previous refresh driver may never
// receive updates of pending transactions it's waiting for. So clear the
// waiting state before assigning another refresh driver.
if (mTransactionIdAllocator && (aAllocator != mTransactionIdAllocator)) {
mTransactionIdAllocator->ClearPendingTransactions();
// We should also reset the transaction id of the new allocator to previous
// allocator's last transaction id, so that completed transactions for
// previous allocator will be ignored and won't confuse the new allocator.
if (aAllocator) {
aAllocator->ResetInitialTransactionId(mTransactionIdAllocator->LastTransactionId());
}
}
mTransactionIdAllocator = aAllocator;
}
void
WebRenderLayerManager::AddDidCompositeObserver(DidCompositeObserver* aObserver)
{

Просмотреть файл

@ -99,8 +99,7 @@ public:
virtual void UpdateTextureFactoryIdentifier(const TextureFactoryIdentifier& aNewIdentifier) override;
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() override;
virtual void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) override
{ mTransactionIdAllocator = aAllocator; }
virtual void SetTransactionIdAllocator(TransactionIdAllocator* aAllocator) override;
virtual void AddDidCompositeObserver(DidCompositeObserver* aObserver) override;
virtual void RemoveDidCompositeObserver(DidCompositeObserver* aObserver) override;