evince and okular do not render eps files correctly resulting in a black background

Bug #1348384 reported by John B.
102
This bug affects 17 people
Affects Status Importance Assigned to Milestone
libspectre (Ubuntu)
High
Unassigned
Trusty
Critical
Unassigned

Bug Description

Impact
======
This Ubuntu 14.04 SRU caused a regression where some .eps files have a black background that makes it almost impossible to see the original content.

https://launchpad.net/ubuntu/+source/libspectre/0.2.7-2ubuntu1.1

This was fixed in Ubuntu 15.04 and newer releases but was not fixed in 14.04 until now.

Test Case
=========
Use Ubuntu's default eps viewer (evince) to open these two test files.

https://bugs.launchpad.net/ubuntu/+source/libspectre/+bug/1348384/+attachment/4171120/+files/countrate.eps

https://bugs.launchpad.net/ubuntu/+source/libspectre/+bug/1242678/+attachment/3886169/+files/test.eps

Rotate test.eps 4 times to ensure that the file still displays correctly when rotated. countrate.eps should not have a black background.

Other Info
==========
Instead of using the fix from 15.04, 16.04 and 16.10, I chose to use the upstream's version of fix-document-rotation.patch included in 0.2.8 and in 17.04. (fix-document-rotation.patch was the only change made in the original SRU)

https://cgit.freedesktop.org/libspectre/commit/?id=38bb113d

Regression Potential
====================
Low. This fix is now in upstream's 0.2.8 and is in Debian and Ubuntu 17.04.

By the way, the 17.04 fix was briefly broken by a ghostscript security fix but the 16.04/16.10 fix was not affected. For more details about that, see bug 1647917.

Original Bug Report
===================
Several eps files, which previously rendered correctly, are not rendered correctly by evince and okular. It looks as though something is wrong with the "transparency" setting, since most of the incorrectly-rendered files have a black background, but the figure can somewhat be made out on top of hte black background. The PDF files I have tested are NOT affected. EPS files that were previously viewable correctly ARE affected.

Thank you for your time.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: evince 3.10.3-0ubuntu10.1
ProcVersionSignature: Ubuntu 3.13.0-32.57-generic 3.13.11.4
Uname: Linux 3.13.0-32-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.2
Architecture: amd64
CurrentDesktop: Unity
Date: Thu Jul 24 16:54:06 2014
ProcEnviron:
 LANGUAGE=en_US
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: evince
UpgradeStatus: Upgraded to trusty on 2014-06-03 (51 days ago)

Revision history for this message
John B. (jbuncher) wrote :
Revision history for this message
Xin Meng (mengxin008) wrote :

I have the same problem in my machine.

Revision history for this message
Christopher Mendillo (chris-mendillo) wrote :

I am experiencing what appears to be the same problem. Just upgraded to 14.04 from 12.04, all of my eps files now have black backgrounds when viewed with evince. I've attached an example eps file.

The file displays normally with ghostview.

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in evince (Ubuntu):
status: New → Confirmed
Revision history for this message
Christopher Mendillo (chris-mendillo) wrote :

The source of this problem is contained within the libspectre1 library. This is the evince postscript backend. Between precise and trusty, libspectre1 was upgraded from 0.2.6-1build1 to 0.2.7-2ubuntu1.1. I downloaded and installed the previous version from the precise archive and eps files now render correctly in envice and the thumbnails are correct, too.

Update manager, of course, now wants to update me back to 0.2.7.

Revision history for this message
John B. (jbuncher) wrote :

Chris,

Is there a previous version of libspectre1 from the trusty repository? I've been running 14.04 on this machine, and feel like this is a recent development.

I will mention that 13.10 did not have this issue either, so the regression likely happened between the last version supplied to 13.10 and the current version in 14.04.

Revision history for this message
Christopher Mendillo (chris-mendillo) wrote :

Hi John,

You can download the old package from ubuntu: http://packages.ubuntu.com/precise/libspectre1

Install with : sudo dpkg -i libspectre1_0.2.6-1build1_amd64.deb

Do not try and remove the newer 0.2.7 package before you install this one, that would require you to remove a ton of stuff to satisfy dependencies.

After installing, you can go into synaptic package manager, search for libspectre1, click on it, then select Package->Lock Version from the menu. That will keep it from trying to update to the new version.

