Subject: Re: bug#78739: 30.1; Performance issue with inline image in an org file

From: Eli Zaretskii <[email-masked]>
Date: Thu, 12 Jun 2025 09:09:55 +0300

[Please use Reply All to reply, to keep the bug tracker CC'ed.]

> Date: Wed, 11 Jun 2025 23:12:36 +0000
> From: laladrik <[email-masked]>
> 
> > Is it necessary to reproduce in an Org buffer?  Can you reproduce in a
> > "normal" buffer that is in Fundamental mode?
> 
> I don't how to get a resized inline image within a non-Org file.  I can do it
> if you tell me how I can do it.  I can't find any information on the internet
> about it.  Just FYI, I'm not an advanced Emacs user.  I've been using it for a
> year maybe and only as a note taking application.
> 
> > Finally, if this happens only in Org buffers, it could make sense to
> > report this to Org developers first.  The fact that redisplay_internal
> > is the hot spot doesn't mean the bug is there: it could be something
> > Org does in this case which forces redisplay to work very hard.
> 
> You might be right, because I found a scenario where I switch to Fundamental
> mode and the lagging disappears. Please find details further in the message.
> 
> > In any case, please post a complete recipe, starting from "emacs -Q",
> > that reproduces the problem on your system, because what you say below
> > is too vague to follow (I tried method 1, but couldn't reproduce).
> 
> Let's get focused on the first scenario.
> 
> Input data:
> 1. The init.el file with the following content
> 
>     (setq org-image-actual-width 1000) ; this command resizes inline images
>     (setq gc-cons-threshold (* 50 1000 1000))
> 
> 2. An Org file has 45 lines.  The last line is the link to the image line this
> [[file:./inlineImage.png]]. I can provide an Org file if you request it.
> 3. An image, which is big enough for resizing.  One of the images I have
> is 2778 x 880.  The format of the image is png.  Also, I tried jpg and bmp, but
> they don't change anything.  The size matters.  The smaller the image, the less
> Emacs slows down.  Again, I can provide it if you request it.

Yes, please post both the Org file and an image, so I could try
exactly what you are trying.

> Scenario:
> 1. emacs -Q --init-directory=<path/to/folder/with/the/init.el>
> <path/to/the/org/file.org>
> 2. Set the cursor mouse over the inline image.
> 3. Press Ctrl-Space
> 4. Press Down for a second or two and see the lagging selection.
> 
> I noticed that switching to Fundamental mode helps.  However, it happens only
> if I switch to Fundamental mode before moving the mouse cursor over the inline
> image.
> 
> Scenario:
> 1. Move cursor to the corner of the desktop.
> 2. emacs -Q --init-directory=<path/to/folder/with/the/init.el>
> <path/to/the/org/file.org>
> 3. M-x fundamental-mode
> 4. Set the cursor mouse over the inline image.
> 5. Press Ctrl-Space
> 6. Press Down for a second or two and see the selection without lagging.
> 
> If you swap steps 3 and 4 then the lagging happens again.
> 
> Should I report it to the Org mode team?

I will answer this after reproducing the issue on my system.

Thanks.