Bug 234134

Summary: [GStreamer][WebRTC] Huge memory leak
Product: WebKit Reporter: Philippe Normand <pnormand>
Component: PlatformAssignee: Philippe Normand <pnormand>
Status: RESOLVED FIXED    
Severity: Normal CC: calvaris, cgarcia, eric.carlson, ews-watchlist, glenn, gustavo, hta, jer.noble, menard, philipj, sergio, tommyw, vjaquez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Philippe Normand 2021-12-10 02:07:06 PST
Initially reported in https://github.com/Igalia/meta-webkit/issues/335

Also happens with mock capture sources.
Comment 1 Philippe Normand 2021-12-10 11:00:34 PST
There's at least one leak here, https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp#L114

I don't have a fix yet though...
Comment 2 Philippe Normand 2021-12-11 08:41:11 PST
(In reply to Philippe Normand from comment #1)
> There's at least one leak here,
> https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/
> gstreamer/MediaSampleGStreamer.cpp#L114
> 
> I don't have a fix yet though...

That's not the culprit actually... Patch incoming
Comment 3 Philippe Normand 2021-12-11 08:54:10 PST
Created attachment 446889 [details]
Patch
Comment 4 Xabier Rodríguez Calvar 2021-12-15 05:02:14 PST
Comment on attachment 446889 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446889&action=review

> Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp:140
> +    const GstClockTime minimumDuration = 1000; // 1 us

period at the end.

> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.cpp:65
> +rtc::scoped_refptr<webrtc::VideoFrameBuffer> GStreamerVideoFrameLibWebRTC::create(GRefPtr<GstSample> sample)

Why did you remove the &&? We should either have const & or &&

> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.h:40
> +    GStreamerVideoFrameLibWebRTC(GRefPtr<GstSample> sample, GstVideoInfo info)

Ditto

> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.h:44
> +    static rtc::scoped_refptr<webrtc::VideoFrameBuffer> create(GRefPtr<GstSample>);

Ditto.
Comment 5 Philippe Normand 2021-12-15 05:30:55 PST
Comment on attachment 446889 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446889&action=review

>> Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp:140
>> +    const GstClockTime minimumDuration = 1000; // 1 us
> 
> period at the end.

Why? This is not a sentence.

>> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.cpp:65
>> +rtc::scoped_refptr<webrtc::VideoFrameBuffer> GStreamerVideoFrameLibWebRTC::create(GRefPtr<GstSample> sample)
> 
> Why did you remove the &&? We should either have const & or &&

&& would transfer ownership iiuc? As mentioned in the changelog we can't do that. Maybe a const& though.

>> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.h:40
>> +    GStreamerVideoFrameLibWebRTC(GRefPtr<GstSample> sample, GstVideoInfo info)
> 
> Ditto

Ditto

>> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.h:44
>> +    static rtc::scoped_refptr<webrtc::VideoFrameBuffer> create(GRefPtr<GstSample>);
> 
> Ditto.

Ditto!.
Comment 6 Xabier Rodríguez Calvar 2021-12-15 08:13:16 PST
Comment on attachment 446889 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446889&action=review

>>> Source/WebCore/platform/mediastream/libwebrtc/gstreamer/GStreamerVideoFrameLibWebRTC.cpp:65
>>> +rtc::scoped_refptr<webrtc::VideoFrameBuffer> GStreamerVideoFrameLibWebRTC::create(GRefPtr<GstSample> sample)
>> 
>> Why did you remove the &&? We should either have const & or &&
> 
> && would transfer ownership iiuc? As mentioned in the changelog we can't do that. Maybe a const& though.

const & sounds good.
Comment 7 Philippe Normand 2021-12-16 05:26:23 PST
Created attachment 447347 [details]
Patch
Comment 8 EWS 2021-12-17 04:49:08 PST
Committed r287180 (245349@main): <https://commits.webkit.org/245349@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 447347 [details].
Comment 9 Radar WebKit Bug Importer 2021-12-17 04:50:19 PST
<rdar://problem/86627091>