mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1441498 - Protect mCompositorVsyncDispatcher by lock. r=kats
mCompositorVsyncDispatcher is created and destroyed on main thread. But it is accessed from Compositor thread or VSyncBridge thread. To avoid race condition between main thread and Compositor thread/VSyncBridge thread, mCompositorVsyncDispatcher needs to be protected by lock.
This commit is contained in:
parent
21ccca19a4
commit
5e1a7f84b4
@ -263,6 +263,9 @@ void nsBaseWidget::DestroyCompositor()
|
||||
// trigger a paint, creating a new compositor, and we don't want to re-use
|
||||
// the old vsync dispatcher.
|
||||
if (mCompositorVsyncDispatcher) {
|
||||
MOZ_ASSERT(mCompositorVsyncDispatcherLock.get());
|
||||
|
||||
MutexAutoLock lock(*mCompositorVsyncDispatcherLock.get());
|
||||
mCompositorVsyncDispatcher->Shutdown();
|
||||
mCompositorVsyncDispatcher = nullptr;
|
||||
}
|
||||
@ -1267,6 +1270,10 @@ void nsBaseWidget::CreateCompositorVsyncDispatcher()
|
||||
// child process communicate via IPC
|
||||
// Should be called AFTER gfxPlatform is initialized
|
||||
if (XRE_IsParentProcess()) {
|
||||
if (!mCompositorVsyncDispatcherLock) {
|
||||
mCompositorVsyncDispatcherLock = MakeUnique<Mutex>("mCompositorVsyncDispatcherLock");
|
||||
}
|
||||
MutexAutoLock lock(*mCompositorVsyncDispatcherLock.get());
|
||||
mCompositorVsyncDispatcher = new CompositorVsyncDispatcher();
|
||||
}
|
||||
}
|
||||
@ -1274,6 +1281,9 @@ void nsBaseWidget::CreateCompositorVsyncDispatcher()
|
||||
already_AddRefed<CompositorVsyncDispatcher>
|
||||
nsBaseWidget::GetCompositorVsyncDispatcher()
|
||||
{
|
||||
MOZ_ASSERT(mCompositorVsyncDispatcherLock.get());
|
||||
|
||||
MutexAutoLock lock(*mCompositorVsyncDispatcherLock.get());
|
||||
RefPtr<CompositorVsyncDispatcher> dispatcher = mCompositorVsyncDispatcher;
|
||||
return dispatcher.forget();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "InputData.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
@ -679,7 +680,10 @@ protected:
|
||||
RefPtr<LayerManager> mLayerManager;
|
||||
RefPtr<CompositorSession> mCompositorSession;
|
||||
RefPtr<CompositorBridgeChild> mCompositorBridgeChild;
|
||||
|
||||
mozilla::UniquePtr<mozilla::Mutex> mCompositorVsyncDispatcherLock;
|
||||
RefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
|
||||
|
||||
RefPtr<IAPZCTreeManager> mAPZC;
|
||||
RefPtr<GeckoContentController> mRootContentController;
|
||||
RefPtr<APZEventState> mAPZEventState;
|
||||
|
Loading…
Reference in New Issue
Block a user