vipercard
vipercard copied to clipboard
drawing on a stack, then saving+reopening, can cause an assert message
Mentioned by erico on twitter.
I have a stack that displays the symptom but am not sure of the bug that led to the state. When opening the stack a JavaScript error message appears, saying "length mismatch, expected, got", and then the dimensions.
- Is the file being encoded properly? (Byte Order Mark in saved JSON is for UTF-8.)
- Are all special characters being escaped?
- newline (yes)
- other control characters (?)
- more at https://json.org
My hunch is that Base64 encoding of (compressed) image data, using JavaScript's btoa()
and atob()
would be less fragile, if somewhat larger. This would also help a JSON saved stack file survive editing outside ViperCard.
The serialization is coming directly from the browser's JSON.serialize, and so I don't think that is the source of this problem. In the repro stack, the image data is valid and can be decompressed, but just has different dimensions than expected. A serialization problem would result in data that couldn't be decompressed.