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 792693 - decodebin3: high cpu usage after eos
decodebin3: high cpu usage after eos
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-01-19 17:56 UTC by fengalin
Modified: 2018-02-10 13:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch: avoid looping on final eos event (2.20 KB, patch)
2018-01-19 17:56 UTC, fengalin
none Details | Review
Patch: avoid looping on final eos event (fix author name) (2.23 KB, patch)
2018-01-29 22:01 UTC, fengalin
committed Details | Review

Description fengalin 2018-01-19 17:56:09 UTC
Created attachment 367094 [details] [review]
Patch: avoid looping on final eos event

After eos, decodebin3 enters a loop sending eos events which causes high cpu usage.

Here is a description of the problem:

- decodebin3-parse, parse_chain_output_probe
    (last src pad of the parse chain for an input stream):
  When an eos event is received for current input stream:
    if all input streams are eos:
(A)   send a "regular" eos event to each multiqueue sink pads
    else:
(B)   send a "decodebin3-custom-eos" eos event
      to current slot's multiqueue sink pad
    drop current eos event

- decodebin3, multiqueue_src_probe (multiqueue sink pad for an input stream)
  When an eos event is received from the parse chain for current input stream:
    if the eos event is a "decodebin3-custom-eos": (coming from (B))
      if all input and output streams are eos:
(D)     send a stream-start and then a "regular" eos event
        to each multiqueue sink pads
      drop current eos event
    else: ("regular" eos, coming from (A)... or from (D) or (E)!)
     if all inputs stream and output streams are eos:
(E)     send a stream-start and then a "regular" eos event
        to each multiqueue sink pads

The issue happens when we reach (D) or (E) as a "regular" eos event is sent back to the multiqueue sink pads which will lead to another (E), etc.

Since reaching a proper sequence is tricky (1), I tried to come up with a solution with as little impact as possible. What I did was marking the eos event from (D) and (E) as "decodebin3-custom-final-eos", so that we can differentiate it from the eos event coming from (A) and avoid doing (E) again and again.

The way the bin is designed, eos events are propagated downstream after all input and output streams are eos. Actually, the stream which initiated (E) let its eos event received from (A) propagate, then it would also let the eos event from (E) propagate. Not only an eos event could be sent twice (and more since we were looping on (E)) but also, it wasn't consistent with the same situation initiated from (D). For consistency among all streams, I decided to drop the event received from (A) and let the event received from (E) propagate. I hope the fact that it is marked as "decodebin3-custom-final-eos" won't impact downstream.

---

(1) https://bugzilla.gnome.org/show_bug.cgi?id=785951
Comment 1 Tim-Philipp Müller 2018-01-29 21:24:01 UTC
Thanks for the patch!

Could you please attach a patch that has your proper name as author?
Comment 2 fengalin 2018-01-29 22:01:41 UTC
Created attachment 367612 [details] [review]
Patch: avoid looping on final eos event (fix author name)

Fixed, sorry about that!
Comment 3 Edward Hervey 2018-02-10 13:23:14 UTC
Nice one ! Thanks for that.

commit ec7d81f67c844f692113d756db2bd328f92bd554 (HEAD -> master, origin/master, origin/HEAD)
Author: François Laignel <fengalin@free.fr>
Date:   Fri Jan 19 18:40:53 2018 +0100

    decodebin3: high cpu usage after eos
    
    After eos, decodebin3 enters a loop sending eos events which causes high cpu usage.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792693