Assertion error from GLIB on clearing stream object

On calling g_clear_object for a camera stream which has spawned buffers in the above fashion we get the following error multiple times:

GLib-GObject-CRITICAL **: 14:41:14.395: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

Our use of buffers is detailed below:

  • When a buffer is completed we have setup a callback that moves the buffer onto a thread safe queue
  • The buffer is popped from the queue in the main thread to be processed.
  • In main thread once we are done with the buffer we clear it using g_clear_object.

It seems to me that when the stream is being dereferenced (i.e. when we do g_clear_object on the camera stream) this also tries to clear these buffers but cannot as we have already cleared them.

I think this means we have a reference somewhere in the camera stream to these buffers that is not being removed when we do g_clear_object on the buffer- Perhaps a reference within Aravis itself unfortunately I have no real idea of what this might be or if there is anything we will be able to do about it?

Full relevant log extract:

2023-12-21T08:46:29.624964 ACTION STANDBY (Execute)
2023-12-21T08:46:29.625047 MAIN_THR DEBUG Executing command "AcquisitionAbort" ...
2023-12-21T08:46:29.626894 MAIN_THR DEBUG Dereferencing camera stream...
2023-12-21T08:46:29.627061 FRM_REC_THR DEBUG Callback state ARV_STREAM_CALLBACK_TYPE_EXIT
2023-12-21T08:46:29.628165 FRM_REC_THR DEBUG COM_INT_receive_frame_callback.C:37 Stopping frame reception thread...
[08:46:29.629] 🆆 device> [GvDevice::write_register] Ack reception timeout
[...]
[08:46:29.630] 🅸 stream> [GvStream::finalize] n_completed_buffers    = 7
[...]
[08:46:29.630] 🅸 stream> [Stream::finalize] Flush 5 buffer[s] in input queue
[08:46:29.630] 🅸 stream> [Stream::finalize] Flush 7 buffer[s] in output queue

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(process:790142): GLib-GObject-CRITICAL **: 08:46:29.630: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

I have found this issue to be due to a misunderstanding of the Aravis callback’s. Whilst I had been working to clear buffers manually I had misunderstood that we needed to pop a frame from the stream during a callback. I had not realised that this was not done by the callback automatically even though the buffer is a argument to the callback.