Totem pauses and stutters during video playback even when CPU usage is low

Bug #1698270 reported by Daniel van Vugt on 2017-06-16
154
This bug affects 27 people
Affects Status Importance Assigned to Milestone
GStreamer
Expired
Medium
GTK+
Fix Released
Medium
totem-pl-parser
Expired
Medium
clutter-1.0 (Ubuntu)
Undecided
Daniel van Vugt
clutter-gst-3.0 (Ubuntu)
Undecided
Daniel van Vugt
clutter-gtk (Ubuntu)
Medium
Daniel van Vugt
gstreamer-vaapi (Ubuntu)
Medium
Daniel van Vugt
gtk+3.0 (Ubuntu)
Medium
Daniel van Vugt
totem-pl-parser (Ubuntu)
High
Daniel van Vugt

Bug Description

Totem pauses and stutters during video playback even when CPU usage is low.

After figuring out how to play videos with full hardware accelerated decoding (e.g. <= 10% CPU), I was surprised to find Totem still pauses and stutters during playback. Other apps like Mplayer, VLC and even gst-play-1.0 never have this problem.

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: totem 3.24.0-0ubuntu1
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:03:18 2017
InstallationDate: Installed on 2017-05-03 (44 days ago)
InstallationMedia: Ubuntu 17.10 "Artful Aardvark" - Alpha amd64 (20170502)
SourcePackage: totem
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Daniel van Vugt (vanvugt) wrote :
Daniel van Vugt (vanvugt) wrote :

The issue seems to persist regardless of which shell / desktop environment I use.

Daniel van Vugt (vanvugt) wrote :

Workaround: Use 'gst-play-1.0' instead of 'totem'. It avoids the rendering glitches and has much lower CPU usage.

Changed in totem:
importance: Unknown → High
status: Unknown → Incomplete
Launchpad Janitor (janitor) wrote :

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

Changed in totem (Ubuntu):
status: New → Confirmed

This happens in full-screen mode for a window with client-side decorations using OpenGL. Another workaround is to use GNOME MPV without CSD or without OpenGL: https://bugzilla.gnome.org/show_bug.cgi?id=778766#c2

Re comment #2: With GNOME MPV, it doesn't happen on KDE Plasma for me even if both CSD and OpenGL are enabled.

description: updated
Amr Ibrahim (amribrahim1987) wrote :

I have this bug also in 3.18.1-1ubuntu4 in Xenial.

tags: added: xenial
Daniel van Vugt (vanvugt) wrote :

First experimental fix: https://git.launchpad.net/~vanvugt/ubuntu/+source/totem/commit/?id=02076c41f892e214d946457f944c6da3011307f1

Although I suspect we are linked to the wrong upstream bug so I won't mention it there.

