Bug Report Image refreshing sometimes fails.

sirjorj

New Member
I have been working on a program that generates overlay images for live streaming the X-Wing Miniatures tabletop game. Last night I did a test stream and found that while it usually worked just fine, sometimes OBS would just stop displaying the image when I changed it.

The program works by generating 2 images (p1.png, p2.png) and overwriting them whenever you update the game state (change shield/hull/upgrade status one one or more ships). I noticed that OBS watches the image files it is displaying and automatically refreshes them when they change on disk (thank you much for this feature, btw), but sometimes it would stop displaying the image. If i would double click on it and check/uncheck that checkbox (something about unloading the image if it is not shown or something, iirc), it would show it again just fine.

Is there some special trick to refreshing images? Or would I be better to write the image to a new file and then move it over the top of the old one to minimize the window in which there is a 'partial' file? I'm wondering if OBS is noticing the change and trying to reload it before i am done writing it, failing, and just leaving it blank until i manually trigger a reload.

Thanks
sirjorj
 

sirjorj

New Member
So I reviewed my image generation code and saw I was doing it pretty inefficiently. I was opening the file, then using libgd to draw the new image, then writing it to the file, then closing it. That leaves a potentially big window for OBS to see the file changed and try to reload it. I changed it so it saved to a different file and then did a rename(2) to overwrite the original. I then tested it again and was unable to make the problem happen again.

Lesson: If you update images by overwriting them, write to a separate file and rename for better results.
And maybe the OBS image refreshing code could be a bit more robust! :)

sirjorj
 
Top