Bug 1669588 - Avoid data races accessing APZCTreeManager::mTestSampleTime. r=kats

This variable is set from the compositor thread, and read from both
the sampler thread (e.g. when sampling animations) and the
controller thread (e.g. during input block creation), so access to
it needs to be synchronized.

Differential Revision: https://phabricator.services.mozilla.com/D94471
This commit is contained in:
Botond Ballo 2020-10-22 19:27:14 +00:00
Родитель d980503d1e
Коммит bbfec388ad
2 изменённых файлов: 8 добавлений и 5 удалений

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

@ -267,7 +267,8 @@ class MOZ_RAII AutoFocusSequenceNumberSetter {
};
APZCTreeManager::APZCTreeManager(LayersId aRootLayersId)
: mInputQueue(new InputQueue()),
: mTestSampleTime(Nothing(), "APZCTreeManager::mTestSampleTime"),
mInputQueue(new InputQueue()),
mRootLayersId(aRootLayersId),
mSampler(nullptr),
mUpdater(nullptr),
@ -347,12 +348,14 @@ AsyncPanZoomController* APZCTreeManager::NewAPZCInstance(
}
void APZCTreeManager::SetTestSampleTime(const Maybe<TimeStamp>& aTime) {
mTestSampleTime = aTime;
auto testSampleTime = mTestSampleTime.Lock();
testSampleTime.ref() = aTime;
}
SampleTime APZCTreeManager::GetFrameTime() {
if (mTestSampleTime) {
return SampleTime::FromTest(*mTestSampleTime);
auto testSampleTime = mTestSampleTime.Lock();
if (testSampleTime.ref()) {
return SampleTime::FromTest(*testSampleTime.ref());
}
return SampleTime::FromNow();
}

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

@ -538,7 +538,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
void SetTestSampleTime(const Maybe<TimeStamp>& aTime);
private:
Maybe<TimeStamp> mTestSampleTime;
mutable DataMutex<Maybe<TimeStamp>> mTestSampleTime;
public:
// Represents the results of an APZ hit test.