Bug 220463

Summary: [GStreamer] Clean-up the TextCombiner
Product: WebKit Reporter: Philippe Normand <pnormand>
Component: PlatformAssignee: Philippe Normand <pnormand>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, calvaris, cgarcia, ews-watchlist, glenn, gustavo, gyuyoung.kim, jbedard, menard, ryuan.choi, sergio, vjaquez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch calvaris: review+, calvaris: commit-queue-

Description Philippe Normand 2021-01-08 08:01:54 PST
Coding style does not conform WebKit's, and it should use the WEBKIT_DEFINE_TYPE machinery.
Comment 1 Philippe Normand 2021-01-11 08:37:55 PST
Created attachment 417382 [details]
Patch
Comment 2 Xabier Rodríguez Calvar 2021-01-12 07:57:43 PST
Comment on attachment 417382 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp:121
> +    auto internalPad = adoptGRef(gst_element_request_pad(combiner->priv->combinerElement.get(), templ, name, caps));
> +    g_object_set(WEBKIT_TEXT_COMBINER_PAD(ghostPad), "inner-combiner-pad", internalPad.leakRef(), nullptr);

You're probably astonished that I tell you this but I don't think you need to create a smart ptr to just release it in the next line.

> Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp:142
> +    gst_element_release_request_pad(combiner->priv->combinerElement.get(), webKitTextCombinerPadLeakInternalPadRef(combinerPad));

Aren't we leaking here? gst_element_release_request_pad doc says "This does not unref the pad. If the pad was created by using gst_element_request_pad(), gst_element_release_request_pad() needs to be followed by gst_object_unref() to free the pad."

> Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp:32
> +#include "GStreamerCommon.h"

You don't need this if you include it in the header.

> Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.h:31
> +#include "GRefPtrGStreamer.h"

GStreamerCommon.h?
Comment 3 Philippe Normand 2021-01-12 08:13:55 PST
Comment on attachment 417382 [details]
Patch

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

>> Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.h:31
>> +#include "GRefPtrGStreamer.h"
> 
> GStreamerCommon.h?

I was profiling the impact of including that header recently, here it adds a 2 seconds wall-time overhead. So unless really needed I now prefer to not include it directly, there is a way to reduce the impact it has but this is another rabbit hole :)
Comment 4 Philippe Normand 2021-01-14 07:58:46 PST
Created attachment 417620 [details]
Patch
Comment 5 Xabier Rodríguez Calvar 2021-01-14 09:15:52 PST
Comment on attachment 417620 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp:142
> +    auto* internalPad = webKitTextCombinerPadLeakInternalPadRef(combinerPad);
> +    gst_element_release_request_pad(combiner->priv->combinerElement.get(), internalPad);
> +    gst_object_unref(internalPad);

Nit: I would adopt it here not unref. I would try to avoid manual unrefs as much as possible cause they can lead to leaks if we change the code around and forget to call it when it is due.
Comment 6 Philippe Normand 2021-01-15 01:27:32 PST
Committed r271512: <https://trac.webkit.org/changeset/271512>
Comment 7 Radar WebKit Bug Importer 2021-01-15 01:28:14 PST
<rdar://problem/73239616>