Subject: bug#34138: 27.0.50; Delayed display of PDF file images

From: Stephen Berman <[email-masked]>
Date: Sun, 20 Jan 2019 12:18:36 +0100

On Sun, 20 Jan 2019 10:17:37 +0100 martin rudalics <[email-masked]> wrote:

>> Since a recent commit, I'm seeing a delay in the display of PDF files as
>> images (both with -Q and with my initializations).  I see this in both
>> doc-view-mode and pdf-view-mode (from the pdf-tools package, available
>> from MELPA).  In doc-view-mode, on visiting a PDF file, it at first
>> appears as raw PDF, as when visiting it in fundamental-mode, and only
>> after a few seconds does the image appear.
>
> I cannot see how 'doc-view-mode' could be possibly affected by the
> changes you identified below.  It doesn't run any of the affected
> hooks.  Have you tried running 'doc-view-mode' without loading
> 'pdf-view-mode'?

Yes, as I noted, I also see this with -Q.

>> The same happens in
>> pdf-view-mode but there the delay is much longer -- with some files it
>> takes close to a minute on my machine before the image is displayed,
>> unless I provide keyboard input, which makes the image appear
>> immediately.
>
> These might be related although going through the sources of
> ‘pdf-view-mode’ I cannot see any problem.  'pdf-util-window-attach'
> uses a workaround for deleting a window after running
> 'window-configuration-change-hook' and there I see a different source
> of trouble:
>
> 'display-buffer-split-below-and-attach' calls 'window--display-buffer'
> with a fifth argument and that has been changed in another commit.
> Please remove the display-buffer-mark-dedicated argument in that call
> and see whether the problem persists.  CC-ing Andreas to make an
> appropriate change in pdf-util.el.

AFAICS display-buffer-split-below-and-attach is only used in the
defcustom pdf-annot-edit-contents-display-buffer-action, which specified
the "Display action when showing the edit buffer", so it's irrelevent
for just displaying the PDF file.  Anyway, I modified and instrumented
the function, but it wasn't called on visiting the file.

>> In addition, in pdf-view-mode this appears in *Message*:
>> Error during redisplay: (eval (pdf-misc-size-indication)) signaled
>> (error "Invalid image specification: nil").
>
> This should come from the 'image-display-size' call in
> 'pdf-view-image-size'.  Could you get a backtrace for it?

There is no Lisp backtrace, just the "error during redisplay" message.
That eval expression is a modeline construct, so I guess this needs to
be debugged at the C level.  I could try to do that but probably need
guidance.  (Ah, I just saw Andreas's post that he could reproduce the
issue, so hopefully he can debug it.)

Steve Berman