From ba272367cd51854e76d9a085f43acccd012948c5 Mon Sep 17 00:00:00 2001 From: Csoregi Natalia Date: Thu, 13 May 2021 12:26:03 +0300 Subject: [PATCH] Backed out changeset 80c9125cfac0 (bug 1704812) for assertion failures on gfxPlatformFontList.cpp. CLOSED TREE --- dom/ipc/ContentChild.cpp | 8 ----- dom/ipc/ContentChild.h | 3 -- dom/ipc/ContentParent.cpp | 15 --------- dom/ipc/ContentParent.h | 1 - dom/ipc/PContent.ipdl | 7 ---- gfx/thebes/SharedFontList-impl.h | 5 --- gfx/thebes/SharedFontList.cpp | 54 ------------------------------ gfx/thebes/gfxPlatformFontList.cpp | 13 ------- gfx/thebes/gfxPlatformFontList.h | 6 ---- 9 files changed, 112 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index c24fbbe57f57..f64edba9ab5a 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -2357,14 +2357,6 @@ mozilla::ipc::IPCResult ContentChild::RecvRebuildFontList( return IPC_OK(); } -mozilla::ipc::IPCResult ContentChild::RecvFontListShmBlockAdded( - const uint32_t& aGeneration, const uint32_t& aIndex, - const base::SharedMemoryHandle& aHandle) { - gfxPlatformFontList::PlatformFontList()->ShmBlockAdded(aGeneration, aIndex, - aHandle); - return IPC_OK(); -} - mozilla::ipc::IPCResult ContentChild::RecvUpdateAppLocales( nsTArray&& aAppLocales) { LocaleService::GetInstance()->AssignAppLocales(aAppLocales); diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index f63c9d325da2..0db6d33061cb 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -352,9 +352,6 @@ class ContentChild final : public PContentChild, mozilla::ipc::IPCResult RecvUpdateFontList(SystemFontList&&); mozilla::ipc::IPCResult RecvRebuildFontList(const bool& aFullRebuild); - mozilla::ipc::IPCResult RecvFontListShmBlockAdded( - const uint32_t& aGeneration, const uint32_t& aIndex, - const base::SharedMemoryHandle& aHandle); mozilla::ipc::IPCResult RecvUpdateAppLocales( nsTArray&& aAppLocales); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 1a8373bb6a28..78d699105cff 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1632,21 +1632,6 @@ void ContentParent::BroadcastFontListChanged() { } } -void ContentParent::BroadcastShmBlockAdded(uint32_t aGeneration, - uint32_t aIndex) { - auto* pfl = gfxPlatformFontList::PlatformFontList(); - for (auto* cp : AllProcesses(eLive)) { - base::SharedMemoryHandle handle = - pfl->ShareShmBlockToProcess(aIndex, cp->Pid()); - if (handle == base::SharedMemory::NULLHandle()) { - // If something went wrong here, we just skip it; the child will need to - // request the block as needed, at some performance cost. - continue; - } - Unused << cp->SendFontListShmBlockAdded(aGeneration, aIndex, handle); - } -} - void ContentParent::BroadcastThemeUpdate(widget::ThemeChangeKind aKind) { const FullLookAndFeel& lnf = *RemoteLookAndFeel::ExtractData(); for (auto* cp : AllProcesses(eLive)) { diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 90e076160cb9..c232253cd63e 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -259,7 +259,6 @@ class ContentParent final static void BroadcastStringBundle(const StringBundleDescriptor&); static void BroadcastFontListChanged(); - static void BroadcastShmBlockAdded(uint32_t aGeneration, uint32_t aIndex); static void BroadcastThemeUpdate(widget::ThemeChangeKind); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 6d2873b423cc..7e4c3667f480 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -635,13 +635,6 @@ child: */ async FontListChanged(); - /** - * A new shmem block has been added to the font list; the child process - * should map the new block and add to its index. - */ - async FontListShmBlockAdded(uint32_t aGeneration, uint32_t aIndex, - SharedMemoryHandle aHandle); - async UpdateAppLocales(nsCString[] appLocales); async UpdateRequestedLocales(nsCString[] requestedLocales); diff --git a/gfx/thebes/SharedFontList-impl.h b/gfx/thebes/SharedFontList-impl.h index 360ac253b918..a9d4f87778e2 100644 --- a/gfx/thebes/SharedFontList-impl.h +++ b/gfx/thebes/SharedFontList-impl.h @@ -266,11 +266,6 @@ class FontList { void ShareBlocksToProcess(nsTArray* aBlocks, base::ProcessId aPid); - base::SharedMemoryHandle ShareBlockToProcess(uint32_t aIndex, - base::ProcessId aPid); - - void ShmBlockAdded(uint32_t aGeneration, uint32_t aIndex, - base::SharedMemoryHandle aHandle); /** * Support for memory reporter. */ diff --git a/gfx/thebes/SharedFontList.cpp b/gfx/thebes/SharedFontList.cpp index 103871f4d1cf..7cd35aa946a3 100644 --- a/gfx/thebes/SharedFontList.cpp +++ b/gfx/thebes/SharedFontList.cpp @@ -9,7 +9,6 @@ #include "nsReadableUtils.h" #include "prerror.h" #include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/ContentParent.h" #include "mozilla/Logging.h" #define LOG_FONTLIST(args) \ @@ -626,48 +625,9 @@ bool FontList::AppendShmBlock(uint32_t aSizeNeeded) { mReadOnlyShmems.AppendElement(std::move(readOnly)); - dom::ContentParent::BroadcastShmBlockAdded(GetGeneration(), - mBlocks.Length() - 1); - return true; } -void FontList::ShmBlockAdded(uint32_t aGeneration, uint32_t aIndex, - base::SharedMemoryHandle aHandle) { - MOZ_ASSERT(!XRE_IsParentProcess()); - MOZ_ASSERT(mBlocks.Length() > 0); - - auto newShm = MakeUnique(); - if (!newShm->IsHandleValid(aHandle)) { - return; - } - if (!newShm->SetHandle(aHandle, true)) { - MOZ_CRASH("failed to set shm handle"); - } - - if (aIndex != mBlocks.Length()) { - return; - } - if (aGeneration != GetGeneration()) { - return; - } - - if (!newShm->Map(SHM_BLOCK_SIZE) || !newShm->memory()) { - MOZ_CRASH("failed to map shared memory"); - } - - uint32_t size = static_cast(newShm->memory())->mBlockSize; - MOZ_ASSERT(size >= SHM_BLOCK_SIZE); - if (size != SHM_BLOCK_SIZE) { - newShm->Unmap(); - if (!newShm->Map(size) || !newShm->memory()) { - MOZ_CRASH("failed to map shared memory"); - } - } - - mBlocks.AppendElement(new ShmBlock(std::move(newShm))); -} - void FontList::DetachShmBlocks() { for (auto& i : mBlocks) { i->mShmem = nullptr; @@ -736,20 +696,6 @@ void FontList::ShareBlocksToProcess(nsTArray* aBlocks, } } -base::SharedMemoryHandle FontList::ShareBlockToProcess(uint32_t aIndex, - base::ProcessId aPid) { - MOZ_RELEASE_ASSERT(XRE_IsParentProcess()); - MOZ_RELEASE_ASSERT(mReadOnlyShmems.Length() == mBlocks.Length()); - MOZ_RELEASE_ASSERT(aIndex < mReadOnlyShmems.Length()); - - base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle(); - if (mReadOnlyShmems[aIndex]->ShareToProcess(aPid, &handle)) { - return handle; - } - - return base::SharedMemory::NULLHandle(); -} - Pointer FontList::Alloc(uint32_t aSize) { // Only the parent process does allocation. MOZ_ASSERT(XRE_IsParentProcess()); diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 28e0c5058721..ee045901633f 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -2657,19 +2657,6 @@ void gfxPlatformFontList::ShareFontListToProcess( } } -base::SharedMemoryHandle gfxPlatformFontList::ShareShmBlockToProcess( - uint32_t aIndex, base::ProcessId aPid) { - MOZ_RELEASE_ASSERT(SharedFontList()); - return SharedFontList()->ShareBlockToProcess(aIndex, aPid); -} - -void gfxPlatformFontList::ShmBlockAdded(uint32_t aGeneration, uint32_t aIndex, - base::SharedMemoryHandle aHandle) { - if (SharedFontList()) { - SharedFontList()->ShmBlockAdded(aGeneration, aIndex, aHandle); - } -} - void gfxPlatformFontList::InitializeFamily(uint32_t aGeneration, uint32_t aFamilyIndex, bool aLoadCmaps) { diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index a3375a3bdb86..70f8e45a99cf 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -277,12 +277,6 @@ class gfxPlatformFontList : public gfxFontInfoLoader { void ShareFontListToProcess(nsTArray* aBlocks, base::ProcessId aPid); - void ShmBlockAdded(uint32_t aGeneration, uint32_t aIndex, - base::SharedMemoryHandle aHandle); - - base::SharedMemoryHandle ShareShmBlockToProcess(uint32_t aIndex, - base::ProcessId aPid); - void SetCharacterMap(uint32_t aGeneration, const mozilla::fontlist::Pointer& aFacePtr, const gfxSparseBitSet& aMap);