Experience: how to lose a document while saving it

07.02.2021

We all know that Illustrator can crash. We have all taken out a document from backups more than once, which Illustrator himself regularly makes. We all scolded Illustrator and ourselves for not making an additional copy of the document. But this case is about how clicking "Save" led to the irrecoverable loss of the document's content.

Task

When I was announcing the project "Road Signs Generator", I decided to record a slow motion video of drawing a sign:

It is really impossible to slow down the video 10 thousand times, so I thought of, as it seemed to me, a rather elegant way — to put small pauses inside the script.

Solution

During development, I use a self-written script that writes all actions to a log-file in order to see the process from the inside. This script is called in all functions and methods, class initializers and for logging variables — that is, I didn't even have to put these pauses inside the extension. I can just put a little pause in the log function.

There was also a moment when the illustrator during the execution of scripts does not draw the document, but only after the end of the script. But you can forcefully tell him "Draw!" In the script.

And so I added to the log:

$.sleep(15);   // pause 15 milliseconds
app.redraw();  // redrawing the document

It turned out perfect — just 2 lines of code and at the output I get a slow process of drawing a sign. It remains to prepare the sign and run the extension.

Mistake

I had one illustration file in which I kept all the sources for the announcement. There I decided to start the process of drawing the sign. I added a new artboard and ran the extension — it was drawn perfectly! Now it was time to record a screencast.

I selected all, deleted the previously generated sign, started the extension, admired the process, and stopped the video recording. And saved in Illustrator.

That's it. This is where I lost the document.

What is the mistake?

At the moment when I selected all before recording the video and deleted, naturally I deleted everything from the document (except for the locked layers and elements). But that's perfectly fine — I can click Undo and everything will be restored, or not save the document and just exit.

BUT! The problem is that the app.redraw() command in the script after drawing adds a step to the document history. That is, the script generated a huge cloud of steps into the history of the document. And I had to press "cancel" about 400 times. But in the story settings in Illustrator, I had 100 actions. And since I saved, I could no longer close the document without saving.

And so I press "undo", press more, and more, AND MORE, AND MORE! And all that happens is just: the sign's artboard has disappeared, the legend has disappeared, the background color has disappeared, the background width has changed, and so on. And so I clicked cancel 100 times, but all I see in front of me is an incomplete sign and a blank document...

The moment I realized this, I got sucked in my stomach (like Harry Potter). I made this file for a long time, collecting different signs from the finished results and process files. And so I lost everything: instead of signs, I saw empty artboards.

I even tried to crash Illustrator, hoping to find a _backup file. But my document was saved perfectly fine. And nothing survived...

Conclusion

Of course, I am to blame for this case myself: I deleted the elements and did not think whether it would be preserved. But the way of losing the document was new to me.

I didn't rework everything, because I already exported many artboards to rasters. But as the announcement was filled, I had to redo the files. And every time I remembered this incident.

Now I know — to record a slow motion video, you need to make a separate document.

PS: As my colleagues tell me, the output can still be supplemented by storing backups of files or in cloud services. Of course, when it comes to working projects, there is nowhere without it. But here — your personal file... In general, you need to treat your projects as full-fledged, working!