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

From: Eli Zaretskii <[email-masked]>
Date: Thu, 24 Jan 2019 16:26:01 +0200

> Date: Thu, 24 Jan 2019 10:08:53 +0100
> From: martin rudalics <[email-masked]>
> CC: [email-masked], [email-masked], 
>  [email-masked], [email-masked]
> 
>  >> (1) Make the window.
>  >>
>  >> (2) Run 'image-mode-reapply-winprops'.
>  >>
>  >> (3) Run 'pdf-view-new-window-function'.
>  >>
>  >> (4) Continue with overlays and properties set up.
>  >>
>  >> (5) Redisplay, eventually.
>  >>
>  >> If anything in (4) needs anything done in (2) and (3), running the
>  >> hooks earlier in redisplay won't help.
>  >
>  > I'm not sure I understand why, perhaps because I don't have a clear
>  > idea what you mean by "continuing with overlays".  Please tell more.
> 
> When I say that steps (1)--(3) are deterministic I meant that making
> the window is guaranteed to have run (2) and (3) before any action in
> (4) gets executed.  In (4) the application may run arbitrary code with
> the guarantee that the overlay from (3) and the "winprops" from (2)
> have been installed.  Running 'window-configuration-change-hook' from
> redisplay means this guarantee no longer holds.

I think the overlay is definitely installed, just not before redisplay
examines the windows.

>  >> Note: We can always restore the emacs 26 (better emacs 25) way
>  >> 'window-configuration-change-hook' is run.  That won't affect the
>  >> remaining hooks and prevent scenarios as the one found here.
>  >
>  > What are the disadvantages of doing that?
> 
> That we again run the hook even if nothing has changed and do not
> catch many possible changes.  Hence well-behaved users of that hook
> would get punished.
> 
> I'm not sure whether I would care personally.  We never reached a
> common agreement on what a window configuration change is and when it
> happens.  So while the hook represents bad design (IMHO) and nobody
> should ever have used it, there never existed a viable alternative to
> accomplish what it provided in the past.

I'd like to see if there's a less radical solution.

Andreas, could you please help me?  I'd like to have a way of
reproducing the problem with pdf-tools, but without poppler.  Would it
be possible for you to show me some Lisp that use pdf-tools (or even
image-mode directly) to just display some fixed image, say splash.png
from etc/images, in the same way, i.e. using the same hooks, as you do
with a PDF document?  I tried to write a very simplified version of
pdf-view.el for that purpose, but either my emulation was imperfect or
there are OS-dependent factors that get in the way, because with the
code I wrote the image appears immediately.  It is important for me to
run code for which I know that you and Stephen see the problem.

Armed with such a test case, I will see what can be done to fix the
behavior.

Thanks.