зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1712165 - Reorder conditions to avoid a possible race between the InitFontList thread and main thread accessing gfxPlatformFontList. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D115690
This commit is contained in:
Родитель
ca8345555c
Коммит
c840efe013
|
@ -464,7 +464,7 @@ bool gfxPlatformFontList::InitFontList() {
|
||||||
LOG_FONTINIT(("(fontinit) system fontlist initialization\n"));
|
LOG_FONTINIT(("(fontinit) system fontlist initialization\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFontlistInitCount) {
|
if (IsInitialized()) {
|
||||||
// Font-list reinitialization always occurs on the main thread, in response
|
// Font-list reinitialization always occurs on the main thread, in response
|
||||||
// to a change notification; it's only the initial creation during startup
|
// to a change notification; it's only the initial creation during startup
|
||||||
// that may be on another thread.
|
// that may be on another thread.
|
||||||
|
|
|
@ -170,12 +170,14 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
||||||
typedef nsTArray<FontFamily> PrefFontList;
|
typedef nsTArray<FontFamily> PrefFontList;
|
||||||
|
|
||||||
static gfxPlatformFontList* PlatformFontList() {
|
static gfxPlatformFontList* PlatformFontList() {
|
||||||
if (sPlatformFontList->IsInitialized()) {
|
// If there is a font-list initialization thread, we need to let it run
|
||||||
return sPlatformFontList;
|
// to completion before the font list can be used for anything else.
|
||||||
}
|
|
||||||
// Currently, only macOS uses OMT font-list initialization; on other
|
|
||||||
// platforms we initialize it directly during gfxPlatform::Init().
|
|
||||||
if (sInitFontListThread) {
|
if (sInitFontListThread) {
|
||||||
|
// If we're currently on the initialization thread, just continue;
|
||||||
|
// otherwise wait for it to finish.
|
||||||
|
if (IsInitFontListThread()) {
|
||||||
|
return sPlatformFontList;
|
||||||
|
}
|
||||||
PR_JoinThread(sInitFontListThread);
|
PR_JoinThread(sInitFontListThread);
|
||||||
sInitFontListThread = nullptr;
|
sInitFontListThread = nullptr;
|
||||||
// If font-list initialization failed, the thread will have cleared
|
// If font-list initialization failed, the thread will have cleared
|
||||||
|
@ -185,8 +187,10 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
||||||
MOZ_CRASH("Could not initialize gfxPlatformFontList");
|
MOZ_CRASH("Could not initialize gfxPlatformFontList");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sPlatformFontList->InitFontList()) {
|
if (!sPlatformFontList->IsInitialized()) {
|
||||||
MOZ_CRASH("Could not initialize gfxPlatformFontList");
|
if (!sPlatformFontList->InitFontList()) {
|
||||||
|
MOZ_CRASH("Could not initialize gfxPlatformFontList");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sPlatformFontList;
|
return sPlatformFontList;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче