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

From: Stephen Berman <[email-masked]>
Date: Mon, 21 Jan 2019 23:27:58 +0100

On Mon, 21 Jan 2019 21:47:21 +0200 Eli Zaretskii <[email-masked]> wrote:

>> From: Andreas Politz <[email-masked]>
>> Cc: Stephen Berman <[email-masked]>, [email-masked],
>> [email-masked], [email-masked]
>> Date: Mon, 21 Jan 2019 20:14:07 +0100
>> 
>> image-mode uses window-configuration-change-hook to check whether a new
>> window for the buffer it was activated for was created.  In this case it
>> runs the hook image-mode-new-window-functions.  This is the hook
>> pdf-tools attaches itself to in order to create an overlay with a window
>> property and the image of the current page.
>> 
>> Usually, i.e. in Emacs 26.1, this is sufficient for the image to be
>> visible immediately (or at least immediately after the function has
>> returned and Emacs is idle).  Conversely, in the current master branch,
>> the image is not visible until, as it seems, the next redraw cycle.
>> 
>> Note, that I don't see a delay. Rather nothing seems to happen until I
>> trigger a redisplay, for example via M-x.
>
> So it's indeed a redisplay problem.  Can you build both Emacs 26 and
> Emacs 27 with --enable-checking, then disable blink-cursor-mode and
> global-eldoc-mode, then invoke "M-x trace-redisplay", and show the
> trace displayed on stderr in both versions when you visit a PDF file?
> Please invoke trace-redisplay _before_ you visit the PDF file.  I'm
> especially interested in what happens in Emacs 27 after you visit the
> PDF file, but _before_ you type "M-x" that causes the image to be
> displayed.  IOW, what trace do you see after visiting the PDF file
> during that time that "nothing seems to happen", as compared to what
> happens in Emacs 26.

I did this and have attached the traces.  Both show the PDF files (I
used different ones in each Emacs) being opened early in the trace: in
emacs-26 the image was immediately displayed and the trace continued and
then paused and I killed emacs; in emacs-master the first trace lines
showing the PDF file correspond to the raw PDF being displayed,
following by the same kind of trace lines as in emacs-26, but then two
lines with the PDF file again, which is when the image display appeared,
after which the trace paused and I killed emacs.  As in all my other
test runs, here again the image appeared without any keyboard input, but
interestingly and surprisingly, this time it took less than 10 seconds,
as compared to 30-60 seconds in most of the other runs (which were
without tracing).

Steve Berman