Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Tern freezes Brackets for certain JS libraries #3977

Closed
caiotoon opened this issue May 23, 2013 · 54 comments
Closed

Tern freezes Brackets for certain JS libraries #3977

caiotoon opened this issue May 23, 2013 · 54 comments

Comments

@caiotoon
Copy link

After updating to Sprint 25, my Brackets is constantly freezing. It's not like a Windows freeze, the windows simply become empty (no left panel, no menu and no content).

When its frozen, I can move the window and click minimize and close button, but Brackets doesn't close. I have to kill the process.

The problem occurred while editing code, on ALT+Tab, when not using it... seem to have no pattern.

Windows 7
Brackets Sprint 25
No extensions installed

@redmunds
Copy link
Contributor

@caiotoon Sorry to hear you're having problems with Sprint 25. This is the first we've heard of this problem, so please try to remember what you did right before it happens again to help us find a pattern. Also, try clearing your cache (https://github.com/adobe/brackets/wiki/Cache-Folder). Maybe some data from previous sprint is causing a problem. Let us know if you have any more info!

@njx
Copy link

njx commented May 23, 2013

Also, do you have Chrome installed? If so, when this happens, try going to http://localhost:9234 in Chrome.
You should get a page saying "Inspectable WebContents", and then below that there should be a link that says Brackets (or possibly something else if Brackets is really hosed). Clicking on the link should bring up the dev tools for Brackets. Down at the bottom right of the window, if there was a logged error, there should be a red X icon. Click on that to see if there's anything suspicious in the console.

@njx
Copy link

njx commented May 23, 2013

I also wonder if it might be another case of #3827. @caiotoon, are you working with a large project, or with some files that might be large?

@caiotoon
Copy link
Author

@njx just happened again. http://localhost:9234 shows only the title "Inspectable WebContents", no other content. The <div class="items"> in DOM is empty. My Brackets folder have around 500 files, but files are not that big individually. There are some images on the folder, but not that big. Is there another way of opening its console?

Here is a print screen:

image

@redmunds as I said, there is no pattern. Sometimes it happens on alt+tab, sometimes when I'm typing, others just after saving. I haven't tried cleaning cache yet. Will after testing @njx ideas.

@caiotoon
Copy link
Author

Just an additional info, I currently have both Sprint 24 and 25 installed, as 25 is not working. Does the URL in Chrome remains the same?

@njx
Copy link

njx commented May 23, 2013

It's looking like this might be a memory leak. We're looking into it. Thanks for the info!

@njx
Copy link

njx commented May 23, 2013

Couple of more questions:
(1) Are you reloading Brackets at all? If so, that might contribute to the memory leak.
(2) If you're comfortable messing with the contents of your Brackets install, could you temporarily move aside the folder www/extensions/default/JavaScriptCodeHints somewhere outside the Brackets folder, restarting Brackets, and using it for awhile? You won't get code hints in JS, but it would be good to know if this is causing the crashes.

@jbalsas
Copy link
Contributor

jbalsas commented May 23, 2013

Hey guys, just a little bit more of info. I also hit this yesterday on sprint 24 (786bb99).

For what it's worth, I was messing around with the CodeMIrror project, and Brackets was freezing on codemirror.js, so maybe you're on the right track.

You may try to reproduce it with that one. I'll try to see if I can get more info later today.

@caiotoon
Copy link
Author

@njx I used it for a while right now (without code hint) and the problem didn't happen. I was quit and reopening Brackets, but didn't hit F5.

I'll continue using until the end of the day and post back the result.

@njx
Copy link

njx commented May 23, 2013

@caiotoon Thanks for looking into this. In your project, how many of the files would you say are JS files?

@njx
Copy link

njx commented May 23, 2013

Also, are you using any frameworks (e.g. ember, angular, ...)?

@gruehle
Copy link
Member

gruehle commented May 23, 2013

I ran into the blank screen issue a couple times this morning. I can reproduce with these steps:

  1. Open the unit tests window
  2. Click on "LowLevelFileIO"
  3. While the tests are running, click "Reload"

BOOM - blank screen.

@njx
Copy link

njx commented May 23, 2013

@jbalsas Were you editing CodeMirror in the context of Brackets (i.e., did you have the brackets folder open as the project root, or just the CodeMirror folder)?

@gruehle
Copy link
Member

gruehle commented May 23, 2013

I've isolated the reload crash and put up a pull request to fix it:
adobe/brackets-shell#249

The pull request only fixes the reload case. Other cases like clicking in the editor, Alt+Tab, etc. are not addressed.

@jbalsas
Copy link
Contributor

jbalsas commented May 23, 2013

@njx Just the CodeMirror folder (not the one inside Brackets though, just a fork of it).

It looks like the issue is with the Brackets Helper process. I've seen it maxed out at 200% CPU usage and 900Mb of Memory.

What I do is:

  1. Open CodeMirror folder in Brackets
  2. Open codemirror.js
  3. Play around hitting ctrl+espace to invoke the code hints and then esc to dismiss them several times

Quite soon, a noticeable delay presents when invoking the code hints. After a certain while (1 or 2 minutes) code hints don't appear anymore, and around 3 or 4 minutes Brackets freezes. At this moment, I can't see the Brackets Helper process anymore, so I assume it's crashed.

I've also profiled in Chrome, and although memory does seem to grow on every codehints invocation, it looks like it's garbage collected properly and stays below 30Mb. Also, when Brackets freezes, nothing shows on Chrome dev tools (Elements panel shows empty).

Hope this helps tracking this down.

@njx
Copy link

njx commented May 23, 2013

@jbalsas Great! (Well, not great :)) I can repro with your steps, though I have to open and close code hints a bunch.

