vprimachenko / Sublime-Colorcoder

Semantic highlight for Sublime Text
290 stars 25 forks source link

Crashes often on Mac #10

Closed chenglou closed 10 years ago

chenglou commented 10 years ago

error: plugin_host has exited unexpectedly, plugin functionality won't be available until Sublime Text has been restarted

I encounter this a dozen times a day (literally). I'd rather quit and restart ST than to disable the plugin, such is my affection for it =).

Not well-versed in ST's plugin system, so not sure what's wrong.

vprimachenko commented 10 years ago

@chenglou please try the debug version

chenglou commented 10 years ago

I installed the git cloned version but somehow it's not activating? (Can't see commands in palette, menu, etc.)

jeffling commented 10 years ago

I have the same problem

vprimachenko commented 10 years ago

change log for Build 3062 lists "Fixed a crash in plugin_host" - are the crashes of colorcoder affected eg. it crashing anymore?

michaelaye commented 10 years ago

I'm suffering the same. should I try github master or which version?

chenglou commented 10 years ago

Still crashing often on 500L + files. I guess throttling a bit should solve the problem? Might have a better solution though.

vprimachenko commented 10 years ago

ok - now there is a command to disable colorcoder in specific views - you can find it in command palette, aswell in the tools menu. (wont help much if colorcoder crashes before you can reach the setting :pensive:)

i will add a setting to disable highliting on files exceeding certain size, also i would like to test an 'mutexed' version, so stay tuned for that.

transat commented 10 years ago

Same problem here. Crashes within seconds of launching Sublime. Have no choice but to disable the plugin until this is fixed.

chenglou commented 10 years ago

I guess disabling the file is one way to do it. But I really do want to use it though so it's not much of a stop-gap solution. Why not throttling?

Not sure what you mean by mutexed version but I'll be watching!

vprimachenko commented 10 years ago

while i am working on the throttled/mutexed version a bit of insight into (what i suspect be the reason of) the crash:

colorcoder uses the view.add_region api to colorize the variables, this api allows to assign a single scope to multiple regions, the scopes corresond to the colors, which in thier turn corresond to the crc8 hashes of variable names. as there are 256 possible hashes, colorcoder issues 256 add_region calls. here comes the trouble: sublimes seem to repaint the text buffer after each of this calls, thus doing 256 costly operation which can cause a timeout and lead to a crash. colorcoder would only need to redraw the buffer once it finished. the definite way to solve this would be to be able to tell sublime 'please dont redraw, i am not quite done yet' (it also would allow to restore the highlight_current_line functionality, as you might have notices colorcoded variabled keep the default bgcolor even in active line, i have a test version with this feature but it lags like hell even on small files even on my machine, and i never expirience timeout-crashes). i have created a reature request in the forum for a requestAnimationFrame (for those familar with HTML/JS) like api, and i would be really gratefull if you could support me on that one, as it would benefit not only colorcoder but a few other plugins.

vprimachenko commented 10 years ago

and here goes an throttled version, it is a bit verbose: will tell you in the console how long it took to colorcode the file, if it doesnt do colorcoding at all.

there is a new setting max_size which tell colorcoder not to highlight files exceeding this size (in bytes), the default value is 10000, can be changed via settings file

chenglou commented 10 years ago

awesome, that was fast =D

michaelaye commented 10 years ago

Why don't u use github to distribute new versions?

vprimachenko commented 10 years ago

i try to let users experiencing problem test my fix before i push it as an update, so i would be gratefull if anyone could confirm this version to be more stable. also verbose version are meant to be used to diagnose errors and dont be pushed upstream

michaelaye commented 10 years ago

why not put them into a branch? It's just so much easier to install that way, that's why I'm asking. I'm really over this zip story long time ago. ;) However, this is only one file so I copied it over my existing one. Will report back shorty.

michaelaye commented 10 years ago

hm, does not work at all for me somehow. all syntax highlighting is gone and the console is quiet and there's no new setting called max_size ?

michaelaye commented 10 years ago

