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 784414 - ges-timeline-element: emit 'deep-notify' signal in main thread
ges-timeline-element: emit 'deep-notify' signal in main thread
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-editing-services
git master
Other Linux
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-07-01 08:44 UTC by Stefan-Adrian Popa
Modified: 2017-07-03 18:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch which ensures deep-notify signals get emitted on the main thread. (2.03 KB, patch)
2017-07-01 08:44 UTC, Stefan-Adrian Popa
none Details | Review
Updated patch. Emits 'deep-notify' right away if in main thread. (2.12 KB, patch)
2017-07-01 11:11 UTC, Stefan-Adrian Popa
none Details | Review
Updated patch. (2.12 KB, patch)
2017-07-01 11:50 UTC, Stefan-Adrian Popa
none Details | Review
ges_timeline_element::deep-notify emitted on the main thread (29.82 KB, patch)
2017-07-03 11:03 UTC, Stefan-Adrian Popa
needs-work Details | Review
ges_timeline_element::deep-notify emitted only on the main thread (2.03 KB, patch)
2017-07-03 15:36 UTC, Stefan-Adrian Popa
committed Details | Review

Description Stefan-Adrian Popa 2017-07-01 08:44:50 UTC
Created attachment 354756 [details] [review]
Patch which ensures deep-notify signals get emitted on the main thread.

We should make sure that 'deep-notify' signal gets emitted in the main thread, as other components that connect to it might need to get the callback in the main thread (for Gtk calls for example).
Comment 1 Tim-Philipp Müller 2017-07-01 10:56:34 UTC
Others might want the notification synchronously though..

You might also be interested in the recently-added

  gst_element_add_property_deep_notify_watch()

which posts messages on the pipeline bus for deep notify signals, messages which you'd then typically pick up from the main thread.
Comment 2 Thibault Saunier 2017-07-01 11:06:57 UTC
GES is suposdely not multi threaded, I think it makes sense that all our API is happening in the main thread/thread used by GES.

Requiring the user handle it on the bus message doesn't seem appropriate here, and gst_element_add_property_deep_notify_watch doesn't allow us to handle it for pad properties.

