atom-ternjs icon indicating copy to clipboard operation
atom-ternjs copied to clipboard

Atom editor freezes up or becomes unresponsive

Open rcrichton opened this issue 9 years ago • 23 comments

For the last little while I have been struggling to use atom-tern. On some of my projects every now and then tern will cause the editor to freeze for up to 20s or sometimes it doesn't ever come back and I have to close the unresponsive editor.

I don't see any serious errors that may be related to this and am struggling to figure out what is going on. If someone could let me know how to look for more information I could post that here as well. For now I have nothing much to go on.

rcrichton avatar Jan 12 '16 09:01 rcrichton

I tried to capture a profile of an instance when these lockups occur. This is what I got:

flame-on

Here is the raw profile file to explore (you only need to look at the last 20s of the profile):

tern.cpuprofile.zip

rcrichton avatar Jan 12 '16 11:01 rcrichton

I'm having this issue as well and it's preventing me from using the plugin

jfkoch avatar Jan 14 '16 21:01 jfkoch

@tststs any idea how we could figure out what is going on here?

rcrichton avatar Jan 15 '16 07:01 rcrichton

There are several problems.

Performance significantly drops by how much files are analysed and passed to loadEagerly, if there are minified files loaded by tern a.s.o. Some people just pass the whole project + node_modules. I saw this quite a few times.

I'm currently working on some large projects and do not face any performance issues. But it seems most people facing the performance issue.

I think the best solution would be reverting this commit (c7452ed). I really like the idea of the tern-wrapper but it seems, that the performance loose by not using the node process is way too high.

tststs avatar Jan 17 '16 20:01 tststs

I too am having issues where this plugin locks up my editor mid typing lately. From my brief look at the developer tools trying to find the culprit, it looked like it was spending most of it's time on this section of code:

https://github.com/tststs/atom-ternjs/blob/2d61fe58ddd56e41f9895c682c05f8e6ad0a608e/lib/atom-ternjs-type.coffee#L128-L139

I'm not using loadEagerly at all.

AlexanderOMara avatar Jan 17 '16 21:01 AlexanderOMara

I'm having this issue even with very small projects. I'm only passing my index.js file to loadEagerly so I don't think that that is the issue.

rcrichton avatar Jan 18 '16 06:01 rcrichton

Could you both turn of inline suggestions and maybe tern-lint and give it a try? I will have a closer look at the timeline and type method today or tomorrow and see if i can spot the problem elsewhere.

tststs avatar Jan 18 '16 07:01 tststs

Thanks for the suggestion. Tern-lint has already been switched off for me. I will try with inline suggestions off today and report back.

rcrichton avatar Jan 18 '16 08:01 rcrichton

I tried fiddling with tern-lint earlier, didn't seem to make a difference. Where would one turn off inline-suggestions? I don't see such a setting in the plugin setting.

AlexanderOMara avatar Jan 18 '16 08:01 AlexanderOMara

I think it's this setting Display inline suggestions for function params.

rcrichton avatar Jan 18 '16 08:01 rcrichton

Its display inline suggestion for function params.

tststs avatar Jan 18 '16 08:01 tststs

Turned off both settings, restarted Atom, doesn't seem to have helped.

AlexanderOMara avatar Jan 18 '16 08:01 AlexanderOMara

ok, i was expecting this. i'll try to push the tern server to a web worker for the next release.

tststs avatar Jan 18 '16 08:01 tststs

Just a first try. Still pretty dirty and there are still quite a few things to do. But looking good so far. I'll keep you updated and hopefully get this done by the weekend.

tststs avatar Jan 19 '16 00:01 tststs

Ok, 0.13.0 should be available now. If you find any issues please feel free to report.

There are still some performance issues i spotted, but i hope this release will fix some of them.

The webworker was only tested on darwin. If there are any issues on linux or windows, report and i will try to fix them as soon as possible.

Greetings.

tststs avatar Jan 19 '16 19:01 tststs

Umm, now it's not working at all for me on OS X.

node.js:15 Uncaught TypeError: Cannot read property 'knownModules' of undefined (8) atom-ternjs-server-worker.js:34 Uncaught TypeError: Cannot read property 'request' of undefined

AlexanderOMara avatar Jan 19 '16 20:01 AlexanderOMara

Closed and restarted all instances of atom? If this does not help, please open an issue with additional info: .tern-project a.s.o.

Greetings.

tststs avatar Jan 19 '16 20:01 tststs

Yeah, even tried uninstalling, relaunching, installing, relaunching again, and still same issue. Restarting server also doesn't help. I will make a new issue.

AlexanderOMara avatar Jan 19 '16 20:01 AlexanderOMara

Well, it doesn't lock up the editor anymore which is nice, but it is acting funky. It appears that it slowly starts taking longer and longer to respond with suggestions. It also appears that as you are typing you might choose older completion hints, resulting in repeated characters if you select one of them. These issues appear more with larger and more-complex files. Restarting the tern server seems to help a bit when it builds up.

AlexanderOMara avatar Jan 19 '16 21:01 AlexanderOMara

I can think of a problem that might occur in large files, but haven't tested it yet. If the previous request isn't resolved yet, atom-ternjs still sends the next request on every action a.s.o. Haven't thought about that yet.

About how much LOC has the file, that produces the issue? I will test it tomorrow and try to find a way to solve this.

tststs avatar Jan 19 '16 22:01 tststs

I'm using a file with ~550 lines of JavaScript, which seems to consistently have the issue.

AlexanderOMara avatar Jan 19 '16 22:01 AlexanderOMara

This is still an issue I think. Tern constantly eats up 100% of CPU for even projects with only one index.js and no node_modules

My project is a mere package.json, package-lock.json and index.js (I removed the node_modules folder, I actually have uuid as dependency)

When I restart tern, Another worker is launched, while the previous one still runs. Killing atom doesn't solve this as ternjs seems to start own worker processes and detaches them (who thought this would be a good idea?) I'm using [email protected] but tried 0.18.2, 0.18.1 and 0.18.0 as well.

Needless to say, this is a pretty huge show stopper for me. Guess I'll try some dev builds from ternjs.

ptusch avatar Dec 07 '18 11:12 ptusch

@ptusch it is probably another issue though. I observe that each time I open Atom, I have in instance of atom-ternjs-server-worker.js that is using ~100% of one CPU and this process doesn't go away when I close Atom.

hugueschabot avatar Dec 15 '18 15:12 hugueschabot