tisho / sketch-plugins

A collection of plugins for Bohemian Coding's Sketch.
645 stars 25 forks source link

Using Plugin Crashes Sketch Every Single Time #2

Open philipamour opened 10 years ago

philipamour commented 10 years ago

What did I do: 1) Opened the production .Sketch file I have been working on (around 50MB, multiple art boards, multiple pages) 2) Renamed a group the way it's required for it to be named in order for this plugin to work 3) Copied and pasted the the renamed group over multiple art boards 4) Changed a layer style 5) 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

philipamour commented 10 years ago

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

tisho commented 10 years ago

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!

tisho commented 10 years ago

Update: I've tracked down the crash to the replication of styles in the dynamic text layers. I haven't found a fix, yet.

bomberstudios commented 10 years ago

@tisho can you point us to the exact line where it crashes? Maybe an extra pair of eyes can help : )

tisho commented 10 years ago

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.

ianleighton commented 10 years ago

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.

spazione commented 10 years ago

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

spazione commented 10 years ago

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

spazione commented 10 years ago

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.

sskyy commented 10 years ago

Is there any "best practice" for building Sketch plugin without memory issue? or any suggestions would be appreciate.

getflourish commented 10 years ago

+1 If files get complex, any plugin that parses the layer tree seems to crash. There must be a way to handle this…