Bug 1870970 - Ensure we call DrawEventRecorder::DetachResources to avoid memory leaks. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D196936
This commit is contained in:
Andrew Osmond 2023-12-20 12:59:26 +00:00
parent 1b7e49f639
commit 40d33b8232
2 changed files with 12 additions and 2 deletions

View file

@ -152,6 +152,7 @@ PaintFragment PaintFragment::Record(dom::BrowsingContext* aBc,
}
if (!recorder->mOutputStream.mValid) {
recorder->DetachResources();
return PaintFragment{};
}
@ -162,11 +163,14 @@ PaintFragment PaintFragment::Record(dom::BrowsingContext* aBc,
recorder->mOutputStream.mLength = 0;
recorder->mOutputStream.mCapacity = 0;
return PaintFragment{
PaintFragment fragment{
surfaceSize.ToUnknownSize(),
std::move(recording),
std::move(recorder->TakeDependentSurfaces()),
};
recorder->DetachResources();
return fragment;
}
bool PaintFragment::IsEmpty() const {
@ -323,7 +327,7 @@ CrossProcessPaint::CrossProcessPaint(float aScale, dom::TabId aRoot,
CrossProcessPaintFlags aFlags)
: mRoot{aRoot}, mScale{aScale}, mPendingFragments{0}, mFlags{aFlags} {}
CrossProcessPaint::~CrossProcessPaint() = default;
CrossProcessPaint::~CrossProcessPaint() { Clear(NS_ERROR_ABORT); }
void CrossProcessPaint::ReceiveFragment(dom::WindowGlobalParent* aWGP,
PaintFragment&& aFragment) {

View file

@ -125,6 +125,12 @@ nsDeviceContextSpecProxy::EndDocument() {
Unused << mRemotePrintJob->SendFinalizePrint();
if (mRecorder) {
MOZ_ASSERT(!mRecorder->IsOpen());
mRecorder->DetachResources();
mRecorder = nullptr;
}
return mozilla::gfx::PrintEndDocumentPromise::CreateAndResolve(true,
__func__);
}