Kleki Blog

New Beta (0.8)

general

Today, I released a beta of the next Kleki version (0.8). This changes how undo/redo works internally. Previously, Kleki used largely HTML Canvas objects (canvas API) to store the oldest undo state of each layer. From what I can tell, this contributed to instability and caused Kleki to hit the canvas memory limit which used to be on iOS. Canvases seemed very convenient when I first used them for the undo feature because you can instantly modify them by applying drawing operations on them, or draw them onto other canvases. But they're not the best place to keep data during the runtime of the application. A canvas can lose its context ("contextlost" event) and thereby lose all of its contents. If, for example, you updated your graphics drivers while Kleki is still open, everything would be gone.

So how are undo states stored now? Everything gets put into (Uint8Clamped) arrays. Arrays are such a fundamental feature that it seems incredibly unlikely to ever corrupt, unless of course the tab is killed. Arrays don't have "contextlost" events either. So with the new undo you should be able to install new graphics drivers while Kleki is still running. Really my hope is that all of those bugs go away where users report that pressing undo leads to weird graphical glitches (https://github.com/bitbof/klecks/issues/2).

As a side benefit, the new undo also improved performance. Why? The old approach replayed actions (brush strokes, filters, etc.) on each undo press. That can be expensive! The new approach just copies the old image data into your current canvas.

Try the beta and lets me know if you run into any bugs. There are some other smaller changes, too:

https://beta.kleki.com

-bitbof