One thing we noticed is that while the memory usage is climbing up (and especially after the code hints stop working), the Brackets Helper process is pegged at 100% CPU. So it does seem like the worker is getting hosed.

@jrowny
Copy link
Contributor

jrowny commented May 24, 2013

This is very similar to the problem I was hitting with codehints on Angular.js. I was getting the exact same kind of crash. The problem ended up being in Tern.

@njx
Copy link

njx commented May 24, 2013

Yup, that one got fixed, but this seems to be a different case. Could be a similar underlying cause that didn't happen to get fixed.

@caiotoon
Copy link
Author

Not sure if it's still helpful, but the problem didn't happen while js hint was disabled.

Also, I'd say the project have 150~200 script files. I use AngularJS, jQuery and some other libraries.

Hope this help.

@adrocknaphobia
Copy link
Contributor

@eztierney reports that this fix to Tern.JS might resolve the issue: ternjs/tern@bf369cc

@MiguelCastillo
Copy link
Contributor

I also run into this issue when I use my tern hinting extension. This only happens with large code bases. I debugged it once for a bit and I noticed that sending hinting requests triggered by document changes to tern while already waiting for a hint request was slowing down tern quite a bit. Eventually hints don't come up and the screen goes blank. Marijn reduced reduceMaxWorkDepth and that seemed to have helped a lot.

@ghost ghost assigned njx and eztierney May 24, 2013
@pthiess
Copy link
Contributor

pthiess commented May 24, 2013

Great effort from all contributors to track this down quickly. Made this a high priority issue and assigned @eztierney . @njx should we integrate tern with the fix from marijnh - its 2 commits away from what we currently integrated?

@eztierney
Copy link
Contributor

Submitted a pull request to update tern - it doesn't totally fix the problem, but it does slow down the memory growth.

@eztierney
Copy link
Contributor

@MiguelCastillo thats interesting - just this morning I saw tern do something similar, and I was making more hint requests before the previous ones had finished. I haven't been able to reproduce it, but maybe there is some lurking bug there...

@MiguelCastillo
Copy link
Contributor

