How to write to an EditableImage in parallel

  1. What do you want to achieve? Keep it simple and clear!

I have a shader engine made using Roblox’s EditableImage API. It works fine, but there is a glaring issue with consistent frame drops due to drawing to a 112x63 px canvas @ a fixed rate of 10 draw calls/sec.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I learned that the EditableImage method :WritePixelsBuffer is kind of slow when writing to a canvas. I tried chunking the shader processing into multiple threads with multiple actors, but :WritePixelsBuffer isn’t thread safe and can only be called on the main thread. The bulk of the shader math is done on a thread separate from the main thread, so it isn’t the culprit behind the frame drops I’m experiencing.

  • This issue isn’t noticeable on higher end devices but, it’s magnified on mobile devices, making the rest of the game noticeably choppy. I want to strictly avoid this by having the shader math & rendering be done on a separate thread. Is this even possible?

If you use parallel to render your shader, then you’d face a new issue: your pixels would render at different times, resulting in tearing and/or incorrect pixel placements. A good solution or alternative, is to find a faster algorithm for references. There’s also reducing any redundant operations.