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 793412 - msdk: session close failure if there are multiple sessions in a pipeline
msdk: session close failure if there are multiple sessions in a pipeline
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.13.91
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 789886
 
 
Reported: 2018-02-13 07:44 UTC by Hyunjun Ko
Modified: 2018-03-08 19:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
msdk: manage child sessions on parent GstMsdkContext (2.08 KB, patch)
2018-02-23 06:31 UTC, Hyunjun Ko
none Details | Review
msdk: manage child sessions on parent GstMsdkContext (2.25 KB, patch)
2018-03-07 10:47 UTC, Hyunjun Ko
committed Details | Review

Description Hyunjun Ko 2018-02-13 07:44:30 UTC
Reproduce step:
gst-launch-1.0 filesrc location=video.mp4 ! qtdemux ! h264parse ! msdkh264dec ! msdkh264enc ! msdkh264dec ! fakesink

When this pipeline finishes playing(or press Ctrl-C), one of SessionClose fails.
Make sure that child sessions are closed before closing a parent session.
Comment 1 Hyunjun Ko 2018-02-23 06:31:18 UTC
Created attachment 368816 [details] [review]
msdk: manage child sessions on parent GstMsdkContext

Sometimes parent context is released before its children get released.
In this case MFXClose of parent session fails.

To make sure that child sessions are closed before closing a parent session,
Parent context needs to manage child sessions and close them first when it's released.

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

Note that this patch is based on patches in bug #793413
Comment 2 sreerenj 2018-02-24 00:03:22 UTC
Review of attachment 368816 [details] [review]:

::: sys/msdk/gstmsdkcontext.c
@@ +216,3 @@
+{
+  mfxSession _session = session;
+  MFXDisjoinSession (_session);

Ideally, it should make sure there is no active task.
According to spec, if this API returns MFX_WRN_IN_EXECUTION:
"Active tasks are in execution or in queue. Wait for
the completion of the tasks and then call this
function again."

@@ +292,3 @@
   priv->job_type = parent_priv->job_type;
+  parent_priv->child_session_list =
+      g_list_append (parent_priv->child_session_list, priv->session);

It is recommended to use g_list_prepend whenever possible.
https://developer.gnome.org/glib/stable/glib-Doubly-Linked-Lists.html#g-list-append
Comment 3 Víctor Manuel Jáquez Leal 2018-02-26 20:48:37 UTC
(In reply to sreerenj from comment #2)
> Review of attachment 368816 [details] [review] [review]:
> 
> ::: sys/msdk/gstmsdkcontext.c
> @@ +216,3 @@
> +{
> +  mfxSession _session = session;
> +  MFXDisjoinSession (_session);
> 
> Ideally, it should make sure there is no active task.
> According to spec, if this API returns MFX_WRN_IN_EXECUTION:
> "Active tasks are in execution or in queue. Wait for
> the completion of the tasks and then call this
> function again."

Would that lead to a deadlock?

As the list is iterated sequentially, perhaps the dependency chain might not follow the sequence and we would wait for a task forever.

> 
> @@ +292,3 @@
>    priv->job_type = parent_priv->job_type;
> +  parent_priv->child_session_list =
> +      g_list_append (parent_priv->child_session_list, priv->session);
> 
> It is recommended to use g_list_prepend whenever possible.
> https://developer.gnome.org/glib/stable/glib-Doubly-Linked-Lists.html#g-list-
> append
Comment 4 Hyunjun Ko 2018-03-01 08:17:35 UTC
(In reply to sreerenj from comment #2)
> Review of attachment 368816 [details] [review] [review]:
> 
> ::: sys/msdk/gstmsdkcontext.c
> @@ +216,3 @@
> +{
> +  mfxSession _session = session;
> +  MFXDisjoinSession (_session);
> 
> Ideally, it should make sure there is no active task.
> According to spec, if this API returns MFX_WRN_IN_EXECUTION:
> "Active tasks are in execution or in queue. Wait for
> the completion of the tasks and then call this
> function again."
> 

I've read it on the document, but feels that it could be risky as Victor said.
Do you really want to handle the MFX_WRN_IN_EXECUTION?
If so, I have to think again from the scratch for this issue, because current patch is not good for doing that.
Comment 5 sreerenj 2018-03-01 22:10:01 UTC
I think at least it should throw some warning so that we can see whether the pipeline is hitting this issue. How about filing a separate bug so that we can track it after 1.14 release?
Comment 6 Hyunjun Ko 2018-03-02 05:04:42 UTC
(In reply to sreerenj from comment #5)
> I think at least it should throw some warning so that we can see whether the
> pipeline is hitting this issue. How about filing a separate bug so that we
> can track it after 1.14 release?

Good.
Comment 7 Hyunjun Ko 2018-03-07 10:47:15 UTC
Created attachment 369403 [details] [review]
msdk: manage child sessions on parent GstMsdkContext

Sometimes parent context is released before its children get released.
In this case MFXClose of parent session fails.

To make sure that child sessions are closed before closing a parent session,
Parent context needs to manage child sessions and close them first when it's released.

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

rebased.
Comment 8 sreerenj 2018-03-08 19:42:03 UTC
Review of attachment 369403 [details] [review]:

Pushed as commit c9faf0d612d7e73fbca16f1c227b181d851c5ae9