vipercard icon indicating copy to clipboard operation
vipercard copied to clipboard

drawing on a stack, then saving+reopening, can cause an assert message

Open moltenform opened this issue 6 years ago • 2 comments

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.

moltenform avatar Apr 12 '18 07:04 moltenform

  • 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.

oesterle avatar Apr 12 '18 20:04 oesterle

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.

moltenform avatar Apr 13 '18 01:04 moltenform