I think simply marshalling in the main maincontext thread is the way to go here.
Comment 3 Stefan-Adrian Popa 2017-07-01 11:11:35 UTC
Created attachment 354758 [details] [review]
Updated patch. Emits 'deep-notify' right away if in main thread.
Comment 4 Tim-Philipp Müller 2017-07-01 11:21:44 UTC
Fair enough, but it will work for pad properties, you just have to set it up on an element (setting it up on a pad doesn't make sense because then you could just use a normal notify signal, there's no 'deep' for the pad after all). It's used in gst-launch-1.0 fwiw.
Comment 5 Thibault Saunier 2017-07-01 11:28:09 UTC
(In reply to Tim-Philipp Müller from comment #4)
> Fair enough, but it will work for pad properties, you just have to set it up
> on an element (setting it up on a pad doesn't make sense because then you
> could just use a normal notify signal, there's no 'deep' for the pad after
> all). It's used in gst-launch-1.0 fwiw.

Right, but in GES we have a different notion of deep-notifie for GESTimelineElement, were we do it for only whitelisted properties.
Comment 6 Thibault Saunier 2017-07-01 11:29:32 UTC
Review of attachment 354758 [details] [review]:

Apart from that, looks good.

::: ges/ges-timeline-element.c
@@ +1305,3 @@
+
+  data->child = gst_object_ref (child);
+    return;

Does that work?! It should be g_param_spec_ref/g_param_spec_unref as GParamSpec is not a GObject
Comment 7 Stefan-Adrian Popa 2017-07-01 11:50:25 UTC
Created attachment 354761 [details] [review]
Updated patch.

Made the required changes.
Comment 8 Thibault Saunier 2017-07-01 12:09:33 UTC
Review of attachment 354761 [details] [review]:

This breaks the following tests:
check.gst-editing-services.ges_basic.test_ges_timeline_add_layer: Failed 'Application returned 1'
check.gst-editing-services.ges_basic.test_ges_timeline_add_layer_first: Failed 'Application returned 1'
check.gst-editing-services.ges_basic.test_ges_timeline_remove_track: Failed 'Application returned 1'
check.gst-editing-services.ges_basic.test_ges_scenario: Failed 'Application returned 1'
check.gst-editing-services.ges_basic.test_ges_timeline_multiple_tracks: Failed 'Application returned 1'
check.gst-editing-services.ges_clip.test_clip_group_ungroup: Failed 'Application returned 1'
check.gst-editing-services.ges_clip.test_split_object: Failed 'Application returned 1'
check.gst-editing-services.ges_timelineedition.test_timeline_edition_mode: Failed 'Application returned 1'
check.gst-editing-services.ges_timelineedition.test_snapping: Failed 'Application returned 1'

Example of the issue:

=================
Test name: check.gst-editing-services.ges_basic.test_ges_timeline_multiple_tracks
Command: '/home/thiblahute/devel/gstreamer/gst-master/build/subprojects/gst-editing-services/tests/check/ges_basic'
=================

Running suite(s): ges-basic
0%: Checks: 1, Failures: 1, Errors: 0
../subprojects/gst-editing-services/tests/check/ges/basic.c:617:F:basic:test_ges_timeline_multiple_tracks:0: trackelement (0x5581c028acf0) refcount is 5 instead of 4
Comment 9 Nicolas Dufresne (ndufresne) 2017-07-01 14:00:36 UTC
I also think g_idle_add is wrong, as Thibault just mention GES can run on another GMaintContext/Thread. Use g_idle_source_new instead and attach it to the thread default context.
Comment 10 Thibault Saunier 2017-07-01 14:38:21 UTC
(In reply to Nicolas Dufresne (stormer) from comment #9)
> I also think g_idle_add is wrong, as Thibault just mention GES can run on
> another GMaintContext/Thread. Use g_idle_source_new instead and attach it to
> the thread default context.

Well, that would run the callback from the thread where it is emited, really not what we want :-)

Most logical thing to handle that case would be to use the default MainContext from the thread where GES has been initialized, but I would say it is not mandatory for now.
Comment 11 Nicolas Dufresne (ndufresne) 2017-07-01 19:39:16 UTC
I meant GES GMainContext of course.

(In reply to Thibault Saunier from comment #2)
> GES is suposdely not multi threaded, I think it makes sense that all our API
> is happening in the main thread/thread used by GES.
> 

Here you open the door that GES could be running in non-default context (a second context). Using g_idle_add will always reach the default context, that's what I'm saying. If you don't support that, then fine (just like GTK).
Comment 12 Thibault Saunier 2017-07-01 19:57:47 UTC
(In reply to Nicolas Dufresne (stormer) from comment #11)
> I meant GES GMainContext of course.

We do not have that concept (yet), if we have a case where it is needed, I think we should had it at that point.

I am under the impression that for android we might need it, but I do not see anything blocking us from doing it later when actually needed.
Comment 13 Stefan-Adrian Popa 2017-07-03 11:03:30 UTC
Created attachment 354830 [details] [review]
ges_timeline_element::deep-notify emitted on the main thread

Fixed tests broken by the previous patch.
Comment 14 Thibault Saunier 2017-07-03 13:21:34 UTC
Review of attachment 354830 [details] [review]:

I guess the same is true with the other tests, please check.

::: tests/check/ges/basic.c
@@ -101,0 +113,11 @@
+
+  /* Let the main loop run so the "deep-notify" signal gets emitted properly.
+   * We need to do this as "deep-notify" signals get emitted only in the main
... 8 more ...

Why does the callback get emited from a GSource and not directly in that test?

Check the stack:

(gdb) t a a bt

Thread 1 (Thread 0x7ffff7f8c740 (LWP 8868))

  • #0 raise
    from /usr/lib/libc.so.6
  • #1 abort
    from /usr/lib/libc.so.6
  • #2 g_assertion_message
    at ../subprojects/glib/glib/gtestutils.c line 2433
  • #3 g_assertion_message_expr
    at ../subprojects/glib/glib/gtestutils.c line 2456
  • #4 child_prop_changed_cb
    at ../subprojects/gst-editing-services/ges/ges-timeline-element.c line 1298
  • #5 g_cclosure_marshal_VOID__PARAM
    at ../subprojects/glib/gobject/gmarshal.c line 1832
  • #6 g_closure_invoke
    at ../subprojects/glib/gobject/gclosure.c line 804
  • #7 signal_emit_unlocked_R
    at ../subprojects/glib/gobject/gsignal.c line 3635
  • #8 g_signal_emit_valist
    at ../subprojects/glib/gobject/gsignal.c line 3391
  • #9 g_signal_emit
    at ../subprojects/glib/gobject/gsignal.c line 3447
  • #10 g_object_dispatch_properties_changed
    at ../subprojects/glib/gobject/gobject.c line 1064
  • #11 gst_object_dispatch_properties_changed
    at ../subprojects/gstreamer/gst/gstobject.c line 427
  • #12 g_object_notify_queue_thaw
    at ../subprojects/glib/gobject/gobject.c line 296
  • #13 g_object_setv
    at ../subprojects/glib/gobject/gobject.c line 2232
  • #14 g_object_set_property
    at ../subprojects/glib/gobject/gobject.c line 2513
  • #15 ges_timeline_element_set_child_property
    at ../subprojects/gst-editing-services/ges/ges-timeline-element.c line 1432
  • #16 ges_track_element_set_child_property
    at ../subprojects/gst-editing-services/ges/ges-track-element.c line 1151
  • #17 ges_video_test_source_set_pattern
    at ../subprojects/gst-editing-services/ges/ges-video-test-source.c line 106
  • #18 ges_test_clip_create_track_element
    at ../subprojects/gst-editing-services/ges/ges-test-clip.c line 342
  • #19 ges_clip_create_track_element
    at ../subprojects/gst-editing-services/ges/ges-clip.c line 879
  • #20 ges_clip_create_track_elements_func
    at ../subprojects/gst-editing-services/ges/ges-clip.c line 961
  • #21 ges_clip_create_track_elements
    at ../subprojects/gst-editing-services/ges/ges-clip.c line 928
  • #22 add_object_to_tracks
    at ../subprojects/gst-editing-services/ges/ges-timeline.c line 2257
  • #23 layer_object_added_cb
    at ../subprojects/gst-editing-services/ges/ges-timeline.c line 2482
  • #24 ffi_call_unix64
    from /usr/lib/libffi.so.6
  • #25 ffi_call
    from /usr/lib/libffi.so.6
  • #26 g_cclosure_marshal_generic
    at ../subprojects/glib/gobject/gclosure.c line 1490
  • #27 g_closure_invoke
    at ../subprojects/glib/gobject/gclosure.c line 804
  • #28 signal_emit_unlocked_R
    at ../subprojects/glib/gobject/gsignal.c line 3705
  • #29 g_signal_emit_valist
    at ../subprojects/glib/gobject/gsignal.c line 3391
  • #30 g_signal_emit
    at ../subprojects/glib/gobject/gsignal.c line 3447
  • #31 ges_layer_add_clip
    at ../subprojects/gst-editing-services/ges/ges-layer.c line 631
  • #32 test_ges_scenario
    at ../subprojects/gst-editing-services/tests/check/ges/basic.c line 100
  • #33 tcase_run_tfun_nofork
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 393
  • #34 srunner_iterate_tcase_tfuns
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 243
  • #35 srunner_run_tcase
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 377
  • #36 srunner_iterate_suites
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 205
  • #37 srunner_run_tagged
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 744
  • #38 srunner_run
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 758
  • #39 srunner_run_all
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 696
  • #40 gst_check_run_suite
    at ../subprojects/gstreamer/libs/gst/check/gstcheck.c line 1057
  • #41 main
    at ../subprojects/gst-editing-services/tests/check/ges/basic.c line 942


We are in the main thread when the element property changed and we should be emitting from the main thread and not on an idle GSource here, please check why it is not the case and do not change the testcase as it should not be needed :)
Comment 15 Thibault Saunier 2017-07-03 13:21:39 UTC
Review of attachment 354830 [details] [review]:

I guess the same is true with the other tests, please check.

::: tests/check/ges/basic.c
@@ -101,0 +113,11 @@
+
+  /* Let the main loop run so the "deep-notify" signal gets emitted properly.
+   * We need to do this as "deep-notify" signals get emitted only in the main
... 8 more ...

Why does the callback get emited from a GSource and not directly in that test?

Check the stack:

(gdb) t a a bt

Thread 1 (Thread 0x7ffff7f8c740 (LWP 8868))

  • #0 raise
    from /usr/lib/libc.so.6
  • #1 abort
    from /usr/lib/libc.so.6
  • #2 g_assertion_message
    at ../subprojects/glib/glib/gtestutils.c line 2433
  • #3 g_assertion_message_expr
    at ../subprojects/glib/glib/gtestutils.c line 2456
  • #4 child_prop_changed_cb
    at ../subprojects/gst-editing-services/ges/ges-timeline-element.c line 1298
  • #5 g_cclosure_marshal_VOID__PARAM
    at ../subprojects/glib/gobject/gmarshal.c line 1832
  • #6 g_closure_invoke
    at ../subprojects/glib/gobject/gclosure.c line 804
  • #7 signal_emit_unlocked_R
    at ../subprojects/glib/gobject/gsignal.c line 3635
  • #8 g_signal_emit_valist
    at ../subprojects/glib/gobject/gsignal.c line 3391
  • #9 g_signal_emit
    at ../subprojects/glib/gobject/gsignal.c line 3447
  • #10 g_object_dispatch_properties_changed
    at ../subprojects/glib/gobject/gobject.c line 1064
  • #11 gst_object_dispatch_properties_changed
    at ../subprojects/gstreamer/gst/gstobject.c line 427
  • #12 g_object_notify_queue_thaw
    at ../subprojects/glib/gobject/gobject.c line 296
  • #13 g_object_setv
    at ../subprojects/glib/gobject/gobject.c line 2232
  • #14 g_object_set_property
    at ../subprojects/glib/gobject/gobject.c line 2513
  • #15 ges_timeline_element_set_child_property
    at ../subprojects/gst-editing-services/ges/ges-timeline-element.c line 1432
  • #16 ges_track_element_set_child_property
    at ../subprojects/gst-editing-services/ges/ges-track-element.c line 1151
  • #17 ges_video_test_source_set_pattern
    at ../subprojects/gst-editing-services/ges/ges-video-test-source.c line 106
  • #18 ges_test_clip_create_track_element
    at ../subprojects/gst-editing-services/ges/ges-test-clip.c line 342
  • #19 ges_clip_create_track_element
    at ../subprojects/gst-editing-services/ges/ges-clip.c line 879
  • #20 ges_clip_create_track_elements_func
    at ../subprojects/gst-editing-services/ges/ges-clip.c line 961
  • #21 ges_clip_create_track_elements
    at ../subprojects/gst-editing-services/ges/ges-clip.c line 928
  • #22 add_object_to_tracks
    at ../subprojects/gst-editing-services/ges/ges-timeline.c line 2257
  • #23 layer_object_added_cb
    at ../subprojects/gst-editing-services/ges/ges-timeline.c line 2482
  • #24 ffi_call_unix64
    from /usr/lib/libffi.so.6
  • #25 ffi_call
    from /usr/lib/libffi.so.6
  • #26 g_cclosure_marshal_generic
    at ../subprojects/glib/gobject/gclosure.c line 1490
  • #27 g_closure_invoke
    at ../subprojects/glib/gobject/gclosure.c line 804
  • #28 signal_emit_unlocked_R
    at ../subprojects/glib/gobject/gsignal.c line 3705
  • #29 g_signal_emit_valist
    at ../subprojects/glib/gobject/gsignal.c line 3391
  • #30 g_signal_emit
    at ../subprojects/glib/gobject/gsignal.c line 3447
  • #31 ges_layer_add_clip
    at ../subprojects/gst-editing-services/ges/ges-layer.c line 631
  • #32 test_ges_scenario
    at ../subprojects/gst-editing-services/tests/check/ges/basic.c line 100
  • #33 tcase_run_tfun_nofork
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 393
  • #34 srunner_iterate_tcase_tfuns
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 243
  • #35 srunner_run_tcase
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 377
  • #36 srunner_iterate_suites
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 205
  • #37 srunner_run_tagged
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 744
  • #38 srunner_run
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 758
  • #39 srunner_run_all
    at ../subprojects/gstreamer/libs/gst/check/libcheck/check_run.c line 696
  • #40 gst_check_run_suite
    at ../subprojects/gstreamer/libs/gst/check/gstcheck.c line 1057
  • #41 main
    at ../subprojects/gst-editing-services/tests/check/ges/basic.c line 942


We are in the main thread when the element property changed and we should be emitting from the main thread and not on an idle GSource here, please check why it is not the case and do not change the testcase as it should not be needed :)
Comment 16 Stefan-Adrian Popa 2017-07-03 15:36:17 UTC
Created attachment 354844 [details] [review]
ges_timeline_element::deep-notify emitted only on the main thread

Fixed the condition which checked if we are in the main thread.