[Bug 1280665] Re: libsdl1.2 always uses backingstore which causes tearing in modern X servers

Bug Watch Updater 1280665 at bugs.launchpad.net
Mon Aug 13 23:07:02 UTC 2018

Launchpad has imported 6 comments from the remote bug at

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at

On 2014-02-04T15:57:21+00:00 Kokoko3k wrote:

SDL_VIDEO_X11_BACKINGSTORE has no effect anymore (since years) , and
having BACKINGSTORE enabled everytime may lead to tearing effect with
newer Xorg servers if composite extension is enabled.

This comment makes me think that there is no point in leaving it in that

#if 0 /* This is an experiment - are the graphics faster now? - nope. */

Reply at:

On 2014-02-20T00:07:02+00:00 Lordmocha wrote:

unset SDL_VIDEO_X11_BACKINGSTORE fixes tearing on intel igpu with xbmc
for me

Reply at:

On 2014-03-04T21:01:08+00:00 7-ajax wrote:

Since I'm the person most nearly responsible for the X side of this
problem, I'll add some background here.

Way back in 2007 (a bit before xserver 1.4) I rewrote X's bs
implementation in terms of some of the Composite extension's internal
machinery; automatic redirection in the Composite sense is equivalent to
core backing store's WhenMapped state, so it made sense to do the one in
terms of the other.  What I didn't do then, though I'd intended to, was
automatically advertise that backing store support if the Composite
extension was enabled; you needed to still explicitly enable it in
xorg.conf for the server to advertise the support.

In 1.15 I finally fixed that up, so now the server claims to support
backing store if the Composite extension is enabled (and it usually is).
This was intended to be a convenience for legacy applications that -
arguably brokenly - require backing store support to work correctly
because they don't bother to implement an Expose handler.

The automatic redirection code, however, is basically just XCopyArea.
It doesn't know what a vblank is, it can't synchronize updates with the
retrace, hence the tearing.  The old pre-1.4 BS code was not any better
in that respect.  The only reason you _might_ want BS is if you're not
running a compositor (hence wouldn't have vsync anyway), and even then
it's a tradeoff, implicit double-buffering on the server side versus
marginally less tearing and possibly not needing a proper Expose
handler.  I can't speak to whether working Expose handlers are common
for SDL apps, but naively I would expect they're not common, that SDL
apps default to being "like fullscreen" and don't expect to repaint
things due to window system events.

So at a bare minimum I would suggest checking whether there's a
compositor running on the screen already, and defaulting BS to off if
there is.  The code to do that is approximately:

    char *s = asprintf("_NET_WM_CM_S%d", screen);
    Atom a = XInternAtom(dpy, s);
    Window w = XGetSelectionOwner(dpy, a);

    if (w) /* compositor running */ ;

If possible I would suggest deferring the decision about BS-or-not to
the point where you know what kind of rendering you're going to do, if
that's a thing you can know.  It's almost never going to be useful for
GL clients.

Reply at:

On 2014-03-05T04:59:40+00:00 Sam Lantinga wrote:

Thanks for the info, that's very useful! :)

Reply at:

On 2014-03-05T05:06:07+00:00 Sam Lantinga wrote:

We don't have a release of SDL 1.2 planned, and Ryan is actively working
on a binary compatible 1.2 API built on top of SDL 2.0, which doesn't
have this problem.

I'm assigning this bug to Ryan just so he sees it and can update it when
the 1.2 API on top of SDL 2.0 is available.

Reply at:

On 2018-08-13T07:21:32+00:00 illume wrote:

Arch Linux patches SDL for this issue here:

Reply at:

** Changed in: libsdl
       Status: Unknown => Won't Fix

** Changed in: libsdl
   Importance: Unknown => Medium

You received this bug notification because you are a member of Ubuntu
Sponsors Team, which is subscribed to the bug report.

  libsdl1.2 always uses backingstore which causes tearing in modern X

Status in libsdl:
  Won't Fix
Status in libsdl1.2 package in Ubuntu:
  Fix Released
Status in libsdl1.2 source package in Trusty:
  Fix Released

Bug description:
  Tearing in SDL applications regardless of vsync setting.

  [Test Case]
  Use eg. XBMC to play any video, or a particular video that more easily shows up the tearing of the images.

  [Regression Potential]
  This is a regression fix in itself, and restores old behavior.


  Fedora 21 has a similar patch applied

  libsdl1.2 always enables backingstore when it is present in the X
  server. For modern X servers, backingstore is implemented by
  redirecting through the composite extension. This causes tearing on
  SDL applications such as xbmc because the redirected rendering is not
  guaranteed to be synchronized.

  A discussion of the problem by Nvidia is here:

  The upstream bug is here:

  I have a patch that restores a check for the
  SDL_VIDEO_X11_BACKINGSTORE environment variable before trying to
  enable backingstore.

To manage notifications about this bug go to:

More information about the Ubuntu-sponsors mailing list