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 768586 - glimagesink: on Raspberry Pi seems to get elected by playbin even if it does not support set_window_handle
glimagesink: on Raspberry Pi seems to get elected by playbin even if it does ...
Status: RESOLVED NOTGNOME
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.x
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-07-08 16:54 UTC by rolfofsaxony
Modified: 2018-05-06 10:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Wxpython program that illustrates the problem (3.07 KB, text/x-python)
2016-07-08 16:54 UTC, rolfofsaxony
  Details
Amended program using ximagesink (3.27 KB, text/x-python)
2016-07-08 18:23 UTC, rolfofsaxony
  Details
glimagesink: Lower the rank on Raspberry Pi (1.09 KB, patch)
2016-07-08 19:19 UTC, Nicolas Dufresne (ndufresne)
none Details | Review

Description rolfofsaxony 2016-07-08 16:54:43 UTC
Created attachment 331102 [details]
Wxpython program that illustrates the problem

Using python on a Raspbian jessie Raspberry Pi 3 when setting 'set_window_handle' to display video in a specific window, the instruction is ignored.
Instead a mode-less window is opened in the centre of the screen.
It cannot be closed, it cannot be moved and the mouse pointer glides behind it.

This occurs using wxpython and gtk.

I have included a sample program. This functions as expected on a Linux Mate 17 and on the Raspberry Pi 3 when running Ubuntu-Mate. The error manifests itself on the same Raspberry Pi machine when running Raspbian-Jessie with all updates and upgrades current as of today's date.
Comment 1 Tim-Philipp Müller 2016-07-08 17:04:19 UTC
What is the window xid/handle that it gets when it's not working?

I suspect there's a race with your window being realized in the main application thread.

