Bug 965871 - Document lock ordering in APZ. r=kats

This commit is contained in:
Botond Ballo 2014-03-10 15:55:44 -04:00
parent 066636cb79
commit ed721375c9
2 changed files with 19 additions and 1 deletions

View File

@ -41,6 +41,22 @@ class Layer;
class AsyncPanZoomController;
class CompositorParent;
/**
* ****************** NOTE ON LOCK ORDERING IN APZ **************************
*
* There are two kinds of locks used by APZ: APZCTreeManager::mTreeLock
* ("the tree lock") and AsyncPanZoomController::mMonitor ("APZC locks").
*
* To avoid deadlock, we impose a lock ordering between these locks, which is:
*
* tree lock -> APZC locks
*
* The interpretation of the lock ordering is that if lock A precedes lock B
* in the ordering sequence, then you must NOT wait on A while holding B.
*
* **************************************************************************
*/
/**
* This class manages the tree of AsyncPanZoomController instances. There is one
* instance of this class owned by each CompositorParent, and it contains as
@ -303,7 +319,8 @@ private:
* This lock does not need to be held while manipulating a single APZC instance in
* isolation (that is, if its tree pointers are not being accessed or mutated). The
* lock also needs to be held when accessing the mRootApzc instance variable, as that
* is considered part of the APZC tree management state. */
* is considered part of the APZC tree management state.
* IMPORTANT: See the note about lock ordering at the top of this file. */
mozilla::Monitor mTreeLock;
nsRefPtr<AsyncPanZoomController> mRootApzc;
/* This tracks the APZC that should receive all inputs for the current input event block.

View File

@ -650,6 +650,7 @@ protected:
// Before manipulating |mFrameMetrics| or |mLastContentPaintMetrics|, the
// monitor should be held. When setting |mState|, either the SetState()
// function can be used, or the monitor can be held and then |mState| updated.
// IMPORTANT: See the note about lock ordering at the top of APZCTreeManager.h.
ReentrantMonitor mMonitor;
// Specifies whether we should use touch-action css property. Initialized from