Totem uses dramatically higher CPU than any other video player

Bug #1698282 reported by Daniel van Vugt
54
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Clutter GStreamer Bindings
Confirmed
Medium
Clutter GTK
Confirmed
Medium
Gstreamer1.0
Fix Released
Medium
Libva
New
Unknown
clutter-gst-3.0 (Ubuntu)
Confirmed
Medium
Unassigned
clutter-gtk (Ubuntu)
Fix Released
High
Daniel van Vugt
gstreamer1.0 (Ubuntu)
Fix Released
Medium
Unassigned
intel-vaapi-driver (Ubuntu)
Confirmed
Undecided
Unassigned
totem (Ubuntu)
Fix Released
Medium
Daniel van Vugt

Bug Description

Totem uses dramatically higher CPU than any other video player.

Example 1: software playback under Gnome Shell Wayland:

totem: 120% (but drops to 80% in Unity7)
mplayer: 40%
vlc: 40%
[all are using ffmpeg for decoding]

Example 2: hardware-accelerated playback under Gnome Shell Xorg:

totem: 11%
gst-play-1.0: 3%
[both are using gstreamer-vaapi for decoding]

Since the decoding libraries are theoretically the same it sounds like totem's performance problems might be in its rendering path.

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: libgstreamer1.0-0 1.12.0-2
ProcVersionSignature: Ubuntu 4.10.0-22.24-generic 4.10.15
Uname: Linux 4.10.0-22-generic x86_64
ApportVersion: 2.20.5-0ubuntu4
Architecture: amd64
Date: Fri Jun 16 12:57:11 2017
InstallationDate: Installed on 2017-05-03 (44 days ago)
InstallationMedia: Ubuntu 17.10 "Artful Aardvark" - Alpha amd64 (20170502)
LogAlsaMixer: Error: command ['/usr/bin/amixer'] failed with exit code 1: amixer: Mixer attach default error: No such file or directory
SourcePackage: gstreamer1.0
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
affects: gstreamer1.0 (Ubuntu) → totem (Ubuntu)
Changed in totem:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in totem (Ubuntu):
status: New → Confirmed
Changed in totem:
status: Confirmed → Expired
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Confirmed the problem is the gstreamer-clutter plugin (which only totem seems to use by default). You can see the same problem here:

High CPU:
gst-launch-1.0 filesrc location=bbb_sunflower_1080p_60fps_normal.mp4 ! qtdemux ! vaapidecodebin ! clutterautovideosink

Low CPU:
gst-launch-1.0 filesrc location=bbb_sunflower_1080p_60fps_normal.mp4 ! qtdemux ! vaapidecodebin ! glimagesink

affects: totem (Ubuntu) → clutter-gst-3.0 (Ubuntu)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Actually about 25-30% of the problem is still totem-specific. The rest is common to other users of clutterautovideosink like:
  gst-play-1.0 --videosink=clutterautovideosink ...

Changed in totem (Ubuntu):
status: New → Triaged
importance: Undecided → High
assignee: nobody → Daniel van Vugt (vanvugt)
status: Triaged → In Progress
Changed in totem:
importance: Medium → Unknown
status: Expired → Unknown
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in clutter-1.0 (Ubuntu):
status: New → Confirmed
Changed in totem:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in clutter-1.0 (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
Changed in clutter-gst-3.0 (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package totem - 3.25.90.1-0ubuntu2

---------------
totem (3.25.90.1-0ubuntu2) artful; urgency=medium

  * debian/patches/fix-bvw_update_tags-performance.patch:
    - bacon-video-widget.c: Reduce CPU usage and visible stuttering
      (LP: #1698282 and LP: #1698270).

 -- Daniel van Vugt <email address hidden> Mon, 21 Aug 2017 16:10:19 +0800

Changed in totem (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Amr Ibrahim (amribrahim1987) wrote :

Does the fix apply in Xenial?

Changed in totem (Ubuntu):
importance: High → Medium
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Debug log requested by upstream: https://bugzilla.gnome.org/show_bug.cgi?id=786561

Changed in totem:
status: Confirmed → Fix Released
affects: totem → gstreamer1.0
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Upstream bug https://bugzilla.gnome.org/show_bug.cgi?id=786561 was initially, and still is, for totem too. The main totem patch is there.

Changed in totem:
importance: Unknown → Medium
status: Unknown → Fix Released
Changed in clutter-gtk (Ubuntu):
status: New → Confirmed
status: Confirmed → In Progress
assignee: nobody → Daniel van Vugt (vanvugt)
importance: Undecided → High
no longer affects: totem
Changed in clutter-gtk:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Another prototype fix done, this one more likely to be accepted upstream:
https://git.launchpad.net/~vanvugt/ubuntu/+source/clutter-gtk/commit/?id=eef8eb07e2516d08a984f8128a308943de0d0902

but not until I figure out the smoothness issue separately (visible in gnome-maps panning at least).

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Debdiff for artful to fix the majority of the problem.

Revision history for this message
Jeremy Bícha (jbicha) wrote :

I've uploaded the clutter-gtk fix to Debian and to Ubuntu's queue. I'm unsubscribing ubuntu-sponsors. Feel free to re-subscribe if you have something else that needs sponsoring.

Changed in clutter-gtk (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package clutter-gtk - 1.8.4-2

---------------
clutter-gtk (1.8.4-2) unstable; urgency=medium

  [ Daniel van Vugt ]
  * Fix high CPU usage (particularly in Wayland sessions) when clutter redraws.
    Hardware redraws of the clutter stage were unexpectedly triggering software
    redraws of the backing window and its decorations. On _every_ frame.
    This halves the CPU usage of totem and gnome-maps. (LP: #1698282)

 -- Jeremy Bicha <email address hidden> Mon, 09 Oct 2017 21:50:47 -0400

Changed in clutter-gtk (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This gstreamer fix is also in Ubuntu, and is the intended replacement for my totem patch (no longer required):

commit 39e21bb6dd79e467ff747ab93b19078f03d03646
Author: Tim-Philipp Müller <email address hidden>
Date: Thu Aug 24 16:00:42 2017 +0100

    baseparse: fix taglist update spam

Changed in gstreamer1.0 (Ubuntu):
importance: Undecided → Medium
status: New → Fix Released
no longer affects: clutter-1.0 (Ubuntu)
Changed in clutter-gst-3.0 (Ubuntu):
assignee: Daniel van Vugt (vanvugt) → nobody
importance: Undecided → Medium
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It appears we've reached a milestone today: totem's CPU usage is no longer significantly higher than gst-play-1.0 --videosink=clutterautovideosink (or glimagesink)

If you compare it to mpv though, totem is 2-3 times heavier still. However profiling totem and gst-play-1.0 today seems to suggest that is due to:
  (a) Lack of DMA-buf support in clutter-gst (https://bugzilla.gnome.org/show_bug.cgi?id=759209)
  (b) General complexity of GStreamer

I think the remaining piece here is to get (a) fixed. However before that will ever work for us, apparently gstreamer-vaapi needs additional fixing so that it does not conflict with the patch we're using for Ubuntu right now: https://bugzilla.gnome.org/show_bug.cgi?id=784369#c12

It sounds like this remaining piece (a) is in progress with upstream. And (b) doesn't look as significant or like a realistically solvable problem any time soon. So I think I'm done here, unless I can help upstream with (a)...

Changed in clutter-gst:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Upstream bug (possibly related) attached:
https://github.com/intel/intel-vaapi-driver/issues/379

Changed in libva:
status: Unknown → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in intel-vaapi-driver (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.