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 795391 - vaapi: problems when playing with glimagesink with egl
vaapi: problems when playing with glimagesink with egl
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other All
: Normal normal
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 796470 796564
 
 
Reported: 2018-04-20 06:04 UTC by Hyunjun Ko
Modified: 2018-06-14 02:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libs: display: avoid VA initialization twice (2.07 KB, patch)
2018-04-24 07:10 UTC, Hyunjun Ko
none Details | Review
RFC: display: egl: fix to create VaapiDisplayEGL with native EGL display and call it when creation (6.67 KB, patch)
2018-04-24 09:36 UTC, Hyunjun Ko
none Details | Review
libs: utils: egl: mark is_wraaped TRUE if the context is wrapped (824 bytes, patch)
2018-04-24 09:40 UTC, Hyunjun Ko
accepted-commit_now Details | Review
libs: egl: utils: fix usage of GstGL macros (1010 bytes, patch)
2018-04-25 14:29 UTC, Víctor Manuel Jáquez Leal
none Details | Review
libs: egl: utils: fix usage of GstGL macros (1010 bytes, patch)
2018-04-25 16:01 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: egl: utils: mark context as wrapped when it is (1.09 KB, patch)
2018-04-25 16:02 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
meson: fix USE_GLES_VERSION_MASK (2.37 KB, patch)
2018-04-25 16:02 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
plugins: handle EGL when creating VAAPI display from gl (1.67 KB, patch)
2018-04-27 16:56 UTC, Víctor Manuel Jáquez Leal
none Details | Review
display: egl: fix to create VaapiDisplayEGL with native EGL display (7.36 KB, patch)
2018-06-01 05:59 UTC, Hyunjun Ko
none Details | Review
display: egl: create VaapiDisplayEGL with native EGL display (6.87 KB, patch)
2018-06-11 17:39 UTC, Víctor Manuel Jáquez Leal
none Details | Review
plugins: handle EGL when creating VAAPI display from gl (2.17 KB, patch)
2018-06-11 17:39 UTC, Víctor Manuel Jáquez Leal
none Details | Review
libs: display: egl: initialize params structure (2.02 KB, patch)
2018-06-11 17:39 UTC, Víctor Manuel Jáquez Leal
none Details | Review
libs: display: resurrect parent private member (3.97 KB, patch)
2018-06-11 17:39 UTC, Víctor Manuel Jáquez Leal
none Details | Review
display: egl: create VaapiDisplayEGL with native EGL display (6.87 KB, patch)
2018-06-12 10:57 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
plugins: handle EGL when creating VAAPI display from gl (3.44 KB, patch)
2018-06-12 10:57 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: display: egl: initialize params structure (2.02 KB, patch)
2018-06-12 10:57 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: display: resurrect parent private member (3.97 KB, patch)
2018-06-12 10:57 UTC, Víctor Manuel Jáquez Leal
committed Details | Review

Description Hyunjun Ko 2018-04-20 06:04:28 UTC
Here are problems I found.

$ gst-play-1.0 a.mp4 b.mp4 c.mp4 --videosink=glimagesink

1. Crash on Wayland.
Not 100% but a crash is very likely to happen when jumping to next media.

2. Doesn't display anything from the 2nd media.
You can see this issue on X11/EGL and Wayland(if the 1st one is fixed).

If you can't reproduce these issues, please let me know because it means that my environment is wrong.
Comment 1 Víctor Manuel Jáquez Leal 2018-04-20 07:52:09 UTC
Confirmed.

There's a problem when dmabuf is negotiated. Perhaps we're not resetting something properly.

