Bug 691865 - x11alpha target has trouble with many PDF documents
Summary: x11alpha target has trouble with many PDF documents
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: X Display Driver (show other bugs)
Version: 8.71
Hardware: PC Linux
: P4 normal
Assignee: Michael Vrhel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-04 02:06 UTC by D. Wagner
Modified: 2011-04-09 04:42 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description D. Wagner 2011-01-04 02:06:39 UTC
I've been noticing that, in my experience, ghostscript is unable to display many PDF files.  It got annoying enough that I decided to run a more rigorous experiment.  Based upon that, I can say that ghostscript's x11alpha driver seems to have serious problems: there are many PDF documents it cannot display.

To quantify the magnitude of the problem, I wrote a script to find every .pdf, .ps, and .eps file on my computer, and then try displaying that document using ghostscript, with the following two invocations:
  gs -q -dBATCH -dNOPAUSE -sDEVICE=x11alpha $file
  gs -q -dBATCH -dNOPAUSE -sDEVICE=x11 $file
This rapidly scrolls through every page of the document.  I record for which files ghostscript successfully completes and for which it crashes with an error.  I iterate over the files, from smallest to largest.

This batch job takes a long time and has not yet completed.  I will report full reports when it finishes.  However, I can report some preliminary numbers.  It has completed running on 3423 of the 9146 files on my system, and the results are already pretty dramatic.  I include a summary of them below:

PDF (.pdf files):
 1550 displayed successfully with both x11alpha and x11 drivers
  117 failed to display with x11alpha, but succeeded with x11
    7 failed with both x11alpha and x11 (6 seem like corrupted files)

Postscript (.ps files):
 756 displayed successfully with both x11alpha and x11 drivers
  67 failed to display with either driver (65 are system files that don't look like documents intended to display; 2 are in HP PJL, not Postscript)

Encapsulated Postscript (.eps files):
 908 displayed successfully with both x11alpha and x11 drivers
  18 failed (but weren't valid EPS in retrospect, so should be ignored)

I also tried this:
  gs -q -dBATCH -dNOPAUSE -sDEVICE=x11 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dMaxBitmap=50000000 $file
But it gives exactly the same results as -sDEVICE=x11alpha on all 3423 files tried so far.

Conclusion: The x11alpha driver is unreliable.  Due to problems with x11alpha, ghostscript can't display about 7% of PDF files found in the wild.  Qualitatively, this makes ghostscript feel unreliable at displaying PDF files.  There is no reliable way to use ghostscript to display PDF files in anti-aliased form on X11 displays.  This is a serious problem for anyone who uses ghostscript to view/display PDF files on an X11 display.

I hope this bug report raises awareness of just how bad the problems with x11alpha are, and how they affect Ghostscript.

Possible strategies for addressing this problem:
1. Fix the problems in the x11alpha driver, whatever they are.
2. Mitigate them by introducing some driver that tries x11alpha, but falls back to -sDEVICE=x11 if x11alpha fails rather than crashing with an error message.  Ideally, this fallback would be transparent (apart from loss of anti-aliasing), and would continue displaying from the same page in the document.  This would be best as a short-term kludge, until the x11alpha driver can be repaired.
3. Change the default driver for PDF files from x11alpha to x11.  However this doesn't address the issue very well, since it leaves people without anti-aliasing.

Let me know if there's any additional information I can provide to help troubleshoot the problems in the x11alpha driver.
Comment 1 Hin-Tak Leung 2011-01-04 02:42:43 UTC
Re-assigning x11alpha/transparency-related bugs to Michael, which owns most(all?) such issues. There are maybe 30+ such open x11alpha bugs the last time I checked, and probably should resolve as a duplicate of one of those.

-dNOTRANSPARENCY sometimes helps, as is -dMaxBitmap=0 . These are somewhat long-standing and reasonably well-known workarounds.

Please feel free to look into it and submit a patch if the reporter can fix it. Quite a few of those 30+ bugs are bountiable, and a fix would qualify for a bounty, if that's an incentive.

BTW, "7% of PDF files found in the wild" is a bit misleading - it probably means "7% on a particular linux system". There are also a few cairo-related problems which Ken/Alex owns; unfortunately cairo is being used by quite a few popular open-source software like google chrome, inkscape, etc.
Comment 2 Henry Stiles 2011-01-04 05:12:54 UTC

X11 alpha wouldn't be acceptable as a viewer application even if it did print these file correctly, it is more a developer/debugging tool, it doesn't do anything other than display files.  There are other programs that are ghostscript based viewers with usual viewer features, for example http://www.ghostscript.com/GSview.html.  

That said, we would like x11alpha to work better than it does but would much rather have an outside consultant with X11 expertise do the work.  If you know somebody who knows X11 graphics programming we'd be happy to give them a consulting contract.  Without that I'm not sure when x11alpha issues will bubble to the top of the priority list.  We have considered disabling the device until the situation improves.
Comment 3 Hin-Tak Leung 2011-01-04 13:22:11 UTC
It is probably appropriate to try to separate files for which -dNOTRANSPARENCY or -dMaxBitmap=0 works, and those which don't work with either. Also, please attach the failed files (or a subset of it), and also indicate whether they can be used publicly as test files. (instead of/in addition of being private/public bug attachments).

As for the last point - I believe some of the files in http://svn.ghostscript.com/ghostscript/tests/pdf/ , http://svn.ghostscript.com/ghostscript/tests/ps/ does not work with x11alpha - and been waiting for some person to work on them in this respect among other purposes, but I could be wrong.
Comment 4 Ray Johnston 2011-01-06 16:30:35 UTC
This is probably related to bug 690487.

Till tested -dMaxBitmap=0 and determined that it does work, but VERY slowly.
The speed issue of not using an internal buffer is expected.
Comment 5 Michael Vrhel 2011-04-01 18:34:01 UTC
issues with -dTextAlphaBits=4 -dGraphicsAlphaBits=4 have been addressed as of rev 12341.  Please attach the problem files.  If they are not attached I will close this bug.
Comment 6 Michael Vrhel 2011-04-09 04:42:44 UTC
Many of these should be fixed with rev 12380.  Since there are no files associated with this bug and I have asked for them I am closing it now as fixed.