Just a workaround until the problem gets fixed, but I hope it helps.

Revision history for this message
John B. (jbuncher) wrote :

I just checked, and the prior version of libspectre (libspectre1_0.2.7-2ubuntu1_amd64.deb), located at:

https://launchpad.net/ubuntu/trusty/amd64/libspectre1/0.2.7-2ubuntu1

renders the eps files correctly. Thus the bug was introduced in the change from -ubuntu1 to -ubuntu1.1 as a result of trying to fix Bug #1242678.

https://bugs.launchpad.net/ubuntu/+source/libspectre/+bug/1242678

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in libspectre (Ubuntu):
status: New → Confirmed
Mathew Hodson (mhodson)
tags: added: regression-update
Revision history for this message
EdouardC (edouard-canot) wrote :

Hi all,

I'm happy to discover that this bug is registrated here. I tried many times early in july to find some information on the web about this problem, but I always failed.

In my case (ubuntu-14.04, 64 bits), I discovered and identified this bug at the end of june.

It appears that it affects only the EPS files which doesn't contain the 'showpage' postscript command at the end of the file. Indeed, a work-around of this bug is to add the 'showpage' command at the end of the EPS file.

So, the good new is that a workaround exists and is pretty easy to do: you can use any text editor to modify an EPS file!

Not all the EPS files are affected: for example the EPS files created with the Matlab software already include a 'showpage' at the end, so they are not affected by this bug.

It is worth noting that EPS files which doesn't contain the 'showpage' command at their end are valid. Don't answer that these EPS are not valid! The 'showpage' command is used to eject the page and it is mandatory in PS files, not EPS files. Please for example the discussion in:
   http://bugs.launchpad.net/inkscape/+bug/929463
which contain the following extract of the official Adobe documentation:
<quote>
Redefine showpage

    The showpage operator is permitted in EPS files because it is present in so
    many PostScript language files. Therefore, it is reasonable for an EPS file
    to use the showpage operator, although it is not necessary if the EPS file
    will only be imported into another document. The application importing the
    EPS file is responsible for redefining showpage. showpage may be redefined
    using the following code segment:

    /showpage { } def

</quote>

Cheers,
EC

Revision history for this message
Christopher Mendillo (chris-mendillo) wrote :

Thanks Edouard,

