Subject: bug#45256: Viewing images over network using TRAMP (errors and unexpected prompts)

From: Juri Linkov <[email-masked]>
Date: Wed, 16 Dec 2020 22:52:05 +0200

> That is, two calls of timer-event-handler([t 0 1 0 nil image-fit-to-window ...])
>
> image-fit-to-window calls remote file operations,
> verify-visited-file-modtime the first time, file-readable-p the second
> time. The first call of image-fit-to-window hasn't finished, when the
> second call of image-fit-to-window happens one second later. That is
> relevant, this situation happens only for slow remote connections (I had
> a hard time to reconstruct the scenario).
>
> From my pov, image-fit-to-window must be hardened in order to avoid this
> reentrant call. Maybe an internal lock at entry, which is honored by
> every next call until the lock is removed.

The simplest solution is just to increase the number of seconds
in the user option 'image-auto-resize-on-window-resize'
proportionally to network latency.

Locking could be implemented as well.  How would be better to do this?
Maybe by using a buffer-local variable?