~exec64/imv#45: 
Black screen when targeted file is changed quickly

I don't know if this feature is documented, but imv seems to "reload" a file that's already opened after is changed, i.e some writes to it.

This seems to work fine for a while, but eventually the window becomes black.

I first encountered this issue when using plantuml for generating diagrams: I would open imv with some file and then overwrite said file with plantuml every time a new diagram version is generated.

An easier way to reproduce this is using cp, like this:

  • Open a file with imv target.png
  • Do while true; do cp -v foo.png target.png && cp -v bar.png target.png; done
  • At first imv will (kind of) alternate between the two until after a few seconds it will become black
Status
REPORTED
Submitter
~itaranto
Assigned to
No-one
Submitted
1 year, 3 months ago
Updated
1 year, 2 months ago
Labels
No labels applied.

~itaranto 1 year, 2 months ago*

It's very weird, because adding some sleep time between the cp's doesn't reproduce the issue:

while true; do cp -v foo.png target.png && sleep 0.01 && cp -v bar.png target.png && sleep 0.01; done

but I can easily reproduce the issue in one shot when using:

plantuml -pipe < test.puml > target.png

~itaranto 1 year, 2 months ago*

Also,

while true; do cat foo.png > target.png && sleep 0.01 && cat bar.png > target.png && sleep 0.01; done

Seems to work fine.

and

# This generates target.png
plantuml target.puml 

Doesn't reproduce it immediately but after a couple of runs.

~jman 1 year, 2 months ago*

I seem to have the same issue when I recreate the PNG currently visualized (I'm using gnuplot to regenerate a plotted diagram). After a while the PNG does not show up anymore, just a black canvas.

FWIW as a "workaround" I use the slideshow feature: imv -t1 file.png. Doesn't cover all cases, though. If my image generation script breaks and imv tries to reload an empty file, then it's "stuck" again and I need to restart imv.

~itaranto 1 year, 2 months ago*

I'll try using the slideshow. For now I'm using imv's IPC mechanism to workaround this, I'm using that in my Neovim plugin.

It's also worth mentioning that other "minimal" image visualizers like feh don't have this issue.

~itaranto 1 year, 2 months ago

I tried using imv -t 0 file.png and imv -t 1 file.png without success, I always get a black canvas eventually.

LIke I mentioned previously, the best workaround sor far is to run imv as a server, and then do imv <PID> close all followed by imv <PID> open <FILE>.

Register here or Log in to comment, or comment via email.