The best thing to do would be to get rid of the sync message handler entirely. Instead, realize your window in the main thread and set the video overlay handle on playbin directly. It will then automatically proxy it to the video sink later.
Comment 2 Nicolas Dufresne (ndufresne) 2016-07-08 17:25:24 UTC
I'm guessing you are using glimagesink. The GL stack is not integrated to the X11 window system, hence setting a window handle has no effect. This is not a GStreamer bug. This problem existed in RPi since day 1.
Comment 3 rolfofsaxony 2016-07-08 17:33:55 UTC
(In reply to Tim-Philipp Müller from comment #1)
> What is the window xid/handle that it gets when it's not working?
> 
> I suspect there's a race with your window being realized in the main
> application thread.
> 
> The best thing to do would be to get rid of the sync message handler
> entirely. Instead, realize your window in the main thread and set the video
> overlay handle on playbin directly. It will then automatically proxy it to
> the video sink later.

I assume that it does not receive the handle at all, which is why it is creating its own window.
The point is, the window that is created cannot be moved from the centre of the screen, I could live with it, if the window could be moved.
The other point, is that the exact same code works perfectly on Linux Mate and on the Raspberry if it is running Ubuntu-Mate. The issue only arises when running Raspbian Jessie.
Re-coding simply to avoid a bug does not seem like a solution, assuming that it is a bug of course.
Comment 4 rolfofsaxony 2016-07-08 17:35:45 UTC
(In reply to Nicolas Dufresne (stormer) from comment #2)
> I'm guessing you are using glimagesink. The GL stack is not integrated to
> the X11 window system, hence setting a window handle has no effect. This is
> not a GStreamer bug. This problem existed in RPi since day 1.

No, I am using 'playbin', please look at the sample code that I included, which recreates the problem.
Comment 5 Nicolas Dufresne (ndufresne) 2016-07-08 17:37:53 UTC
Have you verified what display sink playbin is using ? The solution is probably to unrank glimagesink on RPi though.
Comment 6 Nicolas Dufresne (ndufresne) 2016-07-08 17:42:04 UTC
To help you solving this issue, the NEEDIǸFO means we need to know which display sink was selected by playbin. You should also try setting one, e.g.:

  ximagesink = gst_element_factory_make ("ximagsink", None)
  self.player.set_property('video-sink', ximagesink)

When done, report the results, so we can address your issue properly.
Comment 7 rolfofsaxony 2016-07-08 18:20:56 UTC
(In reply to Nicolas Dufresne (stormer) from comment #6)
> To help you solving this issue, the NEEDIǸFO means we need to know which
> display sink was selected by playbin. You should also try setting one, e.g.:
> 
>   ximagesink = gst_element_factory_make ("ximagsink", None)
>   self.player.set_property('video-sink', ximagesink)
> 
> When done, report the results, so we can address your issue properly.

That cracked it, in this circumstance.
However the fact remains that, the issue still remains, in that using 'playbin' on its own does work on other platforms.
This problem also arises when using "com.sun.star.comp.avmedia.Manager_GStreamer" in LibreOffice.

Having included ximagesink in the playbin pipeline, I print out the value of the ximagesink object and its methods and got this, if it helps:

<__main__.GstXImageSink object at 0x74539828 (GstXImageSink at 0x108cff8)>
['__class__', '__copy__', '__deepcopy__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__gdoc__', '__ge__', '__getattribute__', '__gpointer__', '__grefcount__', '__gsignals__', '__gt__', '__gtype__', '__hash__', '__info__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_force_floating', '_gst_reserved', '_ref', '_ref_sink', '_unref', '_unsupported_data_method', '_unsupported_method', 'abort_state', 'add_control_binding', 'add_metadata', 'add_pad', 'add_pad_template', 'add_static_metadata', 'base_time', 'bind_property', 'bind_property_full', 'bus', 'can_activate_pull', 'can_activate_push', 'center_rect', 'chain', 'change_state', 'check_uniqueness', 'clock', 'clock_id', 'compat_control', 'connect', 'connect_after', 'connect_data', 'connect_object', 'connect_object_after', 'continue_state', 'control_bindings', 'control_rate', 'create_all_pads', 'current_state', 'default_deep_notify', 'default_error', 'disconnect', 'disconnect_by_func', 'do_activate_pull', 'do_change_state', 'do_deep_notify', 'do_event', 'do_fixate', 'do_get_caps', 'do_get_state', 'do_get_times', 'do_no_more_pads', 'do_pad_added', 'do_pad_removed', 'do_post_message', 'do_prepare', 'do_prepare_list', 'do_preroll', 'do_propose_allocation', 'do_provide_clock', 'do_query', 'do_release_pad', 'do_render', 'do_render_list', 'do_send_event', 'do_set_bus', 'do_set_caps', 'do_set_clock', 'do_set_context', 'do_set_state', 'do_show_frame', 'do_start', 'do_state_changed', 'do_stop', 'do_unlock', 'do_unlock_stop', 'do_wait_event', 'element', 'emit', 'emit_stop_by_name', 'eos', 'event_get_type', 'event_parse_command', 'event_parse_key_event', 'event_parse_mouse_button_event', 'event_parse_mouse_move_event', 'expose', 'find_property', 'flags', 'flushing', 'force_floating', 'freeze_notify', 'g_type_instance', 'get_base_time', 'get_blocksize', 'get_bus', 'get_clock', 'get_compatible_pad', 'get_compatible_pad_template', 'get_control_binding', 'get_control_rate', 'get_data', 'get_factory', 'get_g_value_array', 'get_last_sample', 'get_latency', 'get_max_bitrate', 'get_max_lateness', 'get_metadata', 'get_name', 'get_pad_template', 'get_pad_template_list', 'get_parent', 'get_path_string', 'get_properties', 'get_property', 'get_qdata', 'get_render_delay', 'get_request_pad', 'get_start_time', 'get_state', 'get_static_pad', 'get_sync', 'get_throttle_time', 'get_ts_offset', 'get_value', 'get_value_array', 'got_window_handle', 'handle_events', 'handler_block', 'handler_block_by_func', 'handler_disconnect', 'handler_is_connected', 'handler_unblock', 'handler_unblock_by_func', 'has_active_control_bindings', 'has_ancestor', 'have_newsegment', 'have_preroll', 'height', 'install_properties', 'install_property', 'interface_find_property', 'interface_install_property', 'interface_list_properties', 'is_async_enabled', 'is_floating', 'is_last_sample_enabled', 'is_locked_state', 'is_qos_enabled', 'iterate_pads', 'iterate_sink_pads', 'iterate_src_pads', 'last_return', 'last_sync', 'link', 'link_filtered', 'link_pads', 'link_pads_filtered', 'link_pads_full', 'list_properties', 'lock', 'lost_state', 'make_from_uri', 'max_lateness', 'message_full', 'message_get_type', 'message_new_angles_changed', 'message_new_commands_changed', 'message_new_mouse_over', 'message_parse_angles_changed', 'message_parse_mouse_over', 'name', 'need_preroll', 'new', 'next_state', 'no_more_pads', 'notify', 'notify_by_pspec', 'numpads', 'numsinkpads', 'numsrcpads', 'object', 'offset', 'override_property', 'pad_mode', 'pads', 'pads_cookie', 'parent', 'pending_state', 'playing_async', 'post_message', 'prepare_window_handle', 'preroll_cond', 'preroll_lock', 'priv', 'props', 'provide_clock', 'qdata', 'query', 'query_convert', 'query_duration', 'query_get_type', 'query_latency', 'query_new_angles', 'query_new_commands', 'query_parse_angles', 'query_parse_commands_length', 'query_parse_commands_nth', 'query_position', 'query_set_angles', 'query_set_commandsv', 'ref', 'ref_count', 'ref_sink', 'register', 'release_request_pad', 'remove_control_binding', 'remove_pad', 'replace', 'replace_data', 'replace_qdata', 'request_pad', 'run_dispose', 'running', 'seek', 'seek_simple', 'segment', 'send_command', 'send_event', 'send_key_event', 'send_mouse_event', 'set_async_enabled', 'set_base_time', 'set_blocksize', 'set_bus', 'set_clock', 'set_context', 'set_control_binding_disabled', 'set_control_bindings_disabled', 'set_control_rate', 'set_data', 'set_last_sample_enabled', 'set_locked_state', 'set_max_bitrate', 'set_max_lateness', 'set_metadata', 'set_name', 'set_parent', 'set_properties', 'set_property', 'set_qos_enabled', 'set_render_delay', 'set_render_rectangle', 'set_start_time', 'set_state', 'set_static_metadata', 'set_sync', 'set_throttle_time', 'set_ts_offset', 'set_window_handle', 'sinkpad', 'sinkpads', 'srcpads', 'start_time', 'state_change_return_get_name', 'state_cond', 'state_cookie', 'state_get_name', 'state_lock', 'steal_data', 'steal_qdata', 'stop_emission', 'stop_emission_by_name', 'suggest_next_sync', 'sync', 'sync_state_with_parent', 'sync_values', 'target_state', 'thaw_notify', 'unlink', 'unlink_pads', 'unparent', 'unref', 'wait', 'wait_clock', 'wait_preroll', 'watch_closure', 'weak_ref', 'width']
('Window Id:', 25166148)

I have also attached a new version of my sample code that now functions on Raspbian Jessie and Linux Mint 17.

Let me know if there is anything else that you require and I'll endeavour to provide it, tomorrow.
Comment 8 rolfofsaxony 2016-07-08 18:23:33 UTC
Created attachment 331106 [details]
Amended program using ximagesink
Comment 9 Nicolas Dufresne (ndufresne) 2016-07-08 19:19:32 UTC
Created attachment 331110 [details] [review]
glimagesink: Lower the rank on Raspberry Pi

The Raspberry Pi GL stack is not integrated into X11 window system.
Still, it get elected by playbin before ximagesink (g comes before x).
This breaks few application that assumes playbin will only select X11 working
displaysink (notably LibreOffice).

This patch is not tested on RPi, though it should fix the reported issue
without having to modify the applications.
Comment 10 Tim-Philipp Müller 2016-07-08 19:36:05 UTC
Question is though what will it do to performance for everyone just doing some command line stuff or gst-play/playbin ? It will force worst-performing code paths then, no? I think applications should set xvimagesink/ximagesink etc. themselves depending on the windowing system they target.

Perhaps GstVideoOverlay::set_window_id/handle should gain a _full() function that adds a string identifying the handle / windowing system. Then autovideosink could somehow (element details *handwave*) try suitable sinks first. </random ideas>
Comment 11 Nicolas Dufresne (ndufresne) 2016-07-08 20:43:22 UTC
(In reply to Tim-Philipp Müller from comment #10)
> Question is though what will it do to performance for everyone just doing
> some command line stuff or gst-play/playbin ? It will force worst-performing
> code paths then, no? I think applications should set xvimagesink/ximagesink
> etc. themselves depending on the windowing system they target.

X11 is what the Raspberry Pi Foundation targets at the moment. All projects I know that uses glimagesink for performance pick glimagesink directly. glimagesink on raspberry pi is just a poor choice for any serious application because you can't even place the overlay in the screen, it's always centered.

The counter argument is that they are supposedly working on a mesa base driver that will support GLX, but it's been ages. On Raspbian, they still hack the decoder to color transform to RGB, so the rendering to ximagesink is quite fast in fact.

> 
> Perhaps GstVideoOverlay::set_window_id/handle should gain a _full() function
> that adds a string identifying the handle / windowing system. Then
> autovideosink could somehow (element details *handwave*) try suitable sinks
> first. </random ideas>

No idea. To be honest, I have low interest in up-streaming this patch. I feel like the "current" RPi stack is just wrong, and what happens here is a user that suffer it.
Comment 12 rolfofsaxony 2016-07-09 07:31:48 UTC
(In reply to Nicolas Dufresne (stormer) from comment #11)
> (In reply to Tim-Philipp Müller from comment #10)
> > Question is though what will it do to performance for everyone just doing
> > some command line stuff or gst-play/playbin ? It will force worst-performing
> > code paths then, no? I think applications should set xvimagesink/ximagesink
> > etc. themselves depending on the windowing system they target.
> 
> X11 is what the Raspberry Pi Foundation targets at the moment. All projects
> I know that uses glimagesink for performance pick glimagesink directly.
> glimagesink on raspberry pi is just a poor choice for any serious
> application because you can't even place the overlay in the screen, it's
> always centered.
> 
> The counter argument is that they are supposedly working on a mesa base
> driver that will support GLX, but it's been ages. On Raspbian, they still
> hack the decoder to color transform to RGB, so the rendering to ximagesink
> is quite fast in fact.
> 
> > 
> > Perhaps GstVideoOverlay::set_window_id/handle should gain a _full() function
> > that adds a string identifying the handle / windowing system. Then
> > autovideosink could somehow (element details *handwave*) try suitable sinks
> > first. </random ideas>
> 
> No idea. To be honest, I have low interest in up-streaming this patch. I
> feel like the "current" RPi stack is just wrong, and what happens here is a
> user that suffer it.

My thoughts, for what they are worth.
Whilst it is true that I can alter my code to resolve this particular issue, it would appear that the Libreoffice team and one suspects the Apache Openoffice team made the same assumption. Namely that 'playbin/autovideosink' would pick the most relevant sink for the platform. So whilst I can re-code, anyone using the "com.sun.star.comp.avmedia.Manager_GStreamer" facility cannot, as far as I know.
Comment 13 Matthew Waters (ystreet00) 2018-05-06 10:59:32 UTC
While this is a problem, there's not really much we can do about it without degrading something else.  If you want a specific window system integration, you need to force a compatible video sink.