@eztierney I am thinking that coming up with a way to queue hint requests when editing the document might be a good idea. I can reproduce the problem when typing quickly. I also have lots of requirejs dependencies, so I am not sure if tern has to do something special. I havent had much time to figure out what's really happening but maybe this long weekend I can.

@gruehle
Copy link
Member

gruehle commented May 24, 2013

@caiotoon @jbalsas @MiguelCastillo and anyone else who has run into this issue: we just pushed changes to master that significantly decrease memory usage with code hints. Could you pull the latest code and see if you can still reproduce the problem? Thanks!

@eztierney
Copy link
Contributor

@MiguelCastillo thanks for the info - I tried reseting the ternInstance.files, which we weren't doing, but it did not seem to help the memory problems in this case. So far the only thing I have found that works is terminating the worker thread we run tern in, which is less than ideal, but at least it works.

@jrowny
Copy link
Contributor

jrowny commented Jun 5, 2013

Still hitting this occasionally, but it can take up to an hour to happen.

@jeffkenton
Copy link
Contributor

I have a case where I can freeze Brackets first try, almost every time:

I did a QuickEdit search that brought up an inline editor window. With that window still open, I clicked Debug->Show Performance Data. Performance data came up and Brackets was dead.

Not the same case others are reporting, but dead frozen. This is also reproducible with Sprint 24.

@redmunds
Copy link
Contributor

redmunds commented Jun 5, 2013

@jeffkenton Please open a new issue for that case. Thanks.

Done: Issue #4121 (jeffkenton)

@pthiess
Copy link
Contributor

pthiess commented Jun 7, 2013

@eztierney @pfarland - I'm moving this out into the next sprint. I believe the current state is that we have a short term fix. I'm not clear if there are better ways to architect around the issue or if we perceive it as a FOL. Lets meet and talk about the options we have moving forward.

Thanks,
Peter :)

@gruehle
Copy link
Member

gruehle commented Jun 27, 2013

Bumping the priority down to medium since most people are no longer running into this issue.

If anyone has reproducible steps with the current build, please add them here.

@zaggino
Copy link
Contributor

zaggino commented Jul 9, 2013

I downloaded sprint 27 today and it freezes (like described above) as soon as I open my project folder ... sprint 26 was at least working for a few minutes for me. I tried clearing the cache and also deleting all the extensions / reinstalling but nothing helped.

@njx
Copy link

njx commented Jul 9, 2013

@zaggino - that sounds bad, and possibly different from what we've noticed before, if it literally happens as soon as you open the folder (is there any delay between when you open the folder and when it freezes?). What OS are you on? Can you look at Task Manager (Win) / Activity Monitory (Mac) and see if the Brackets or Brackets Helper process is using a lot of memory?

@zaggino
Copy link
Contributor

zaggino commented Jul 9, 2013