The crash I got in wayland (weston) is:

  • #0 __GI_raise
    at ../sysdeps/unix/sysv/linux/raise.c line 51
  • #1 __GI_abort
    at abort.c line 79
  • #2 __assert_fail_base
    at assert.c line 92
  • #3 __GI___assert_fail
    at assert.c line 101
  • #4 intel_batchbuffer_reset
    at ../subprojects/intel-vaapi-driver/src/intel_batchbuffer.c line 63
  • #5 intel_batchbuffer_flush
    at ../subprojects/intel-vaapi-driver/src/intel_batchbuffer.c line 148
  • #6 gen6_pp_object_walker
    at ../subprojects/intel-vaapi-driver/src/i965_post_processing.c line 4674
  • #7 gen6_pp_pipeline_setup
    at ../subprojects/intel-vaapi-driver/src/i965_post_processing.c line 4691
  • #8 gen6_post_processing
    at ../subprojects/intel-vaapi-driver/src/i965_post_processing.c line 4719
  • #9 i965_post_processing_internal
    at ../subprojects/intel-vaapi-driver/src/i965_post_processing.c line 4743
  • #10 i965_image_pl1_rgbx_processing
    at ../subprojects/intel-vaapi-driver/src/i965_post_processing.c line 5073
  • #11 i965_image_processing
    at ../subprojects/intel-vaapi-driver/src/i965_post_processing.c line 5555
  • #12 i965_hw_putimage
    at ../subprojects/intel-vaapi-driver/src/i965_drv_video.c line 5569
  • #13 i965_PutImage
    at ../subprojects/intel-vaapi-driver/src/i965_drv_video.c line 5630
  • #14 gst_vaapi_surface_put_image
    at ../subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapisurface.c line 741
  • #15 ensure_allowed_raw_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipluginbase.c line 1315
  • #16 gst_vaapi_plugin_base_get_allowed_raw_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipluginbase.c line 1351
  • #17 ensure_allowed_sinkpad_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c line 1095
  • #18 gst_vaapipostproc_transform_caps_impl
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c line 1189
  • #19 gst_vaapipostproc_transform_caps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapipostproc.c line 1212
  • #20 gst_base_transform_transform_caps
  • #21 gst_base_transform_query_caps
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 686
  • #22 gst_base_transform_default_query
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 1541
  • #23 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4038
  • #24 gst_pad_peer_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4170
  • #25 gst_pad_peer_query_caps
    at ../subprojects/gstreamer/gst/gstutils.c line 3089
  • #26 gst_base_transform_query_caps
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 669
  • #27 gst_base_transform_default_query
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 1541
  • #28 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4038
  • #29 gst_pad_peer_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4170
  • #30 query_caps_func
    at ../subprojects/gstreamer/gst/gstutils.c line 2759
  • #31 gst_pad_forward
    at ../subprojects/gstreamer/gst/gstpad.c line 3009
  • #32 gst_pad_proxy_query_caps
    at ../subprojects/gstreamer/gst/gstutils.c line 2809
  • #33 gst_pad_query_caps_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3188
  • #34 gst_pad_query_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3420
  • #35 gst_queue_handle_sink_query
    at ../subprojects/gstreamer/plugins/elements/gstqueue.c line 1079
  • #36 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4038
  • #37 gst_pad_peer_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4170
  • #38 gst_pad_peer_query_caps
    at ../subprojects/gstreamer/gst/gstutils.c line 3089
  • #39 __gst_video_element_proxy_getcaps
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideoutilsprivate.c line 108
  • #40 gst_video_decoder_proxy_getcaps
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1750
  • #41 gst_vaapidecode_sink_getcaps
    at ../subprojects/gstreamer-vaapi/gst/vaapi/gstvaapidecode.c line 1340
  • #42 gst_video_decoder_sink_getcaps
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1764
  • #43 gst_video_decoder_sink_query_default
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1813
  • #44 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4038
  • #45 gst_pad_query_caps
  • #46 gst_video_decoder_sink_query_default
    at ../subprojects/gst-plugins-base/gst-libs/gst/video/gstvideodecoder.c line 1837
  • #47 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4038
  • #48 gst_pad_peer_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4170
  • #49 query_accept_caps_func
    at ../subprojects/gstreamer/gst/gstutils.c line 2699
  • #50 gst_pad_forward
    at ../subprojects/gstreamer/gst/gstpad.c line 3009
  • #51 gst_pad_proxy_query_accept_caps
    at ../subprojects/gstreamer/gst/gstutils.c line 2739
  • #52 gst_pad_query_accept_caps_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3135
  • #53 gst_pad_query_default
    at ../subprojects/gstreamer/gst/gstpad.c line 3416
  • #54 gst_pad_query
    at ../subprojects/gstreamer/gst/gstpad.c line 4038
  • #55 gst_pad_query_accept_caps
    at ../subprojects/gstreamer/gst/gstutils.c line 3126
  • #56 pre_eventfunc_check
    at ../subprojects/gstreamer/gst/gstpad.c line 5572
  • #57 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5706
  • #58 gst_pad_send_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5885
  • #59 send_sticky_event
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 1969
  • #60 foreach_dispatch_function
    at ../subprojects/gstreamer/gst/gstpad.c line 5984
  • #61 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 611
  • #62 gst_pad_sticky_events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 6015
  • #63 send_sticky_events
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 1984
  • #64 connect_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 2506
  • #65 analyze_new_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 1798
  • #66 pad_added_cb
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 2939
  • #67 caps_notify_cb
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 3129
  • #68 g_closure_invoke
  • #69 0x00007ffff6bd8d3e in
  • #70 g_signal_emit_valist
  • #71 g_signal_emit
  • #72 0x00007ffff6bca424 in
  • #73 gst_object_dispatch_properties_changed
    at ../subprojects/gstreamer/gst/gstobject.c line 430
  • #74 g_object_notify_by_pspec
  • #75 store_sticky_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5197
  • #76 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5490
  • #77 gst_pad_set_caps
    at ../subprojects/gstreamer/gst/gstcompat.h line 59
  • #78 gst_base_transform_setcaps
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 1328
  • #79 gst_base_transform_sink_eventfunc
    at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c line 1889
  • #80 gst_capsfilter_sink_event
    at ../subprojects/gstreamer/plugins/elements/gstcapsfilter.c line 521
  • #81 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5715
  • #82 gst_pad_push_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5368
  • #83 push_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3891
  • #84 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 611
  • #85 check_sticky
    at ../subprojects/gstreamer/gst/gstpad.c line 3951
  • #86 gst_pad_push_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5502
  • #87 gst_pad_set_caps
    at ../subprojects/gstreamer/gst/gstcompat.h line 59
  • #88 gst_h264_parse_update_src_caps
    at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c line 1991
  • #89 gst_h264_parse_set_caps
    at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c line 2726
  • #90 gst_base_parse_sink_event_default
    at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c line 1153
  • #91 gst_h264_parse_event
    at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c line 2905
  • #92 gst_pad_send_event_unchecked
    at ../subprojects/gstreamer/gst/gstpad.c line 5715
  • #93 gst_pad_send_event
    at ../subprojects/gstreamer/gst/gstpad.c line 5885
  • #94 send_sticky_event
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 1969
  • #95 foreach_dispatch_function
    at ../subprojects/gstreamer/gst/gstpad.c line 5984
  • #96 events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 611
  • #97 gst_pad_sticky_events_foreach
    at ../subprojects/gstreamer/gst/gstpad.c line 6015
  • #98 send_sticky_events
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 1984
  • #99 connect_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 2506
  • #100 analyze_new_pad
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 1798
  • #101 pad_added_cb
    at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin2.c line 2939
  • #102 ffi_call_unix64
  • #103 ffi_call
  • #104 g_cclosure_marshal_generic
  • #105 g_closure_invoke
  • #106 0x00007ffff6bd8d3e in
  • #107 g_signal_emit_valist
  • #108 g_signal_emit
  • #109 gst_element_add_pad
    at ../subprojects/gstreamer/gst/gstelement.c line 715
  • #110 gst_qtdemux_add_stream
    at ../subprojects/gst-plugins-good/gst/isomp4/qtdemux.c line 8311
  • #111 qtdemux_expose_streams
    at ../subprojects/gst-plugins-good/gst/isomp4/qtdemux.c line 12094
  • #112 gst_qtdemux_loop_state_header
    at ../subprojects/gst-plugins-good/gst/isomp4/qtdemux.c line 4493
  • #113 gst_qtdemux_loop
    at ../subprojects/gst-plugins-good/gst/isomp4/qtdemux.c line 6138
  • #114 gst_task_func
    at ../subprojects/gstreamer/gst/gsttask.c line 332
  • #115 0x00007ffff6e7e7d0 in
  • #116 0x00007ffff6e7de05 in
  • #117 start_thread
    at pthread_create.c line 463
  • #118 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 95

