I knocked up some quick code for drawing on an image a while back as part of a work project, but I've never actually checked how well it works on gigantic images. It calculates the bounding box of your stroke every frame, and uses an SDF-based system to calculate the pixels of the stroke (so if you draw quickly, it will correctly join up the points). I didn't focus too heavily on performance, other than making sure it was good enough to not slow down the app, but since its speed only depends on how much you're actually drawing per frame, rather than the size of the canvas, I'd imagine it would hold up reasonably on gigantic images?