After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772835 - videooverlaycomposition: Need unref composition when remove video overlay composition meta
videooverlaycomposition: Need unref composition when remove video overlay com...
Status: RESOLVED INVALID
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-10-13 04:33 UTC by kevin
Modified: 2016-10-15 08:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Need unref composition when remove video overlay composition meta (2.90 KB, patch)
2016-10-13 04:38 UTC, kevin
none Details | Review
Need unref composition when remove video overlay composition meta (3.02 KB, patch)
2016-10-13 05:30 UTC, kevin
rejected Details | Review

Description kevin 2016-10-13 04:33:54 UTC
gst_buffer_add_video_overlay_composition_meta() add one ref to GstVideoOverlayComposition * comp. So need unref when remove video composition meta.
Comment 1 kevin 2016-10-13 04:38:16 UTC
Created attachment 337553 [details] [review]
Need unref composition when remove video overlay composition meta
Comment 2 kevin 2016-10-13 05:30:00 UTC
Created attachment 337555 [details] [review]
Need unref composition when remove video overlay composition meta
Comment 3 Nicolas Dufresne (ndufresne) 2016-10-13 13:41:57 UTC
Review of attachment 337555 [details] [review]:

Interesing, that means when we add a video meta, unless we cache the composition, we need to drop the extra ref. Though, this new public function is not useful, since this should already be cleared by gst_buffer_remove_meta(). The remove meta is completely generic, if not, fix it ;-P.
Comment 4 Tim-Philipp Müller 2016-10-13 13:55:19 UTC
> Interesting, that means when we add a video meta, unless we
> cache the composition, we need to drop the extra ref.

In the usual case you attach the same composition to many video buffers, so that seems to make sense, no?

Kevin, please provide a minimal test case that leaks, or let us know if gst_buffer_remove_meta() is enough for your purposes.
Comment 5 Nicolas Dufresne (ndufresne) 2016-10-13 15:42:03 UTC
(In reply to Tim-Philipp Müller from comment #4)
> > Interesting, that means when we add a video meta, unless we
> > cache the composition, we need to drop the extra ref.
> 
> In the usual case you attach the same composition to many video buffers, so
> that seems to make sense, no?

I don't remember exactly, I thought we could re-use the GstMeta, which makes caching of the composition less useful. I need to re-read some code, I didn't notice, and may have introduced leaks all over there.
Comment 6 kevin 2016-10-13 23:17:20 UTC
(In reply to Tim-Philipp Müller from comment #4)
> > Interesting, that means when we add a video meta, unless we
> > cache the composition, we need to drop the extra ref.
> 
> In the usual case you attach the same composition to many video buffers, so
> that seems to make sense, no?
> 
> Kevin, please provide a minimal test case that leaks, or let us know if
> gst_buffer_remove_meta() is enough for your purposes.

Yes, our case is copy gstbuffer and attach the composition to new gstbuffer. it will cause leaks evenif gst_buffer_remove_meta().
Comment 7 kevin 2016-10-14 02:55:14 UTC
Below is our code.

  while ((meta = gst_buffer_iterate_meta (src, &state))) {
    if (meta->info->api == GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE) {
      compmeta = (GstVideoOverlayCompositionMeta*)meta;
      if (GST_IS_VIDEO_OVERLAY_COMPOSITION (compmeta->overlay)) {
        comp_copy = gst_video_overlay_composition_copy(compmeta->overlay);
        if (comp_copy) {
          gst_buffer_add_video_overlay_composition_meta(dst, comp_copy);
        }
      }
    }
  }

gst_video_overlay_composition_copy() will new comp_copy and gst_buffer_add_video_overlay_composition_meta() will add one ref. Do you have any suggestion.
Comment 8 Nicolas Dufresne (ndufresne) 2016-10-14 13:42:27 UTC
(In reply to kevin from comment #7)
> Below is our code.
> 
>   while ((meta = gst_buffer_iterate_meta (src, &state))) {
>     if (meta->info->api == GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE) {
>       compmeta = (GstVideoOverlayCompositionMeta*)meta;
>       if (GST_IS_VIDEO_OVERLAY_COMPOSITION (compmeta->overlay)) {
>         comp_copy = gst_video_overlay_composition_copy(compmeta->overlay);
>         if (comp_copy) {
>           gst_buffer_add_video_overlay_composition_meta(dst, comp_copy);
>         }
>       }
>     }
>   }
> 
> gst_video_overlay_composition_copy() will new comp_copy and
> gst_buffer_add_video_overlay_composition_meta() will add one ref. Do you
> have any suggestion.

According to the API, you must unref if you don't want to keep the composition after gst_buffer_add_video_overlay_composition_meta(). So basically, it is your fault if it leaks. The API makes sense, since the the GstVideoOverlayComposition meta is a copy on write object. That means if it's reference count is bigger then 1, it will be considered immutable and gst_video_overlay_composition_make_writable() will copy. The appropriate usage here is the following:

> compmeta = gst_buffer_get_video_overlay_composition_meta(src);
> if (compmeta)
>   gst_buffer_add_video_overlay_composition_meta (dst, compmeta->overlay);
Comment 9 kevin 2016-10-15 04:16:26 UTC
Is there function to iterate composition? I remember video add timeoverlay and clockoverlay have two compositions. Is it right?
Comment 10 Tim-Philipp Müller 2016-10-15 08:18:20 UTC
gst_buffer_foreach_meta()