Although, in that particular case, it's fine to show the dialog.
But if it was a background flow that generated random wallpapers, it would be impossible without 3rd-party apps like Termux. Unless I somehow implemented a PNG encoder using pure blocks, or as a shell-script.
Yes, BMP encoders are easier to implement, but they are extremely bad at compression.
IDK if JSEngine exposes the Canvas API, but even if it doesn't it would be easy to import a PNG encoder from a CDN.
In general, JSEngine is very useful for any sort of "pure" data-processing (doesn't require Android APIs)