tecosaur / org-latex-preview-todos

A tracker for the Org LaTeX Preview effort on https://git.tecosaur.net/tec/org-mode
5 stars 0 forks source link

:height image attribute is sometimes not saved in cache #43

Open 9viz opened 1 month ago

9viz commented 1 month ago

Sometimes the cached images do not have the :height attribute anymore when Emacs is opened the next time. It does not matter if the fragment is inline or display math. I have org-latex-preview-persist-expiry set to 'never. To make the attribute appear again, I need to say M-x org-latex-preview-clear-cache RET when the point is on the fragment. As an example, consider the cached entry before

;;   -*- mode: lisp-data; -*-
(((elisp-data "LaTeX preview cached image data")) ((file "/../tmp/org-tex-TIkAIL-000000021.svg") . "1b/7e90c8-043c-4d73-ac77-fdd2ae44f4bd-b1c0512633a355c75d25f2c6895423db.svg") ((elisp-data (:image-type svg :errors nil))))

and the image is attached as before_cache_clear.svg, and after clearing the cache

;;   -*- mode: lisp-data; -*-
(((elisp-data "LaTeX preview cached image data")) ((file "/tmp/org-tex-vspmqC-000000001.svg") . "db/f3fa47-a0ad-4fe8-b8ba-ac50eb2e4ecc-85e416b52ef9f3ef9597c5a9c512e4a5.svg") ((elisp-data (:image-type svg :width 0.9369485460114989 :height 0.7680325306302024 :depth 0.04918392937239927 :errors nil))))

and the image attached is after_cache_clear.svg. The height attribute in the image is the same.

I believe the problem happens when Emacs does not exit cleanly (because it got OOM'd or it segfaulted), etc. since I seem to witness this only after Emacs gets killed.

after_cache_clear before_cache_clear

9viz commented 1 month ago

Update: I am 95% sure that this happens when Emacs does not have the chance to exit cleanly. Happened earlier this day and some of the images created by the segfaulted process look smaller in a fresh new Emacs process I started afterwards.