add imlib_decache_file() or similar #16

Closed
opened 2023-07-02 07:45:19 -07:00 by NRK · 0 comments

Currently, imlib2 only provides the "raw" frame of a multi-frame image. This means that the user needs to do the necessary blending. In nsxiv the loading is done in the following way (pseudo-code):

raw_frame = imlib_load_image_frame(file, n);
full_frame = do_thing(raw_frame);
imlib_free_image(raw_frame);

However, this causes problems when we recieve an inotify event but the mtime didn't get updated yet. Since we already freed the "raw_frame" (which is what's being cached) we cannot decache it anymore, and trying to load the same file will end up giving stale/old frames. (See https://codeberg.org/nsxiv/nsxiv/issues/456#issuecomment-959168).

We can keep the "raw frame" open, but that'd consume unnecessary memory. Another solution is to reload the frames (hoping to get it from the cache) and decache it, and then load it again. But if mtime did get updated, then it'd cause unnecessary loading.

Ideally, we should be able to do something like imlib_decache_file(filename); and have imlib2 invalidate all the cache that's asociated with filename.

Currently, imlib2 only provides the "raw" frame of a multi-frame image. This means that the user needs to do the necessary blending. In nsxiv the loading is done in the following way (pseudo-code): ```c raw_frame = imlib_load_image_frame(file, n); full_frame = do_thing(raw_frame); imlib_free_image(raw_frame); ``` However, this causes problems when we recieve an inotify event *but* the `mtime` didn't get updated yet. Since we already freed the "raw_frame" (which is what's being cached) we cannot decache it anymore, and trying to load the same file will end up giving stale/old frames. (See https://codeberg.org/nsxiv/nsxiv/issues/456#issuecomment-959168). We can keep the "raw frame" open, but that'd consume unnecessary memory. Another solution is to reload the frames (hoping to get it from the cache) and decache it, and then load it again. But if `mtime` *did* get updated, then it'd cause unnecessary loading. Ideally, we should be able to do something like `imlib_decache_file(filename);` and have imlib2 invalidate all the cache that's asociated with `filename`.
kw closed this issue 2023-07-07 09:54:49 -07:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: old/legacy-imlib2#16
No description provided.