Changed in totem (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
status: Confirmed → In Progress
Changed in clutter-1.0 (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
Changed in totem (Ubuntu):
importance: Undecided → High
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
Amr Ibrahim (amribrahim1987) wrote :

Does the fix apply in Xenial?

Daniel van Vugt (vanvugt) wrote :

I don't see why not. Let's just wait until upstream has accepted the fix and I'll be more confident about applying the same to xenial.

Daniel van Vugt (vanvugt) wrote :

OK, I have now encountered a few reasons for totem stuttering...

1. Excessive/faulty tags parsing (only seen in Big Buck Bunny videos?). Upstream has fixed the root cause:
  https://bugzilla.gnome.org/show_bug.cgi?id=786561
but we have also patched totem itself in Ubuntu to avoid the issue:
  https://launchpad.net/ubuntu/+source/totem/3.25.90.1-0ubuntu2

2. Excessive CPU usage of clutter-gtk particularly under Wayland -> bug 1698282

3. Insufficient buffering/parallelism in GStreamer. BBB tends to have a big stutter when the video bitrate spikes over 11Mbps. I'm not aware of any other reports of the problem though.

4. My experimental fixes for the high CPU usage of clutter-gtk in bug 1698282 reintroduces an old smoothness problem that only occurs under the default setting of CLUTTER_BACKEND=gdk (but not with CLUTTER_BACKEND=wayland or x11). I'll try to fix that somewhere between bug 1698282 and this one.

Changed in gstreamer (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Changed in gtk+3.0 (Ubuntu):
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Daniel van Vugt (vanvugt)
Daniel van Vugt (vanvugt) wrote :

Smoothness issue 4 above I have tracked down to this clutter-gtk code:

-------------------------
static void
clutter_master_clock_gdk_update (GdkFrameClock *frame_clock,
                                 ClutterMasterClockGdk *master_clock)
{
  GList *stages, *l;

  _clutter_threads_acquire_lock ();

  /* Get the time to use for this frame */
  master_clock->cur_tick = gdk_frame_clock_get_frame_time (frame_clock);
-------------------------

The problem is not in clutter-gtk though. It's a general lack of precision in the GdkFrameClock logic. Despite my monitor running at around 60Hz, the GDK frame_time interval is erratic and mostly varies between 17 and 18 milliseconds. So the root cause is just poor timing logic in GDK.

I have an experimental fix already for gdk so probably don't need to propose changes to clutter-gtk any more.

Daniel van Vugt (vanvugt) wrote :

Sorry, in comment #12 I mean "clutter" (in its gdk subdir), not "clutter-gtk".

Changed in clutter-1.0 (Ubuntu):
status: New → Won't Fix
Changed in clutter-gtk (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
importance: Undecided → Medium
status: New → In Progress
Changed in gtk:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in gstreamer (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
status: Triaged → In Progress
Changed in gstreamer (Ubuntu):
status: In Progress → New
Changed in gstreamer (Ubuntu):
status: New → In Progress
Daniel van Vugt (vanvugt) wrote :

Now looking into issue 3 from comment #11 again.

Every time the big stutter occurs it coincides with my PC's harddisk LED. Also, the same place in the video seems to be the first time the stream bitrate peaks over 10Mbps. So there seems to be some kind of cause and effect at this particularly detailed part of the video.

The stutter only occurs in totem though. No other gstreamer tool seems to exhibit the problem when playing the same video. Even using "gst-launch-1.0 playbin uri=file:///...." seems to not have the problem. So all evidence at the moment is suggesting the biggest stutter is somehow specific to the totem binary, and not gstreamer in general.

I've also just noticed a 5th source of stuttering; that is using clutterautovideosink in an X11 session. Will ignore that problem for now...

Changed in totem (Ubuntu):
status: Fix Released → In Progress
Daniel van Vugt (vanvugt) wrote :

The part relevant to clutter-gtk is now released with bug 1698282. Although that doesn't contribute much to the visible stuttering for me, it could in theory for some systems.

Changed in clutter-gtk (Ubuntu):
status: In Progress → Fix Released
no longer affects: gstreamer (Ubuntu)
Changed in totem (Ubuntu):
status: In Progress → New
assignee: Daniel van Vugt (vanvugt) → nobody
status: New → Confirmed
Changed in clutter-1.0 (Ubuntu):
status: Won't Fix → In Progress
Changed in clutter-1.0 (Ubuntu):
status: In Progress → Won't Fix
Daniel van Vugt (vanvugt) wrote :

Some simple system monitoring:
  cat /proc/`pidof totem`/io
reveals totem's biggest skip coincides with a disk _write_ of some sort.

That should be easy to track down but I'm just about out of time this week.

Changed in totem (Ubuntu):
status: Confirmed → In Progress
assignee: nobody → Daniel van Vugt (vanvugt)
Daniel van Vugt (vanvugt) wrote :
Changed in totem:
importance: High → Unknown
status: Incomplete → Unknown
Changed in totem:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in totem:
status: Confirmed → Invalid
no longer affects: totem
Changed in totem:
importance: Unknown → Medium
status: Unknown → Confirmed
Daniel van Vugt (vanvugt) wrote :

A fix for bionic.

Changed in totem-pl-parser (Ubuntu):
assignee: nobody → Daniel van Vugt (vanvugt)
importance: Undecided → High
status: New → In Progress
affects: totem → totem-pl-parser
no longer affects: totem (Ubuntu)

The attachment "totem-pl-parser_3.26.0-1ubuntu2.debdiff" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package totem-pl-parser - 3.26.0-1ubuntu2

---------------
totem-pl-parser (3.26.0-1ubuntu2) bionic; urgency=medium

  * totem-pl-parser-xspf.c: Avoid large stutters in video playback due to
    heavy (and unnecessary) disk syncing (LP: #1698270)

 -- Daniel van Vugt <email address hidden> Tue, 31 Oct 2017 17:07:46 +0800

Changed in totem-pl-parser (Ubuntu):
status: In Progress → Fix Released
Changed in gtk:
status: Confirmed → Fix Released
Daniel van Vugt (vanvugt) wrote :

I suspect there's another issue specific to Xorg that's causing stutter there, and not yet resolved. Although you won't see it till bug 1747744 is fixed :)

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gtk+3.0 - 3.22.28-1ubuntu1

---------------
gtk+3.0 (3.22.28-1ubuntu1) bionic; urgency=medium

  * Merge with Debian. Remaining changes:
    + Install a settings.ini file to set our themes
    + Enable Mir backend
    + Update debian/libgtk-3-0.symbols
    + debian/control.in:
      - Build-depend on adwaita-icon-theme-full for icon name check test
    + debian/rules: Mark additional known test failures:
      - box-shadow-changes-modify-clip.ui
      - label-text-shadow-changes-modify-clip.ui
    + Ubuntu-specific patches:
      - 073_treeview_almost_fixed.patch
      - bzg_gtkcellrenderer_grabbing_modifier.patch
      - ubuntu_gtk_custom_menu_items.patch
      - print-dialog-show-options-of-remote-dnssd-printers.patch
      - uimanager-guard-against-nested-node-updates.patch
      - x-canonical-accel.patch
      - message-dialog-restore-traditional-look-on-unity.patch
      - 0001-gtk-reftest-Force-icon-theme-to-Adwaita.patch
      - restore_filechooser_typeaheadfind.patch
      - 0001-calendar-always-emit-day-selected-once.patch
      - 0001-gtkwindow-set-transparent-background-color.patch
      - ubuntu_fileselector_behaviour.patch
      - unity-border-radius.patch
      - unity-headerbar-maximized-mode.patch
      - gtksocket-unscale-before-sending-configurenotify.patch
      - no_content_hub.patch

gtk+3.0 (3.22.28-1) unstable; urgency=medium

  * New upstream release (LP: #1698270) (LP: #1714518)
  * Update Vcs fields for conversion to git
  * Add debian/gbp.conf
  * Bump Standards-Version to 4.1.3
  * Update Vcs fields for migration to https://salsa.debian.org/
  * Drop git_text-view-support-emoji-chooser.patch: Applied in new release

 -- Jeremy Bicha <email address hidden> Thu, 15 Feb 2018 10:15:34 -0500

Changed in gtk+3.0 (Ubuntu):
status: In Progress → Fix Released
Daniel van Vugt (vanvugt) wrote :

This issue is still not fixed for Xorg. Not sure what package to target though...

Changed in totem (Ubuntu):
status: New → Confirmed
Daniel van Vugt (vanvugt) wrote :

I'm really not sure what changed to make 4K video so stuttery now in totem. The CPU is fairly low and goes through the roof only if I uninstall VAAPI. So VAAPI is working, and it works smoothly in mpv too.

Since I could last play 4K smoothly in totem there has been:
  * A mesa update 17.2 -> 18.0
  * A Xorg update 1.19.5 -> 1.19.6
  * Kernel updates
  * Hardware changes (I changed from a Haswell to Kaby Lake desktop)

Amr Ibrahim (amribrahim1987) wrote :

I am also having stutter videos in Totem in Bionic. I am using old hardware from 2011. I am ready to give more debugging info when needed.

Changed in gstreamer:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in gstreamer-vaapi (Ubuntu):
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Daniel van Vugt (vanvugt)
no longer affects: totem (Ubuntu)
Daniel van Vugt (vanvugt) wrote :

Maybe this is a better upstream bug:
https://bugzilla.gnome.org/show_bug.cgi?id=795325

Changed in gstreamer:
importance: Medium → Unknown
status: Confirmed → Unknown
Changed in gstreamer:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in gstreamer-vaapi (Ubuntu):
status: In Progress → Confirmed
Changed in gstreamer-vaapi (Ubuntu):
status: Confirmed → In Progress
Changed in clutter-gst-3.0 (Ubuntu):
status: New → In Progress
assignee: nobody → Daniel van Vugt (vanvugt)
Changed in clutter-gst-3.0 (Ubuntu):
status: In Progress → Incomplete
Changed in gstreamer-vaapi (Ubuntu):
status: In Progress → Incomplete
Changed in totem-pl-parser:
status: Confirmed → Expired
Changed in clutter-1.0 (Ubuntu):
status: Won't Fix → New
Launchpad Janitor (janitor) wrote :

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

Changed in clutter-1.0 (Ubuntu):
status: New → Confirmed
Sergei (markovs-i-mail) wrote :

After gnome-twitch flatpak update (and some other "core" flatpak packages update) now I have same lags in gnome-twitch.
The bug comes from gnome. Just like most of bugs in Ubuntu and other distros.

Changed in gstreamer:
status: Confirmed → Expired

I encounter probably the same bug in 18.04 and in 18.10.

I've opened a separate bug report because it might not be the exact issue:
https://bugs.launchpad.net/ubuntu/+source/gstreamer1.0/+bug/1818382

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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