Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 6a95b49

Browse files
committed
Bug 1691475 - Remove shared surfaces on the compositor thread. r=jrmuizel, a=pascalc
We add a shared surface on the main thread to the shared surfaces table when in the compositor process because it uses a different wrapper object if the shared surface is in a different process. This structure was mirrored for the removal of a shared surface created in the compositor process, however that created a race between the main thread freeing the surface before the display list creation bound an image key to the shared surface's external image ID. As such, this patch makes removal always post to the compositor thread, whether in the compositor process or not. Differential Revision: https://phabricator.services.mozilla.com/D104426
1 parent b9943ff commit 6a95b49

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

gfx/layers/ipc/SharedSurfacesChild.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -416,20 +416,11 @@ void SharedSurfacesChild::Unshare(const wr::ExternalImageId& aId,
416416
return;
417417
}
418418

419-
if (manager->OtherPid() == base::GetCurrentProcId()) {
420-
// We are in the combined UI/GPU process. Call directly to it to remove its
421-
// wrapper surface to free the underlying buffer, but only if the external
422-
// image ID is owned by the manager. It can be different if the surface was
423-
// last shared with the GPU process, which crashed several times, and its
424-
// job was moved into the parent process.
425-
if (manager->OwnsExternalImageId(aId)) {
426-
SharedSurfacesParent::RemoveSameProcess(aId);
427-
}
428-
} else if (manager->OwnsExternalImageId(aId)) {
429-
// Only attempt to release current mappings in the GPU process. It is
430-
// possible we had a surface that was previously shared, the GPU process
431-
// crashed / was restarted, and then we freed the surface. In that case
432-
// we know the mapping has already been freed.
419+
if (manager->OwnsExternalImageId(aId)) {
420+
// Only attempt to release current mappings in the compositor process. It is
421+
// possible we had a surface that was previously shared, the compositor
422+
// process crashed / was restarted, and then we freed the surface. In that
423+
// case we know the mapping has already been freed.
433424
manager->SendRemoveSharedSurface(aId);
434425
}
435426
}

gfx/layers/ipc/SharedSurfacesParent.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,6 @@ void SharedSurfacesParent::AddSameProcess(const wr::ExternalImageId& aId,
144144
sInstance->mSurfaces.Put(id, std::move(surface));
145145
}
146146

147-
/* static */
148-
void SharedSurfacesParent::RemoveSameProcess(const wr::ExternalImageId& aId) {
149-
MOZ_ASSERT(XRE_IsParentProcess());
150-
MOZ_ASSERT(NS_IsMainThread());
151-
Release(aId, /* aForCreator */ true);
152-
}
153-
154147
/* static */
155148
void SharedSurfacesParent::DestroyProcess(base::ProcessId aPid) {
156149
StaticMutexAutoLock lock(sMutex);

gfx/layers/ipc/SharedSurfacesParent.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class SharedSurfacesParent final {
6767

6868
static void AddSameProcess(const wr::ExternalImageId& aId,
6969
gfx::SourceSurfaceSharedData* aSurface);
70-
static void RemoveSameProcess(const wr::ExternalImageId& aId);
7170

7271
static StaticMutex sMutex;
7372

0 commit comments

Comments
 (0)