GNU bug report logs - #74537
[PATCH] An on-disk image modification does a cache miss

Previous Next

Package: emacs;

Reported by: Manuel Giraud <manuel <at> ledu-giraud.fr>

Date: Mon, 25 Nov 2024 21:28:02 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Manuel Giraud <manuel <at> ledu-giraud.fr>
Cc: 74537 <at> debbugs.gnu.org
Subject: bug#74537: [PATCH] An on-disk image modification does a cache miss
Date: Tue, 26 Nov 2024 15:31:50 +0200
> Date: Mon, 25 Nov 2024 22:24:25 +0100
> From:  Manuel Giraud via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> With this patch, when an image file is modified on disk, the associated
> cache image is invalidated and re-read from disk.

Thanks, but I'm not sure it's a good idea to do that automatically
whenever lookup_image is called.

First, lookup_image is called only when we need to create or access an
image with only its Lisp descriptor in hand; once the image has been
displayed, that should happen relatively rarely.  For example, the
glyph matrices used to manipulate the display record only the image's
cached ID, and the code accesses the cached image without calling
lookup_image.  So this change could have weird confusing effects,
whereby the fact that the image was modified on disk becomes apparent
only after some display-related actions, but not after others.  For
example, scrolling a window by a small amount will not notice the
change on disk, whereas significant changes, especially when the image
goes off the window and back into it, will show the change.  Don't you
see such issues if you install the change?

Second, if the image is already on display, and the file changes on
disk, some layout calculations could see different dimensions than
what is actually on display, which will cause subtle bugs.  For
example, what if there's a 'display' property such as this:

  '(space :width (0.5 (image PROPS)))

and an image with those same PROPS is already shown on display?  The
code which implements the above calls lookup_image, which will
simulate a cache miss if the file has changed, and will then load the
new file, which could return dimensions different from the image
already on display.  So the width of the space glyph produced by the
above will be different from that of the displayed image, and we could
have misalignment until the next redisplay which redraws the image.

So I think this should probably be controlled by a variable visible
from Lisp, by default off, and we might also have a function to
invalidate all the cached images whose files have changed (which will
then need to trigger a thorough redisplay, I think).




This bug report was last modified 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.