Yes, I can confirm that appending the "showpage" command to my eps files causes them to be rendered correctly by evince and libspectre. From what I can tell reading the latest EPS standard (https://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf), as you say, showpage is allowed in eps, but should be redefined by programs that import eps. evince libspectre should do so in order to display correctly formatted eps files that lack the superfluous showpage command.

Revision history for this message
Achim Bohnet (allee) wrote :

So how's fault is it? Is it in scope of libspectre tasks to add a dummy showpage for eps files? Or have all applications that
use libspectre handle this case themself?

The ubuntu1 ubuntu1.1 diff is here:

http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/libspectre/trusty-updates/revision/14

I've subscribed Till Kamppeter to this bug, to get his attention. He the one that cherry picked the patch.

Achim

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in okular (Ubuntu):
status: New → Confirmed
Revision history for this message
Corentin SCHREIBER (cschreib) wrote :

The "vanilla" libspectre-0.2.7 doesn't show this behavior. The patch we are takling about has been introduced in the master branch of the git repository last June, but was reverted in September:
http://cgit.freedesktop.org/libspectre

Some time between those two dates, somebody added this patch to the debian/ubuntu version of libspectre though, and it has not yet been reverted here.

While this gets fixed, you can get the source of the debian package, download the vanilla libspectre, and build yourself a new .deb package without this faulty patch (make sure that the source repositories are enabled). I give below a script that should do this for you. There may be a better way, but at least this one works.

# Install the tools needed to build debian packages
sudo apt-get install devscripts
# Install the dependencies of libspectre
sudo apt-get build-dep libspectre1

# Make yourself a temporary directory
mkdir ~/tmp/
cd ~/tmp/

# Download the vanilla libspectre-0.2.7
wget http://libspectre.freedesktop.org/releases/libspectre-0.2.7.tar.gz

# Download the debian source code
sudo apt-get source libspectre1

# Create a new directory with the correct code
cd libspectre-0.2.7
uupdate ../libspectre-0.2.7.tar.gz -v 0.2.7-vanilla
cd ../libspectre-0.2.7-vanilla

# Remove the debian patch
rm debian/patches/*

# Build the package
dpkg-buildpackage -us -uc -nc
# Note: fore some reason, this fails to build libspectre-dev, but we don't care

# Install it
cd ../
sudo dpkg -i libspectre1_0.2.7-vanilla*.deb

Changed in libspectre (Ubuntu):
importance: Undecided → High
assignee: nobody → Till Kamppeter (till-kamppeter)
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Marek, it seems that your fix on libspectre for bug 1242678 is causing this bug. Can you have a look? Thanks.

Revision history for this message
Marek Kašík (mkasik) wrote :

This patch fixes the problem for me. But I can not reproduce the problem mentioned in https://bugs.freedesktop.org/show_bug.cgi?id=76450#c34 so there are still some problems probably.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Erase the current page before its drawing" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

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

tags: added: patch
Revision history for this message
EdouardC (edouard-canot) wrote :

Thanks a lot Corentin. The re-build of a vanilla DEB package solves the rendering perfectly.
Your explainations were quite clear...

Regards,
Edouard

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Marek, is the patch from upstream (or at least submitted to upstream)? Can we expect it to be included in an upstream version of libspectre soon?

Revision history for this message
Marek Kašík (mkasik) wrote :

The patch is a simplified version of the patch https://bugs.freedesktop.org/attachment.cgi?id=105606. I still can not reproduce the problem mentioned by Carlos and my previous patch was reverted so I don't know whether it will be included there at all.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Attached is a debdiff to get the fixed package for Vivid using the attached patch.

Changed in libspectre (Ubuntu):
status: Confirmed → Fix Committed
assignee: Till Kamppeter (till-kamppeter) → nobody
Changed in evince (Ubuntu):
status: Confirmed → Invalid
Changed in okular (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
Robie Basak (racb) wrote :

I've just spoken with Till about this on IRC.

It seems to me that there are two patches involved here. Patch 1 (fix-document-rotation) fixed bug 1242678, but caused a regression (tracked by this bug: bug 1348384). Marek has kindly provided patch 2 (erase-page) that fixes this.

But patch 1 was reverted upstream, and we don't know what the current status of this is. So patch 1 has inadvertently caused Ubuntu to diverge from upstream, and this is what is causing the current pain.

I think that taking patch 2 is going to exacerbate the problem. Then we'll be even further diverged from upstream, and this will make future merges harder, which sets Ubuntu up to end up with an old version for fear of regression.

So to avoid making the situation worse, can someone please resolve the situation of these two bugs upstream before pushing this patch into Ubuntu? What has upstream done about bug 1242678? Would it be better to revert patch 1 from Ubuntu, and take what upstream has done to fix it instead, thus avoiding this regression altogether and bring us closer to upstream?

Finally, when preparing debdiffs, please use dep3 headers (http://dep.debian.net/deps/dep3/) to make it easier to follow upstream status on these patches.

Thanks.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libspectre - 0.2.7-2ubuntu3

---------------
libspectre (0.2.7-2ubuntu3) vivid; urgency=medium

  * erase-page.patch: Some EPS files get rendered with black background.
    This patch fixes this. Thanks to Marek Kasik for this patch (LP: #1348384).
 -- Till Kamppeter <email address hidden> Mon, 15 Dec 2014 18:34:44 +0100

Changed in libspectre (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
GrandVizier (grandvizier) wrote :

libspectre - 0.2.7-2ubuntu3 does not solve the problem for me.
Rather, it replaces the original problem (black background) with another one (nothing displayed, completely white).
As before, manually adding "showpage" at the end of the eps file renders correctly.
I observe the problem on Ubuntu 15.04 (upgraded form 14.10) and Kubuntu 15.04 (fresh install).

Revision history for this message
EdouardC (edouard-canot) wrote :

I confirm the previous post of GrandVizier.

Incredible that it has been badly fixed !

Previously totally black, the background is totally white.

Please read the ADOBE standard concerning the EPS language before implementing some hazardous or not professional things !

My linux box is Ubuntu 15.04 (64bits) newly upgraded from 14.10.

Revision history for this message
John B. (jbuncher) wrote :

I know the bug status says "Fix Released", but the problem is still present on new installs of Ubuntu 14.04 (using a 14.04 image and upgrading all packages, NOT installing from a 14.04.2 image).

Are there any plans to backport/fix this in the LTS release?

Revision history for this message
Christopher Mendillo (chris-mendillo) wrote :

I just did a fresh install of 14.04.2 from a newly downloaded 14.04.2 iso. This contains libspectre1_0.2.7-2ubuntu1.1_amd64 and produces the bug.

I tried Corentin's fix to install the vanilla version, but compiling crashed with:

dpkg-genchanges: error: cannot read ../libspectre_0.2.7-vanilla-0ubuntu1.dsc: No such file or directory
dpkg-buildpackage: error: dpkg-genchanges gave error exit status 2

I've gone through all of the ubuntu versions and this is what I get:

libspectre1_0.2.7-2ubuntu1_amd64 -- White background
libspectre1_0.2.7-2ubuntu1.1_amd64 -- Black background
libspectre1_0.2.7-2ubuntu2_amd64 -- Black background
libspectre1_0.2.7-2ubuntu3_amd64 -- White background

So, version 3 works for me, but that is in 14.04.2. I see GrandVizier has a new problem in 15.04.

I've attached an example eps file that renders correctly in 14.04.2 with libspectre1_0.2.7-2ubuntu3_amd64.

Revision history for this message
EdouardC (edouard-canot) wrote :

Ha ha... we are close to the first birthday of this bug, which is not yet fixed on 15.04

Perhaps it will be fixed for 15.10, or 16.04, or 17.04?

Mathew Hodson (mhodson)
no longer affects: evince (Ubuntu)
no longer affects: okular (Ubuntu)
Revision history for this message
Jeremy Bicha (jbicha) wrote :

I'm setting the bug importance to Critical according to #7 of
https://wiki.ubuntu.com/StableReleaseUpdates#Procedure

https://launchpad.net/ubuntu/+source/libspectre/0.2.7-2ubuntu2 was an SRU that introduced this regression on Trusty.

Changed in libspectre (Ubuntu Trusty):
importance: Undecided → Critical
status: New → Triaged
Changed in libspectre (Ubuntu Trusty):
assignee: nobody → Till Kamppeter (till-kamppeter)
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

The SRU was the simple application of an upstream patch from this upstream bug report

https://bugs.freedesktop.org/show_bug.cgi?id=76450

I do not know anything of the internals of libspectre and even do not have upload rights for it, as it does not belong to printing. It is used by evince to generate certain output data formats. I only have done the debdiff for that SRU because no one else did it. I am not maintaining libspectre in Ubuntu.

So my suggestion is to simply remove the patch if the solution of the current problem is urgent and no better patch from upstream is available. But take into account that the problem of the original SRU will reappear. Let this be a new SRU. Wait for a better upstream fix if it is not so urgent.

In general make upstream aware of both problems and that fix of the first problem caused the second and what is needed is a fix to solve both problems. Do another SRU if the final fix is available.

Changed in libspectre (Ubuntu Trusty):
assignee: Till Kamppeter (till-kamppeter) → nobody
Revision history for this message
Jeremy Bicha (jbicha) wrote :

Till, I'm taking care of this bug. Thank you!

description: updated
Changed in libspectre (Ubuntu Trusty):
status: Triaged → In Progress
Jeremy Bicha (jbicha)
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello John, or anyone else affected,

Accepted libspectre into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/libspectre/0.2.7-2ubuntu1.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in libspectre (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Jeremy Bicha (jbicha) wrote :

I completed both test cases successfully with libspectre1 0.2.7-2ubuntu1.2 from trusty-proposed on Ubuntu GNOME 14.04.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libspectre - 0.2.7-2ubuntu1.2

---------------
libspectre (0.2.7-2ubuntu1.2) trusty; urgency=medium

  * Replace fix-document-rotation.patch with new version from 0.2.8.
    This fixes a regression introduced in 0.2.7-2ubuntu1.1 where some
    eps files are mostly unreadable with a black background when viewed
    in apps like Evince or Okular (LP: #1348384)

 -- Jeremy Bicha <email address hidden> Wed, 07 Dec 2016 15:52:17 -0500

Changed in libspectre (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for libspectre has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

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.