Bug 1892643. Allow checking for shutdown in the image decode pool after the decode pool has been cleared. r=gfx-reviewers,nical

Differential Revision: https://phabricator.services.mozilla.com/D208086
This commit is contained in:
Timothy Nikkel 2024-05-25 09:45:37 +00:00
Родитель 7d4a28101d
Коммит 0220614e37
3 изменённых файлов: 11 добавлений и 6 удалений

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

@ -245,8 +245,7 @@ void AnimationSurfaceProvider::Run() {
// release the thread as soon as possible. The animation may advance even
// during shutdown, which keeps us decoding, and thus blocking the decode
// pool during teardown.
if (!mDecoder || !continueDecoding ||
DecodePool::Singleton()->IsShuttingDown()) {
if (!mDecoder || !continueDecoding || DecodePool::IsShuttingDown()) {
return;
}
@ -282,8 +281,7 @@ void AnimationSurfaceProvider::Run() {
// animation may advance even during shutdown, which keeps us decoding, and
// thus blocking the decode pool during teardown.
MOZ_ASSERT(result == LexerResult(Yield::OUTPUT_AVAILABLE));
if (!checkForNewFrameAtYieldResult ||
DecodePool::Singleton()->IsShuttingDown()) {
if (!checkForNewFrameAtYieldResult || DecodePool::IsShuttingDown()) {
return;
}
}

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

@ -16,6 +16,7 @@
#include "mozilla/StaticPrefs_image.h"
#include "mozilla/TaskController.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/AppShutdown.h"
#include "nsCOMPtr.h"
#include "nsIObserverService.h"
#include "nsThreadManager.h"
@ -132,7 +133,13 @@ DecodePool::Observe(nsISupports*, const char* aTopic, const char16_t*) {
return NS_OK;
}
bool DecodePool::IsShuttingDown() const { return mShuttingDown; }
/* static */ bool DecodePool::IsShuttingDown() {
if (MOZ_UNLIKELY(!sSingleton)) {
return AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads);
}
return sSingleton->mShuttingDown;
}
class DecodingTask final : public Task {
public:

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

@ -56,7 +56,7 @@ class DecodePool final : public nsIObserver {
/// True if the DecodePool is being shutdown. This may only be called by
/// threads from the pool to check if they should keep working or not.
bool IsShuttingDown() const;
static bool IsShuttingDown();
/// Ask the DecodePool to run @aTask asynchronously and return immediately.
void AsyncRun(IDecodingTask* aTask);