Aha: My file was 339 lines long and it must have triggered no-colorcoding, I looked at colorcoder.py and syntax coloring works there. But as I said, the setting max_size is not exposed in the Default settings?

michaelaye commented 10 years ago

Is it possible to adapt the coloring algorithm? I got these 3 variables next to each other that start with same prefix, but are different and end up having indistinguishable color: https://www.dropbox.com/s/kocrpwwawt849yx/Screenshot%202014-05-20%2017.47.24.pdf Edit: Well, only 2 of them are different, but maybe that's still fixable?

michaelaye commented 10 years ago

not really more stable, sorry. just crashed for me for a 115 lines file.

chenglou commented 10 years ago

https://github.com/vprimachenko/Sublime-Colorcoder/issues/10#issuecomment-43609744 didn't throttle, or at least not correctly. The console still accumulates all the colouring and fire them serially.

vprimachenko commented 10 years ago

@michaelaye

max_size is not exposed in the Default

yeah, but you still can set it in user preferences

[…] same prefix, but are different and end up having indistinguishable color […]

sadly its the way crc8 work, as i map all variable names to only one byte (as i am rather limited to 256 distinct colors, i could theoretically go up to 360 but i didnt found such a hashing function) a lot of collisions are possible. you can try to salt the hash by chaning the initial value of runningCRC to something what eliminate this collision. theoretically i could use crc16 and map those additional bits to lightsness and saturation but it results in rather unpleasent looking code.

not really more stable

i am sorry, i just cant reproduce this, and slowly running out of ideas… i have run colorcoder on 10mb files, it was slow but no crash occured, i tried it on my older laptop while underclocking it so colorocder had to struggle with minimal ram and ~2 GHz cpu, still stable. it is really a pain without a propper debugger and only diagnosing it remotely, so sorry agian it takes so long to fix it.

@chenglou

didn't throttle, or at least not correctly

does it ever print "already colorcoding, skipping for now"? what are the average times it reports it needed to highlight the file?

michaelaye commented 10 years ago

max_size

Understood.

crc8

Are you saying, currently your code is looking pleasant? ;) Just asking...

not stable

No need to apologize for the time it takes to fix it. You are very responsive and I would never ask more from an open source author. Also, this project is cutting edge on the available plugins for ANY editor in the world, so this is kinda ground-breaking! ;)

throttling

Maybe you can make sure to get more debug messages out? Because so far I have not seen anything printed out in the console. Should launching ST from the console via subl be enough to be able to get the feedback? BTW, I have ST3, could that be an issue?

vprimachenko commented 10 years ago

ST3

dunno but wait, you are on mac right (iirc subl is OSX only)…

@chenglou, @jeffling, @transat are you on mac too?

michaelaye commented 10 years ago

I'm on Mac, yes. And quite ashamed that I did not mention that earlier. Bad bug reporting. :scream: Now, for completeness:

chenglou commented 10 years ago

Yep, OS X 10.9.3 on MacBook Air.

jeffling commented 10 years ago

OS X 10.9.3 macbook pro ret

Zackio commented 10 years ago

I'm having this issue, any solution? I'm on a mac too. I guess it's mac issue.

vprimachenko commented 10 years ago

@Zackio it really seem so, and in that event theres little i can do about it. I really hope jps makes some update to stability to plugin_host soon. Anyway i hacked something together abusing some uncodumented api's: a new test version hopefully more stable. If you and @michaelaye @chenglou @jeffling could give it a test run and report is it would be really great.

Zackio commented 10 years ago

Its still doing it. I'm trying to see if I can spot when it happens as it can go for a while and be fine, then it just keeps doing it. I love the plugin BTW, best addition to my workflow, as I'm terrible at spelling.

vprimachenko commented 10 years ago

being an seemingly mac only issue, i doubt there is something i can do about it.

I will close this issue as wontfix, as the crash seem to have its roots not in my plugin per-se but in macs version ofplugin host`. I hope this will be fixed in future versions of sublime, if not i will contact John on this issue.