Pattern runs, but has lost its code

Has anybody else seen this? It has happened to me a couple of times on the PB3 (never on the 2+), but this is the first time I’ve caught it in action and couldn’t write it off to me just forgetting to press “Save”.

Pixelblaze 3 standard, firmware 3.17, 591K available.

I was editing a pattern – call it “A” – then saved it and switched to another pattern to grab a chunk of code that I needed. When I switched back, pattern “A” loaded and ran with my latest edits and all slider controls functional. But the code area of the IDE was empty.

I then switched away from “A” again and looked at several other patterns in the IDE – all fine. When I switched back, “A” still runs, and still has no source code.

Tried exporting “A” – absolutely nothing happens when I press the export button. Other patterns still export fine.

What’d I do? Is there a way to recover the source (it’s actually no big deal if not – maybe 10 minutes of work. I save frequently to external .js files.)

These are computationally intensive patterns – sometimes the framerates go as low as 7 or 8 fps. The UI can be a little slow to respond when running one of these things. Could that cause problems with file I/O? Is there anything diagnostic I could look at to provide more information?

I feel like I’ve had something similar happen once, but I can’t remember which version I was on. My theory at the time was that I had somehow saved a corrupt version from a WiFi issue and it wasn’t able to parse the binary version back into code.

Can you try dumping the binary version and send it to me? I want to see what happens if I install it manually via curl.

The easiest way IMO is to run Firestorm, type “/”, and then use the “dump” button next to the board with the pattern.

Also, from a browser dev console on that Pixelblaze, inspect programList to figure out the program ID.


@zranger1 ,
Uh no :frowning: Yeah this sounds like a partially written or corrupt file. The files combine name, bytecode, preview, and compressed source in that order.

It sounds like something is failing near the end of the file where the source is stored. This could have happened if wifi couldn’t send all the data, or if there were problems writing to the file (like the kind of issues updates had on your PB).

I can do a better job of handling these, detectable failure should at least leave the original intact. I also (and @jeff has recommended this as well) want to provide some feedback in the UI when a save is complete/successful.

Another idea is to use storage in the browser to snapshot source code so that you could recover the source. Ideally you’d be able to get source in the event of a failed save or accidentally reloading the page while editing, etc. Perhaps a listing of the last n copies. That relies on the browser’s page/origin identity so a change in IP address would break it, so not good for long term stuff like version control but would be a nice way to prevent a few issues.

1 Like

That’s so clever. I wonder if Pixelblazers could make it a little more durable too if we configured local DNS with a hosts file mapping the board name with a .local TLD to its current IP.

1 Like

Oh right! That does work better with mdns too!

@Jeff, I’ll retrieve the binary and upload it this evening. I’m kind of curious about what’s in there.

I was contemplating writing a browser addon to periodically snapshot changes to the edit window, especially since I periodically save pattern source to a directory anyway. Having some backup/autosave capability built in to the IDE would be even better.

Edit: After firing up that Pixelblaze today, the pattern is still running, complete with preview and UI controls, but it shows source to a different unrelated pattern. Definitely not pressing “Save” on that one yet.

Wonder if the save hadn’t completed before I switched patterns, so it saved the correct binary, and grabbed the source from the newly loaded pattern. Possibly a threading thing? Here’s a screenshot of the weird mashup.
“Copy of Rock Concert” is the running pattern.

My editing window seems to be stuck on “Editing Matrix Green…” today, no matter what I load, although the source code shown actually is for the green matrix waterfall pattern, which is way wrong. Should I maybe contemplate erasing everything and restoring from scratch at this point?

Results: Same as yours! Name and preview loaded, I could run the pattern (oooh, ahhh! nice) but the editor was blank.

Sounds like the LZString-encoded source at the end of the binary got corrupted or truncated somehow. Sorry you lost some work.

1 Like

Thanks for taking a look! That’s pretty much what I’d figured. Only a few minutes of constant fine tuning work lost, and fortunately for once, I remember what I was thinking while I was doing it.

This disappearance of code thing happened a couple of times yesterday while running one of my v3s. Found I was running on weak WiFi @ -62 dBM. Fixed it, now running fine at -32. No problems on either of my v3s.
I, of course, will let greater minds sort the details. And thanks for doing so!

When you hit save it queues up everything atomically on the UI side. It shouldn’t cross wires with a pattern just being loaded.

If it can’t load the source, it might leave the old source in the editor though. If you clear it out or hit New Pattern or something before you edit another pattern, does it still load this green pattern source?

Otherwise I wonder if your flash is dying, or there is severe filesystem corruption that is causing it to read/write the wrong files/data. If you want to do some advanced troubleshooting I can dig deeper. Maybe image the flash and try a few things.

I’ve still got the backup of the bad pattern, but I deleted it from the Pixelblaze and cautiously went on working. I’ll keep my eyes open, but everything seems ok now. As far as I can tell, no other files on that Pixelblaze were affected.

I thought about the flash memory. This is my “dev” Pixelblaze, so I’m saving to flash quite often, and might someday actually wear it out. After poking around with a voltmeter though, I’m leaning towards the possibility of a power problem.

When this died, I was inadvertently running my matrix at a 100% brightness, doing things that often resulted in bright white pixels. The way I had it wired (for convenience), the voltage at the Pixelblaze could drop considerably depending on what the LEDs were doing. I’ve since rewired (for sanity), using heavier wire and feeding power to the Pixelblaze first. It has been stable so far. If it happens again, I’ll let you know.

1 Like

FWIW, I just had this happen last night. I’ve been on a wide variety of access points; last night was a very strong SNR and great bandwidth (but I don’t know the model - it was a commercial radio with sectored antennas).

On the next power up, trying to edit that pattern resulted in a blank editor and “Copy of” pretended to the pattern name, interestingly, though that wasn’t shown in the main list.

For the record, it was a ridiculously large pattern (~45K).

My wifi connection is very solid too. I’ve not had a recurrence, but since it happened, I’ve been extremely careful to be sure that my Pixelblaze has finished whatever it was doing – generating the preview, saving, refreshing the web page – and has returned to its stable framerate before I change patterns or save again.

Might be time to go back to being less careful to see if I can make it happen again. (45k! That really is large!)

I just had this happen… in the midst of editing. Pattern continued to run, but things crashed. Reloaded browser window, Pattern continued, but editor was empty. Opening up the saved version of the pattern lost the new changes.

Clearly, some v3 bug still to be narrowed down.