From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74537: [PATCH] An on-disk image modification does a cache miss Date: Tue, 26 Nov 2024 19:38:35 +0100 Message-ID: <87r06x4z84.fsf@ledu-giraud.fr> References: <87ed2z6m7q.fsf@ledu-giraud.fr> <86plmiglyx.fsf@gnu.org> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25101"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74537@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 26 19:39:37 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tG0TI-0006NL-Jx for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Nov 2024 19:39:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tG0Sx-00038p-Gy; Tue, 26 Nov 2024 13:39:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tG0Sk-00036h-P8 for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2024 13:39:05 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tG0Sk-00068Y-Ab for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2024 13:39:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=4WvnZdVuklUn1EumfgcJloae1kIVD5sj+96mjiA7j6A=; b=nemB7CRpI2B/oXf8p7w7wEFSjLYmlEqhYyZSQ9NhexYZ3qF+n0OFJNMMOuHhf6TENcOuU51GlgjXsQEvu3nhsyPzPmM/ZmneeYXbQGpVaxqKCGtX21QXpVyZPtDEW6qF3Wk+tB9THAuNXViPdMzR1S89pGfU8Z/LGkNerrL9Tb3eZhDLTeoTzvlXfpeKEMmN1N8irBNL4/o8960eV/urcaR+iLn35DRwTJs7pwPQaYSgO11YmA59miTrw2JdWhja7XowP8E6CvpVqihcnWIYKnbkmRexuB3AxSi/ISmVVMPznLoPSDz6C5tK4+k1tzhW3OcfOFnUyYf2Ao+9NXr0VA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tG0Sk-0001D8-4x for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2024 13:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Nov 2024 18:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74537 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74537-submit@debbugs.gnu.org id=B74537.17326463244624 (code B ref 74537); Tue, 26 Nov 2024 18:39:02 +0000 Original-Received: (at 74537) by debbugs.gnu.org; 26 Nov 2024 18:38:44 +0000 Original-Received: from localhost ([127.0.0.1]:52393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tG0SR-0001CV-DF for submit@debbugs.gnu.org; Tue, 26 Nov 2024 13:38:43 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:13425) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tG0SO-0001CK-Cl for 74537@debbugs.gnu.org; Tue, 26 Nov 2024 13:38:41 -0500 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=ZB7tCdgT 3UF0SUAvZYYo2RSWPIHbxJ5RDR0zXUSxyuw=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=MJIumaSWk0wFcc6SsOuYigNsTmgl+X 1kGavzbhO3mFId1Zisg9jROtdB/fgBeHxrMuYmu4K9JBYeZJx3sFgYCA== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=ZB7tCdgT3UF0SUAv ZYYo2RSWPIHbxJ5RDR0zXUSxyuw=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=yi7UTX7htGYk2lbZBTJJ35JfUdKO6qYg+njUj5 hTL+TTOCKXhJe4fHOEo6b7SSwPCp0TxyqaytV4M4JUwDLEo1+ToPhnhziDufcEgOm5uBev dGCrqvAhcbfk0hKRmz39tgzgxwRDIDcnd7P9TKtLhpR/AcBz228NwmRVm5PADWrq5KCjd6 xvDeZzfWIPDM1clNN1RYWOosQZr/eviAKAj5MtpdNwjGD8zFixJDzJFON11U5hHJ64X4rQ vnbKjo6UL+37jwNUzWmCgNas1WInlX1u1MYxUen9Turo6uz0E7IFmNtE8dYqCEleZma0GC 3+sj/9tjdcDzbzBYZaOgxuaw== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 0e65ca65 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 26 Nov 2024 19:38:36 +0100 (CET) In-Reply-To: <86plmiglyx.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 26 Nov 2024 15:31:50 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295997 Archived-At: Eli Zaretskii writes: >> 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" >> >> 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. Ok. > 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? I've tried a bit with image-mode and also with something like: (insert (propertize "f" 'display '(image :file "/tmp/foo.jpg" :type jpeg :width 100))) and, yes, I can see the behavior you describe. But I also can't really see why it is a problem: the image has changed! At one point it should be reflected in Emacs, no? > 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. This I've tried with: (insert (propertize "foo" 'display '(space :width (0.1 . (image :file "/tmp/foo.jpg" :type jpeg))))) and also the re-alignment occurs at /some/ point. But likewise, I fail to see why this is a problem. After all, maybe I'm a bit partial to image-mode with this patch. I think my idea was to eventually get rid of the systematic `image-flush' call in "image-mode.el" to make it beneficiate from the image cache more and still be able to display the correct image. It seems I also lack some imagination about how users could use images in Emacs. For instance, with your example about alignment, I imagined that it could be something that a user would do in its modeline (for example) but with images that would never ever change. -- Manuel Giraud