Unexpected ownership transfer within a get_property call
System artifacts:
Package: python3-gi
Source: pygobject (3.42.2-3)
Version: 3.42.2-3+b1
Package: python3-gst-1.0
Source: gst-python1.0
Version: 1.22.0-2
Code demonstrating the issue:
import traceback
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib
def consumer_added_callback(wrs, peer_id, webrtcbin):
print('Consumer {} added'.format(webrtcbin))
print('before get_property')
iceagent = webrtcbin.get_property("ice-agent")
print(iceagent)
print('after get_property')
# Initializes Gstreamer, it's variables, paths
Gst.init(sys.argv)
# Create a new pipeline
pipeline = Gst.Pipeline()
# Creates element by name
# https://lazka.github.io/pgi-docs/Gst-1.0/classes/ElementFactory.html#Gst.ElementFactory.make
src_name = "my_video_test_src"
src = Gst.ElementFactory.make("videotestsrc", "my_video_test_src")
wrs = Gst.ElementFactory.make("webrtcsink", "wrs")
wrs.set_property("name", "wrs")
signaller = wrs.get_property("signaller")
signaller.set_property("uri", "ws://gst-webrtc-signalling-service:8443")
pipeline.add(src)
pipeline.add(wrs)
src.link(wrs)
wrs.connect('consumer-added', consumer_added_callback)
# Start pipeline
pipeline.set_state(Gst.State.PLAYING)
# Init GObject loop to handle Gstreamer Bus Events
loop = GLib.MainLoop()
try:
loop.run()
except Exception:
traceback.print_exc()
loop.quit()
# Stop Pipeline
pipeline.set_state(Gst.State.NULL)
del pipeline
The iceagent
reference is being invalidated as it exits the scope of the consumer_added_callback
function, leading to the subsequent destruction of the underlying iceagent
object, which ultimately causes a failure in the pipeline. Making iceagent
global resolves the issue. But it looks like a bug in a binders reference counter logic.
Edited by Robert Ayrapetyan