Comment 2 Hyunjun Ko 2018-04-20 08:19:57 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #1)
> Confirmed.
> 
> There's a problem when dmabuf is negotiated. Perhaps we're not resetting
> something properly.
> 
> The crash I got in wayland (weston) is:

Thanks for confirmation.
I have a patch for the crash, and now I'm thinking about the solution for the 2nd problem.

I'm going to propose some patches.
Comment 3 Hyunjun Ko 2018-04-20 08:22:00 UTC
BTW, I guess this is a cause of the issue https://bugs.webkit.org/show_bug.cgi?id=184574

But I'm not sure yet.
Comment 4 Hyunjun Ko 2018-04-23 07:26:19 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #1)
> Confirmed.
> 
> There's a problem when dmabuf is negotiated. Perhaps we're not resetting
> something properly.
> 
> The crash I got in wayland (weston) is:

Weird.
That's different from mine.
Mine is the following:

  • #0 __memmove_avx_unaligned_erms
    at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S line 407
  • #1 memcpy
    at /usr/include/x86_64-linux-gnu/bits/string_fortified.h line 34
  • #2 gen9_render_init
    at gen9_render.c line 1832
  • #3 i965_Init
    at i965_drv_video.c line 7513
  • #4 __vaDriverInit_1_1
    at i965_drv_video.c line 7678
  • #5 va_openDriver
    at va.c line 447
  • #6 vaInitialize
    at va.c line 720
  • #7 vaapi_initialize
    at gstvaapiutils.c line 112
  • #8 gst_vaapi_display_create_unlocked
    at gstvaapidisplay.c line 896
  • #9 gst_vaapi_display_create
    at gstvaapidisplay.c line 909
  • #10 gst_vaapi_display_new
    at gstvaapidisplay.c line 1155
  • #11 gst_vaapi_create_display_from_handle
    at gstvaapipluginutil.c line 126
  • #12 gst_vaapi_create_display_from_gl_context
    at gstvaapipluginutil.c line 200
  • #13 gst_vaapi_ensure_display
    at gstvaapipluginutil.c line 293
  • #14 gst_vaapi_plugin_base_ensure_display
    at gstvaapipluginbase.c line 415
  • #15 gst_vaapipostproc_ensure_display
    at gstvaapipostproc.c line 219
  • #16 gst_vaapipostproc_ensure_filter
    at gstvaapipostproc.c line 228
  • #17 gst_vaapipostproc_start
    at gstvaapipostproc.c line 310
  • #18 gst_base_transform_activate
    at gstbasetransform.c line 2390
  • #19 gst_base_transform_sink_activate_mode
    at gstbasetransform.c line 2456
  • #20 activate_mode_internal
    at gstpad.c line 1224
  • #21 gst_pad_set_active
    at gstpad.c line 1107
  • #22 activate_pads
    at gstelement.c line 3040

