commit 7749fdd33aedaf9d72956cc6fa6e892f1edbf418
parent e89552cb83b38b77e82a84f5c2c932291c2f7ff0
Author: Markus Stange <mstange.moz@gmail.com>
Date: Tue, 7 Oct 2025 14:12:05 +0000
Bug 1992872 - Reuse snapshotters between reftest readbacks. r=bradwerth
Before: https://share.firefox.dev/46HvB2g (2582 samples)
After: https://share.firefox.dev/3IxEZMD (754 samples, 3.4x faster)
I captured these profiles with the following command:
```
samply record python3 ./mach reftest layout/reftests/reftest-sanity/reftest.list --setpref layers.gpu-process.enabled=true
```
Differential Revision: https://phabricator.services.mozilla.com/D267681
Diffstat:
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/gfx/layers/NativeLayerRootRemoteMacParent.h b/gfx/layers/NativeLayerRootRemoteMacParent.h
@@ -47,6 +47,7 @@ class NativeLayerRootRemoteMacParent final : public NativeLayerRemoteParent {
bool aIsHDR, IntSize aSize);
RefPtr<NativeLayerRootCA> mRealNativeLayerRoot;
+ UniquePtr<NativeLayerRootSnapshotter> mSnapshotter;
nsTHashMap<uint64_t, RefPtr<NativeLayer>> mKnownLayers;
};
diff --git a/gfx/layers/NativeLayerRootRemoteMacParent.mm b/gfx/layers/NativeLayerRootRemoteMacParent.mm
@@ -102,13 +102,15 @@ mozilla::ipc::IPCResult NativeLayerRootRemoteMacParent::RecvRequestReadback(
return IPC_FAIL(this, "Can't allocate shmem.");
}
- auto snapshotter = mRealNativeLayerRoot->CreateSnapshotter();
- if (!snapshotter) {
- return IPC_FAIL(this, "Can't create parent-side snapshotter.");
+ if (!mSnapshotter) {
+ mSnapshotter = mRealNativeLayerRoot->CreateSnapshotter();
+ if (!mSnapshotter) {
+ return IPC_FAIL(this, "Can't create parent-side snapshotter.");
+ }
}
- if (!snapshotter->ReadbackPixels(aSize, readbackFormat,
- buffer.Range<uint8_t>())) {
+ if (!mSnapshotter->ReadbackPixels(aSize, readbackFormat,
+ buffer.Range<uint8_t>())) {
return IPC_FAIL(this, "Failed readback.");
}