forked from mirrors/gecko-dev
Bug 1797688 - Part 6: Substitute gXPCOMThreadsShutDown with InOrBeyond(XPCOMShutdownFinal) in SurfaceCacheImpl. r=xpcom-reviewers,mccr8
To release the images, `ClearReleasingImages` basically takes all the `RefPtr<Image>` out of `mReleasingImagesOnMainThread` under a lock and then clears them, all on the main thread. This can be safely done before as late as XPCOMShutdownFinal on the main thread in order to avoid leaks. Differential Revision: https://phabricator.services.mozilla.com/D160624
This commit is contained in:
parent
c9e6f9840c
commit
a71d351e3b
1 changed files with 4 additions and 2 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#include "gfx2DGlue.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "imgFrame.h"
|
||||
#include "mozilla/AppShutdown.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
|
|
@ -1398,7 +1399,8 @@ class SurfaceCacheImpl final : public nsIMemoryReporter {
|
|||
bool needsDispatch = mReleasingImagesOnMainThread.IsEmpty();
|
||||
mReleasingImagesOnMainThread.AppendElement(image);
|
||||
|
||||
if (!needsDispatch || gXPCOMThreadsShutDown) {
|
||||
if (!needsDispatch ||
|
||||
AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownFinal)) {
|
||||
// Either there is already a ongoing task for ClearReleasingImages() or
|
||||
// it's too late in shutdown to dispatch.
|
||||
return;
|
||||
|
|
@ -1933,7 +1935,7 @@ void SurfaceCache::ReleaseImageOnMainThread(
|
|||
|
||||
// Don't try to dispatch the release after shutdown, we'll just leak the
|
||||
// runnable.
|
||||
if (gXPCOMThreadsShutDown) {
|
||||
if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownFinal)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue