Bug 1109283 - Handle failure of nsExpirationTracker::AddObject in the SurfaceCache. r=dholbert

This commit is contained in:
Seth Fowler 2014-12-10 02:53:47 -08:00
parent 73a6c54a83
commit 26c1415afc

View File

@ -12,6 +12,7 @@
#include <algorithm>
#include "mozilla/Attributes.h" // for MOZ_THIS_IN_INITIALIZER_LIST
#include "mozilla/DebugOnly.h"
#include "mozilla/Likely.h"
#include "mozilla/Move.h"
#include "mozilla/RefPtr.h"
#include "mozilla/StaticPtr.h"
@ -385,6 +386,8 @@ public:
MOZ_ASSERT(mLockedCost <= mMaxCost, "Locked more than we can hold?");
} else {
mCosts.InsertElementSorted(costEntry);
// This may fail during XPCOM shutdown, so we need to ensure the object is
// tracked before calling RemoveObject in StopTracking.
mExpirationTracker.AddObject(aSurface);
}
}
@ -401,7 +404,14 @@ public:
MOZ_ASSERT(!mCosts.Contains(costEntry),
"Shouldn't have a cost entry for a locked surface");
} else {
mExpirationTracker.RemoveObject(aSurface);
if (MOZ_LIKELY(aSurface->GetExpirationState()->IsTracked())) {
mExpirationTracker.RemoveObject(aSurface);
} else {
// Our call to AddObject must have failed in StartTracking; most likely
// we're in XPCOM shutdown right now.
NS_WARNING("Not expiration-tracking an unlocked surface!");
}
DebugOnly<bool> foundInCosts = mCosts.RemoveElementSorted(costEntry);
MOZ_ASSERT(foundInCosts, "Lost track of costs for this surface");
}