Closed Bug 1421200 Opened 7 years ago Closed 7 years ago

Fix memory leakage for WebRenderUserData

Categories

(Core :: Graphics: WebRender, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: ethlin, Assigned: ethlin)

References

Details

(Whiteboard: [wr-mvp])

Attachments

(1 file)

There is a memory leakage problem in WebRenderUserData. It blocks p2 bug, so I should fix it.
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [wr-mvp]
Comment on attachment 8932387 [details] Bug 1421200 - Fix memory leakage problem when getting WebRenderUserData. https://reviewboard.mozilla.org/r/203450/#review208936 ::: gfx/layers/wr/WebRenderCommandBuilder.h:161 (Diff revision 1) > if (!userDataTable) { > - return result.forget(); > + return nullptr; > } > > - WebRenderUserData* data = nullptr; > - if (userDataTable->Get(aPerFrameKey, &data)) { > + RefPtr<WebRenderUserData> data = userDataTable->Get(aPerFrameKey); > + if (!data || !(data->GetType() == T::Type()) || !data->IsDataValid(mManager)) { The hash table is a nsRefPtrHashtable. The output data of the function 'Get' is already_addrefed[1]. [1] https://dxr.mozilla.org/mozilla-central/rev/cad9c9573579698c223b4b6cb53ca723cd930ad2/xpcom/ds/nsRefPtrHashtable.h#42
(In reply to Ethan Lin[:ethlin] from comment #2) > > The hash table is a nsRefPtrHashtable. The output data of the function 'Get' > is already_addrefed[1]. Good catch!
Comment on attachment 8932387 [details] Bug 1421200 - Fix memory leakage problem when getting WebRenderUserData. https://reviewboard.mozilla.org/r/203450/#review208948 ::: gfx/layers/wr/WebRenderCommandBuilder.h:161 (Diff revision 1) > - if (userDataTable->Get(aPerFrameKey, &data)) { > - if (data->GetType() == T::Type() && data->IsDataValid(mManager)) { > + if (!data || !(data->GetType() == T::Type()) || !data->IsDataValid(mManager)) { > + return nullptr; > - result = static_cast<T*>(data); > - } > } I'd slightly prefer if you inverted the condition, so that it's not all negated: if (data && data->GetType() == T::Type() && data->IsValid(mManager)) { RefPtr<T> result = static_cast<T*>(data.get()); return result.forget(); } return nullptr; I find conditions with a lot of ! harder to read.
Attachment #8932387 - Flags: review?(bugmail) → review+
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #4) > Comment on attachment 8932387 [details] > Bug 1421200 - Fix memory leakage problem when getting WebRenderUserData. > > https://reviewboard.mozilla.org/r/203450/#review208948 > > ::: gfx/layers/wr/WebRenderCommandBuilder.h:161 > (Diff revision 1) > > - if (userDataTable->Get(aPerFrameKey, &data)) { > > - if (data->GetType() == T::Type() && data->IsDataValid(mManager)) { > > + if (!data || !(data->GetType() == T::Type()) || !data->IsDataValid(mManager)) { > > + return nullptr; > > - result = static_cast<T*>(data); > > - } > > } > > I'd slightly prefer if you inverted the condition, so that it's not all > negated: > > if (data && data->GetType() == T::Type() && data->IsValid(mManager)) { > RefPtr<T> result = static_cast<T*>(data.get()); > return result.forget(); > } > > return nullptr; > > I find conditions with a lot of ! harder to read. Okay, I don't like inverse conditions neither!
Pushed by ethlin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/29dcfd9a7ce8 Fix memory leakage problem when getting WebRenderUserData. r=kats
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: