Closed
Bug 1421200
Opened 7 years ago
Closed 7 years ago
Fix memory leakage for WebRenderUserData
Categories
(Core :: Graphics: WebRender, enhancement, P1)
Core
Graphics: WebRender
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.
Comment hidden (mozreview-request) |
Updated•7 years ago
|
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [wr-mvp]
Assignee | ||
Comment 2•7 years ago
|
||
mozreview-review |
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
Comment 3•7 years ago
|
||
(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 4•7 years ago
|
||
mozreview-review |
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+
Assignee | ||
Comment 5•7 years ago
|
||
(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!
Comment hidden (mozreview-request) |
Pushed by ethlin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/29dcfd9a7ce8
Fix memory leakage problem when getting WebRenderUserData. r=kats
Comment 8•7 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox59:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in
before you can comment on or make changes to this bug.
Description
•