diff options
author | David Gowers <finticemo@gmail.com> | 2023-08-28 12:28:57 +0200 |
---|---|---|
committer | NRK <nrk@disroot.org> | 2023-08-28 12:31:09 +0200 |
commit | 10a6228538a58bf40995cb7d57d47ef6ca93767d (patch) | |
tree | 512a9995ce1fd59923ece0d0af9685ac5f966114 /thumbs.c | |
parent | cc132dd365105bb80cf683a0ce1b11d038db1c25 (diff) | |
download | nsxiv-10a6228538a58bf40995cb7d57d47ef6ca93767d.tar.zst |
set autoreload timeout based on the latest event (#459)
currently the autoreload feature of nsxiv is a bit unreliable because we
try to load at the very first event we received. however, the writer
might not be done writing and so we might try to load a truncated image
(and fail).
in the following ascii diagram, function S represents sleep and `+` sign
represents writes by the writer. because we set the sleep (of 10ms) at
the first event, subsequent writes by the writer doesn't influence our
reload logic:
S(10) load()
nsxiv | |
writer + + + + (done)
time(ms): 00 05 10 15
after this patch, (assuming function T (re)sets a timeout), we will keep
(re)setting a timeout on new events giving the writer more time to
finish:
T(10) T(10) T(10) T(10) load()
nsxiv | | | | |
writer + + + + (done)
time(ms): 00 05 10 15 20 25
while this patch makes things significantly more robust, the problem
here is inherently unsolvable since there's no way to tell whether the
writer is done writing or not.
for example, if user does something like `curl 'some.png' > test.png`
then curl might stop for a second or two in the middle of writing due to
internet issues - which will make nsxiv drop the image.
this patch also increases the autoreload delay from 10ms to now 128ms
instead to decrease chances of false failures.
ref: https://github.com/0ion9/sxiv/commit/6ae2df6ed549c2cc119bd7d235b75154fc042d2d
partially-fixes: https://codeberg.org/nsxiv/nsxiv/issues/456
commit-message-by: NRK
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/459
Reviewed-by: eylles <eylles@noreply.codeberg.org>
Diffstat (limited to 'thumbs.c')
0 files changed, 0 insertions, 0 deletions