Comment 5 Hyunjun Ko 2018-04-24 07:10:36 UTC
Created attachment 371313 [details] [review]
libs: display: avoid VA initialization twice

Since the commit dcf135e2 landed, it tries to initalize VA display
twice in case of creating GstVaapiDisplayEGL.

This is fine on X11 at least but leads to crash in the driver on Wayland.
Comment 6 Víctor Manuel Jáquez Leal 2018-04-24 07:28:59 UTC
(In reply to Hyunjun Ko from comment #5)
> Created attachment 371313 [details] [review] [review]
> libs: display: avoid VA initialization twice
> 
> Since the commit dcf135e2 landed, it tries to initalize VA display
> twice in case of creating GstVaapiDisplayEGL.
> 
> This is fine on X11 at least but leads to crash in the driver on Wayland.

I would rather to resurrect the parenthood logic (and document it). It is clearer than the proposed semantics in this patch.
Comment 7 Hyunjun Ko 2018-04-24 09:36:38 UTC
Created attachment 371315 [details] [review]
RFC: display: egl: fix to create VaapiDisplayEGL with native EGL display and call it when creation

gst_vaapi_display_egl_new_with_native_display has been broken since no
one uses it. 

Currently it needs to call this api to create display with provided EGL 
display so that it could avoid duplicated calls for the native display
(eg. eglTerminate).
Comment 8 Hyunjun Ko 2018-04-24 09:37:55 UTC
The 2nd problems happens because gst-vaapi calls eglTerminate even though the egl display is still used in gst-gl.

I'm requesting comments for the patch so that we could find better solution.
Comment 9 Hyunjun Ko 2018-04-24 09:40:17 UTC
Created attachment 371316 [details] [review]
libs: utils: egl: mark is_wraaped TRUE if the context is wrapped
Comment 10 Víctor Manuel Jáquez Leal 2018-04-24 13:12:44 UTC
Review of attachment 371316 [details] [review]:

lgtm

we should also backport it to 1.14 and 1.12
Comment 11 Víctor Manuel Jáquez Leal 2018-04-24 13:32:03 UTC
Review of attachment 371315 [details] [review]:

::: gst-libs/gst/vaapi/gstvaapidisplay_egl.c
@@ +51,3 @@
   guint display_type;
   guint gles_version;
+  gboolean is_native;

why not just add gpointer egl_display instead of juggling with different semantics in one single variable?

@@ +117,3 @@
 #endif
 #if USE_WAYLAND
+    if (!native_vaapi_display)

we could use params->display_type to choose what vaapi display instantiates, besides the compilation dependencies

::: gst/vaapi/gstvaapipluginutil.c
@@ +211,3 @@
+      GstGLDisplayEGL *egl_display;
+
+      egl_display = gst_gl_display_egl_from_gl_display (gl_display);

why not call here too gst_gl_display_get_handle() thus you could get a common guintptr variable, which could be null by default.

@@ +259,3 @@
+
+  if (gl_display)
+    gst_object_unref (gl_display);

I don't see the reason for this unref since gl_display was unrefed already.
Comment 12 Víctor Manuel Jáquez Leal 2018-04-24 13:32:36 UTC
Review of attachment 371313 [details] [review]:

I'm going to mark this as rejected, because it's just a proof-of-concept.
Comment 13 Hyunjun Ko 2018-04-25 01:10:53 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #6)
> (In reply to Hyunjun Ko from comment #5)
> > Created attachment 371313 [details] [review] [review] [review]
> > libs: display: avoid VA initialization twice
> > 
> > Since the commit dcf135e2 landed, it tries to initalize VA display
> > twice in case of creating GstVaapiDisplayEGL.
> > 
> > This is fine on X11 at least but leads to crash in the driver on Wayland.
> 
> I would rather to resurrect the parenthood logic (and document it). It is
> clearer than the proposed semantics in this patch.

I don't understand what you mean.

The parent thing is related to display-cache, which we removed. See commit ec3e10f.

Which one do you want to resurrect?
Comment 14 Hyunjun Ko 2018-04-25 01:25:25 UTC
Review of attachment 371315 [details] [review]:

::: gst-libs/gst/vaapi/gstvaapidisplay_egl.c
@@ +51,3 @@
   guint display_type;
   guint gles_version;
+  gboolean is_native;

Well, that's what I thought for a while.
Adding another gpointer is fine to me, too.

@@ +118,3 @@
 #if USE_WAYLAND
+    if (!native_vaapi_display)
+      native_vaapi_display = gst_vaapi_display_wayland_new (NULL);

This is not about this patch, isn't it?
Anyway it still needs "#if USE_WAYLAND" since the header is included under the macro.

::: gst/vaapi/gstvaapipluginutil.c
@@ +211,3 @@
+      GstGLDisplayEGL *egl_display;
+
+      egl_display = gst_gl_display_egl_from_gl_display (gl_display);

Ah i didn't realize it. Thanks.

@@ +259,3 @@
+
+  if (gl_display)
+    gst_object_unref (gl_display);

That unref of gl_display is removed in this patch :)
Comment 15 Hyunjun Ko 2018-04-25 02:14:29 UTC
(In reply to Hyunjun Ko from comment #14)
> ::: gst/vaapi/gstvaapipluginutil.c
> @@ +211,3 @@
> +      GstGLDisplayEGL *egl_display;
> +
> +      egl_display = gst_gl_display_egl_from_gl_display (gl_display);
> 
> Ah i didn't realize it. Thanks.
> 

Hmm, Victor, as far as I understand, it has to get GLDisplayEGL so that it retrieve EGLDisplay finally from it.

Could you explain what you mean in detail please?
Comment 16 Víctor Manuel Jáquez Leal 2018-04-25 14:29:34 UTC
Created attachment 371373 [details] [review]
libs: egl: utils: fix usage of GstGL macros

Include gl.h for the required GstGL symbols.
Comment 17 Víctor Manuel Jáquez Leal 2018-04-25 16:01:55 UTC
Created attachment 371389 [details] [review]
libs: egl: utils: fix usage of GstGL macros

Include gl.h for the required GstGL symbols.
Comment 18 Víctor Manuel Jáquez Leal 2018-04-25 16:02:04 UTC
Created attachment 371390 [details] [review]
libs: egl: utils: mark context as wrapped when it is

The returning egl context may be null, so we should check the
return value.
Comment 19 Víctor Manuel Jáquez Leal 2018-04-25 16:02:11 UTC
Created attachment 371391 [details] [review]
meson: fix USE_GLES_VERSION_MASK

1. The macro in the code is USE_GLES_VERSION_MASK
2. glesv3 is provided by glesv2 pkg-config, then it's required to
   check headers
Comment 20 Víctor Manuel Jáquez Leal 2018-04-26 08:55:19 UTC
Attachment 371389 [details] pushed as 9fde93f - libs: egl: utils: fix usage of GstGL macros
Attachment 371390 [details] pushed as 4af46f0 - libs: egl: utils: mark context as wrapped when it is
Attachment 371391 [details] pushed as 785efdb - meson: fix USE_GLES_VERSION_MASK
Comment 21 Víctor Manuel Jáquez Leal 2018-04-26 09:01:02 UTC
branch 1.14

* 56b63720 meson: fix USE_GLES_VERSION_MASK
* 5de03007 libs: egl: utils: mark context as wrapped when it is
* b50e4225 libs: egl: utils: fix usage of GstGL macros
Comment 22 Víctor Manuel Jáquez Leal 2018-04-26 09:06:49 UTC
branch 1.12

* cf67d6d5 meson: fix USE_GLES_VERSION_MASK
* 1660bd0d libs: egl: utils: mark context as wrapped when it is
Comment 23 Víctor Manuel Jáquez Leal 2018-04-26 17:46:54 UTC
Review of attachment 371315 [details] [review]:

By the way, this patch will need to be rebased after bug 793643 is merged

::: gst-libs/gst/vaapi/gstvaapidisplay_egl.c
@@ +118,3 @@
 #if USE_WAYLAND
+    if (!native_vaapi_display)
+      native_vaapi_display = gst_vaapi_display_wayland_new (NULL);

yes, we still need the macro. Just we could create efficiently the internal display by identifying the environment instead of try-and-error
Comment 24 Hyunjun Ko 2018-04-27 07:25:21 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #23)
> Review of attachment 371315 [details] [review] [review]:
> 
> By the way, this patch will need to be rebased after bug 793643 is merged
> 
Okay, I'll be working on it after those patches are merged
Comment 25 Víctor Manuel Jáquez Leal 2018-04-27 16:56:26 UTC
Created attachment 371465 [details] [review]
plugins: handle EGL when creating VAAPI display from gl
Comment 26 Víctor Manuel Jáquez Leal 2018-04-27 16:58:50 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #25)
> Created attachment 371465 [details] [review] [review]
> plugins: handle EGL when creating VAAPI display from gl

I cook this patch to create a EGL VAAPI display when the gl display is EGL. But it brings problems when playing a second video, as those expressed here.
Comment 27 Hyunjun Ko 2018-04-30 09:56:00 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #23)
> Review of attachment 371315 [details] [review] [review]:
> 
> By the way, this patch will need to be rebased after bug 793643 is merged
> 
> ::: gst-libs/gst/vaapi/gstvaapidisplay_egl.c
> @@ +118,3 @@
>  #if USE_WAYLAND
> +    if (!native_vaapi_display)
> +      native_vaapi_display = gst_vaapi_display_wayland_new (NULL);
> 
> yes, we still need the macro. Just we could create efficiently the internal
> display by identifying the environment instead of try-and-error

I see, but in case of GST_VAAPI_DISPLAY_TYPE_EGL, we have to do try-and-error.
Comment 28 Víctor Manuel Jáquez Leal 2018-04-30 10:09:57 UTC
(In reply to Hyunjun Ko from comment #27)
> (In reply to Víctor Manuel Jáquez Leal from comment #23)
> > Review of attachment 371315 [details] [review] [review] [review]:
> > 
> > By the way, this patch will need to be rebased after bug 793643 is merged
> > 
> > ::: gst-libs/gst/vaapi/gstvaapidisplay_egl.c
> > @@ +118,3 @@
> >  #if USE_WAYLAND
> > +    if (!native_vaapi_display)
> > +      native_vaapi_display = gst_vaapi_display_wayland_new (NULL);
> > 
> > yes, we still need the macro. Just we could create efficiently the internal
> > display by identifying the environment instead of try-and-error
> 
> I see, but in case of GST_VAAPI_DISPLAY_TYPE_EGL, we have to do
> try-and-error.

Agree. That's the case with attachment 371465 [details] [review]
Comment 29 Hyunjun Ko 2018-04-30 10:13:32 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #11)
> 
> ::: gst/vaapi/gstvaapipluginutil.c
> @@ +211,3 @@
> +      GstGLDisplayEGL *egl_display;
> +
> +      egl_display = gst_gl_display_egl_from_gl_display (gl_display);
> 
> why not call here too gst_gl_display_get_handle() thus you could get a
> common guintptr variable, which could be null by default.
> 

There are different cases.
If there's a gldisplaywayland in glcontextegl, in this case, we should call gst_gl_display_egl_from_gl_display to retrieve EGLDisplay.
(This is the case that's using gst-play or totem.)

But if gldisplayegl in glcontextegl, we can use just gst_gl_display_get_handle.
(This is the case that's in WebkitGTK.)
Comment 30 Víctor Manuel Jáquez Leal 2018-04-30 13:53:38 UTC
(In reply to Hyunjun Ko from comment #29)
> (In reply to Víctor Manuel Jáquez Leal from comment #11)
> > 
> > ::: gst/vaapi/gstvaapipluginutil.c
> > @@ +211,3 @@
> > +      GstGLDisplayEGL *egl_display;
> > +
> > +      egl_display = gst_gl_display_egl_from_gl_display (gl_display);
> > 
> > why not call here too gst_gl_display_get_handle() thus you could get a
> > common guintptr variable, which could be null by default.
> > 
> 
> There are different cases.
> If there's a gldisplaywayland in glcontextegl, in this case, we should call
> gst_gl_display_egl_from_gl_display to retrieve EGLDisplay.
> (This is the case that's using gst-play or totem.)
> 
> But if gldisplayegl in glcontextegl, we can use just
> gst_gl_display_get_handle.
> (This is the case that's in WebkitGTK.)

You can see my patch in attachment 371465 [details] [review] and use the variable display_type to decide which API call use.
Comment 31 Hyunjun Ko 2018-05-01 01:24:53 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #30)
> (In reply to Hyunjun Ko from comment #29)
> > (In reply to Víctor Manuel Jáquez Leal from comment #11)
> > > 
> > > ::: gst/vaapi/gstvaapipluginutil.c
> > > @@ +211,3 @@
> > > +      GstGLDisplayEGL *egl_display;
> > > +
> > > +      egl_display = gst_gl_display_egl_from_gl_display (gl_display);
> > > 
> > > why not call here too gst_gl_display_get_handle() thus you could get a
> > > common guintptr variable, which could be null by default.
> > > 
> > 
> > There are different cases.
> > If there's a gldisplaywayland in glcontextegl, in this case, we should call
> > gst_gl_display_egl_from_gl_display to retrieve EGLDisplay.
> > (This is the case that's using gst-play or totem.)
> > 
> > But if gldisplayegl in glcontextegl, we can use just
> > gst_gl_display_get_handle.
> > (This is the case that's in WebkitGTK.)
> 
> You can see my patch in attachment 371465 [details] [review] [review] and use the
> variable display_type to decide which API call use.

hmm.. that wouldn't be simple imo.
(just using gst_gl_display_egl_from_gl_display VS using 2 apis by conditional statement)
Comment 32 Víctor Manuel Jáquez Leal 2018-05-08 12:46:24 UTC
Comment on attachment 371315 [details] [review]
RFC: display: egl: fix to create VaapiDisplayEGL with native EGL display and call it when creation

ping?

@hyunjun: what's the status of this patch?
Comment 33 Hyunjun Ko 2018-05-09 03:12:47 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #32)
> Comment on attachment 371315 [details] [review] [review]
> RFC: display: egl: fix to create VaapiDisplayEGL with native EGL display and
> call it when creation
> 
> ping?
> 
> @hyunjun: what's the status of this patch?

I have no plan on this for now.
As we discussed before, it needs refactroing, doesn't it?
If so, you'd better do that than me.
Comment 34 Hyunjun Ko 2018-05-09 03:15:33 UTC
(In reply to Hyunjun Ko from comment #33)
> (In reply to Víctor Manuel Jáquez Leal from comment #32)
> > Comment on attachment 371315 [details] [review] [review] [review]
> > RFC: display: egl: fix to create VaapiDisplayEGL with native EGL display and
> > call it when creation
> > 
> > ping?
> > 
> > @hyunjun: what's the status of this patch?
> 
> I have no plan on this for now.
> As we discussed before, it needs refactroing, doesn't it?
> If so, you'd better do that than me.

Ah you talked about the 2nd patch. Sorry about misunderstanding.
For the second patch, you'd better do that too imo.:)

BTW, the crash still happens as I told you before, we need to focus on it because it's crash.

You couldn't really reproduce the crash any more?
Please 20 times next/prev on gst-play.
Comment 35 Hyunjun Ko 2018-06-01 05:54:27 UTC
Regarding the problem #1, I proposed patches on the bug #796470, which is about a bit of refactoring GstVaapiDisplay.
Comment 36 Hyunjun Ko 2018-06-01 05:59:14 UTC
Created attachment 372503 [details] [review]
display: egl: fix to create VaapiDisplayEGL with native EGL   display

gst_vaapi_display_egl_new_with_native_display has been broken since no
one uses it. 

Currently it needs to call this api to create display with provided EGL 
display so that it could avoid duplicated calls for the native display
(eg. eglTerminate).



-----------------------------------

I rebased on the patches on bug #796470.
Comment 37 Víctor Manuel Jáquez Leal 2018-06-06 15:50:11 UTC
I have pushed these commit in branch 1.14

* fdf7f65c libs: display: resurrect parent private memember
* 55a14e39 libs: display: egl: initialize params structure
* fa54262a plugins: handle EGL when creating VAAPI display from gl
* 67d386d9 display: egl: fix to create VaapiDisplayEGL with native EGL display

@hyunjun commit 67d386d9 is a modified version of yours. Also, I suspect we really need to resurrect the parent member in private structure (commit fdf7f65c), because of the locks to the wrapped vaDisplay.
Comment 38 Víctor Manuel Jáquez Leal 2018-06-06 15:50:39 UTC
Reopen to fix this issue in master
Comment 39 Víctor Manuel Jáquez Leal 2018-06-11 17:39:10 UTC
Created attachment 372637 [details] [review]
display: egl: create VaapiDisplayEGL with native EGL display

gst_vaapi_display_egl_new_with_native_display() has been broken since
it wasn't used.

Currently it's needed to call this API to create a display providing
the EGL display, so it could avoid duplicated calls to the native
display (eg. eglTerminate).

Signed-off-by: Victor Jaquez <vjaquez@igalia.com>
Comment 40 Víctor Manuel Jáquez Leal 2018-06-11 17:39:24 UTC
Created attachment 372638 [details] [review]
plugins: handle EGL when creating VAAPI display from gl
Comment 41 Víctor Manuel Jáquez Leal 2018-06-11 17:39:33 UTC
Created attachment 372639 [details] [review]
libs: display: egl: initialize params structure

Statically initialise the internal params structure.
Comment 42 Víctor Manuel Jáquez Leal 2018-06-11 17:39:40 UTC
Created attachment 372640 [details] [review]
libs: display: resurrect parent private member

This is, practically, a revert of commit dcf135e2.

The parent logic is useful for the EGL display, which is a decorator
of the real windowing subsystem (X11 or Wayland). Thus it is avoided
calling vaInitialize() and vaTerminate() twice.
Comment 43 Víctor Manuel Jáquez Leal 2018-06-12 10:57:03 UTC
Created attachment 372653 [details] [review]
display: egl: create VaapiDisplayEGL with native EGL display

gst_vaapi_display_egl_new_with_native_display() has been broken since
it wasn't used.

Currently it's needed to call this API to create a display providing
the EGL display, so it could avoid duplicated calls to the native
display (eg. eglTerminate).

Signed-off-by: Victor Jaquez <vjaquez@igalia.com>
Comment 44 Víctor Manuel Jáquez Leal 2018-06-12 10:57:15 UTC
Created attachment 372654 [details] [review]
plugins: handle EGL when creating VAAPI display from gl

If GstGL reports a EGL platform force to create a EGL display using
the native EGL display.
Comment 45 Víctor Manuel Jáquez Leal 2018-06-12 10:57:24 UTC
Created attachment 372655 [details] [review]
libs: display: egl: initialize params structure

Statically initialise the internal params structure.
Comment 46 Víctor Manuel Jáquez Leal 2018-06-12 10:57:32 UTC
Created attachment 372656 [details] [review]
libs: display: resurrect parent private member

This is, practically, a revert of commit dcf135e2.

The parent logic is useful for the EGL display, which is a decorator
of the real windowing subsystem (X11 or Wayland). Thus it is avoided
calling vaInitialize() and vaTerminate() twice.
Comment 47 Víctor Manuel Jáquez Leal 2018-06-12 11:07:02 UTC
Attachment 372653 [details] pushed as 50470ae - display: egl: create VaapiDisplayEGL with native EGL display
Attachment 372654 [details] pushed as e62f3d7 - plugins: handle EGL when creating VAAPI display from gl
Attachment 372655 [details] pushed as ad974b4 - libs: display: egl: initialize params structure
Attachment 372656 [details] pushed as b0bebeb - libs: display: resurrect parent private member
Comment 48 Hyunjun Ko 2018-06-14 02:29:56 UTC
I didn't focus on this issue enough recently, sorry.
And thank you for your work with much better patches.