Actually after reinstall: it happens right after (less than 5 seconds) I open almost any file (before reinstall probably some file was always opened on startup, but if there are no opened files, it won't crash). OS is Win7 64bit. When I turn on the brackets, I have two brackets.exe processes running and one brackets-node.exe process running. I can open small files less than about 30-40 lines of code ... I can't open anything bigger without brackets crashing.
s1

@zaggino
Copy link
Contributor

zaggino commented Jul 9, 2013

This is 100% related to a large project in currently opened folder as when switch to another folder and try to open my files, everything works fine. Project itself includes many libraries like jquery, bootstrap, and so on and also includes a lot of own javascript code ... about 150 files.

@eztierney
Copy link
Contributor

@zaggino When we've seen this before it's usually been caused by 1 particular version of a library file (bootstrap, angular, ember, etc). The trick is figuring out which one is the problem.

You can either try removing the library files, or with Sprint 27 we added a configuration file for code hints that you can use to exclude certain files, or directories. You can create a file named .jscodehints and put it in the directory you are opening with brackets. The file should look something like:

{
"excluded-directories" : ["/lib"],
"excluded-files" : ["file1.js", "file2.js"]  
}

That would exclude all the files in the lib directory, and any files named file1.js or file2.js. You could use that to try to narrow down which file it is, and to work around the problem and still get codehints for the rest of your code.

Alternatively, if the project is public and you could point us to it, we could take a look at it and try to narrow it down.

@zaggino
Copy link
Contributor

zaggino commented Jul 10, 2013

@eztierney Great feature indeed. I tried excluding just node_modules directory and everything seems stable for now (it includes latest async, express, mongodb, q, underscore).

Strange enough - when I cancelled the directory exclusion so I can pinpoint exact library it's still working. I will definitely play with it and see if I can pinpoint particular library that's causing problems. Reading the sources of brackets I suppose I can just use max-file-size: 1 to turn off hints completely when the problems will return but hopefully they won't.

@zaggino
Copy link
Contributor

zaggino commented Jul 10, 2013

How the temp folder works ? I managed to lock out brackets that it didn't even start properly after taskkill-ing it so I tried removing everything in cache folder (\AppData\Roaming\Brackets\cef_data) but it didn't help. Then I restarted the entire Windows and it's working again ... Are brackets saving temp data somewhere else too?

@njx
Copy link

njx commented Jul 10, 2013

@cfjedimaster reported on the Google Group that the Parse library also seems to cause the Tern crash. https://groups.google.com/d/msg/brackets-dev/LdHhNFs_m-k/vjsxUdDxpecJ

@RaymondLim
Copy link
Contributor

I can reproduce it consistently on my Windows 7 with ExtJS. And I also narrow it down to only two files from ExtJS -- ext.js and ext-debug.js. If you have one of them in your project folder, then you don't see the issue, but if you have both of them, then you can get Brackets frozen in a minute. You can watch the memory consumption in Processes tab of Task Manager. And the same two files have no issue with sprint 26.

Update 1: I can reproduce it on Mac with the same two files. Replacing the entire thirdparty folder under extensions\default\JavaScriptCodeHints\ with the one from sprint 26 does fix the issue.

Update 2: I confirmed that this issue is introduced with this commit in Tern ternjs/tern@2010f93.

Update 3: Others are experiencing the same memory issue and has logged this Tern issue ternjs/tern#185.

@dangoor
Copy link
Contributor

dangoor commented Jul 11, 2013

I just tried the Parse library in a fresh project. In that environment, it does not fail. As @RaymondLim notes, the problem may be with certain combinations of files. Raymond also narrowed the problem down to a specific commit in Tern

@dangoor
Copy link
Contributor

dangoor commented Jul 11, 2013

Further note about Parse. I've tried the combination of Parse+jQuery as noted on the mailing list and have seen no problems yet.

@dangoor
Copy link
Contributor

dangoor commented Jul 11, 2013

Another update: I have filed a new Tern issue on the Ext case that @RaymondLim identified. I have managed to cut the vast majority of the code out of the Ext files and still reproduce the issue. I'm not sure that the failure there is a general case.

@njx
Copy link

njx commented Jul 17, 2013

Hi folks--we've made some progress on the various Tern issues. We have fixes for a number of them, but we're still tracking a specific crash in #4400 that appears to be a bug in Chromium. For now, we'll close this bug. If you continue to run into issues in the next sprint (Sprint 28), please file a new bug with details. Thanks.

@njx njx closed this as completed Jul 17, 2013
@caiotoon
Copy link
Author

Thanks, guys.

@ghost
Copy link

ghost commented Jun 15, 2015

It is 2 years later and I am still having this issue

@ByteJuggler
Copy link

For what it's worth: I've recently installed Brackets 1.3. It worked fine, though admittedly I did not do a great deal with it yet. Tonight when I ran it again, it notified me of a new version, 1.4. Since installing it, hitting F5 with a trivial page is consistently locking up Brackets as per the first post in this thread (white screen, requires task manager to kill.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

17 participants