Request - 'Complete' when Image/TextureWriter is done

We have had several occasions when we’ve wanted to write an image from skia to disk, but when reopening or uploading this file we’ve had errors and needed to set an arbitrary timer between one stage and the next.

FileExists and Filewatcher aren’t quite the way, because the file itself may only be partially written even though it technically exists in the OS’s registry.

I’ve made a quick attempt at this this morning using a pattern I happened upon in another project.
AttemptingImageWriter.vl (89.2 KB)


Is there any chance that you can demonstrate the problem?

Both ImageWriter and TextureWriter are synchronous, meaning they block execution and therefore are done writing, when the frame is done. So in the next frame the written file will be accessible.

So unless you do some custom async handling on top, the problem you describe should not exist.

Let’s look at it another way: I would like an async image/texture writer, because sometimes
a) when an image is created and I try to upload it, the result is a 1x1 pixel file.
b) the program freezes/stutters during the thing, which kinda sucks.
Not a problem with most fast machines, but we try to use more low power, discreet devices.

Why don’t you put everything in the AsyncTask region and check the In Progress pin?

@tonfilm I’ve tried this in the past and, esp with TextureWriter, the image isn’t always written.

@Hadasi can you provide a patch that demonstrates this?

In this thread from some time ago, Elias posted this awsome Async Image Writer for Skia that somehow never made it into the pack.

Attached you find your earlier example adapted.
ImageWriter.vl (56.9 KB)

@bildwerk thanks for resurfacing this. ImageWriter (Async) will ship with the next preview.

@Hadasi true, as for an async version for skia, this is what you’re looking for. indeed, simply putting the blocking ImageWriter in an AsyncTask is not enough (see the implementation of the new async imagewriter for understanding)

1 Like