Using Plugin Crashes Sketch Every Single Time
What did I do:
- Opened the production .Sketch file I have been working on (around 50MB, multiple art boards, multiple pages)
- Renamed a group the way it's required for it to be named in order for this plugin to work
- Copied and pasted the the renamed group over multiple art boards
- Changed a layer style
- Pressed ⌘ E
What happened: Sketch crashed
What did I expect to happen: I expected the plugin to work on the file as it worked fine on a small simple testing document.
Here's the crash report: http://d.pr/n/5FB0
I tried to create a crash reproducer file. It does not work at all the times; however, I can't really share the files to which I am referring to as those are under NDA and are property of the company I work for. Here's the reproducer file (try changing a layer or two and activate the plugin): http://d.pr/f/Or2q
Confirmed! It actually worked fine with just two pages, but crashed when I added a third. I'll let you know what I find out. Thanks so much for providing the reproducer file!
Update: I've tracked down the crash to the replication of styles in the dynamic text layers. I haven't found a fix, yet.
@tisho can you point us to the exact line where it crashes? Maybe an extra pair of eyes can help : )
That would be much appreciated. Thanks, Ale. This is the place in the code I had it narrowed down to: https://github.com/tisho/sketch-plugins/blob/master/Symbols/Sync%20Symbol.sketchplugin#L94
Even if I commented out the actual removeStylePart/addNewStylePart, just accessing the style part arrays would cause a segfault. This seems to be a red herring, though, because when I created another test file with no dynamic layers, it still crashed after the number of layers in all symbol instances went over ~1300.
It looks like a memory issue, but I can't pinpoint it.
fwiw I've had a similar (but inconsistent) crash when syncing a text layer style change over ~20 groups or so across 3 artboards. If I figure out how to isolate it I'll submit an issue.
Similar problem : I have a project with 16 artwork already started without any symbols instance. I decidied to add symbols instance only in a second time but I have problem at the first attempt to create them: crashed or do nothing when I press cmd+e. For the rest, with new project, seems to have no problem working
small dumb test : just for try I've deleted a lot of artworks and layers from the project and the plugin start again to work
small dumb test 2: I've deleted only big bitmap image and the plugin start again to work... it looks like a memory problem imho.
Is there any "best practice" for building Sketch plugin without memory issue? or any suggestions would be appreciate.
+1 If files get complex, any plugin that parses the layer tree seems to crash. There must be a way to handle this…