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

Code hints: CPU stays at 100% with specific project, may eventually crash #7245

Open
peterflynn opened this issue Mar 19, 2014 · 9 comments
Open

Comments

@peterflynn
Copy link
Member

This code is derived from the following project: https://github.com/etrepum/platformer-melon-js -- if you clone that and do a grunt build, you'll also hit the bug. The testcase here is simplified.

  1. Download the files from https://gist.github.com/peterflynn/9635216 and place them all in one folder
  2. Open the folder in Brackets
  3. Open melonJS-0.9.11.js

Result:
One CPU core goes to 100%, and Brackets memory usage climbs continuously. (Sometimes it seems to level off around 800-900 MB even though CPU remains at 100% afterward; other times memory usage keeps climbing until it crashes).

If any one of the 4 files is removed, Brackets tops out at about 400 MB of memory usage and CPU returns to normal afterward.

@peterflynn
Copy link
Member Author

If I delete roughly the bottom half of melonJS-0.9.11.js (from line 8571), memory usage levels off at around 740 MB and the CPU returns to normal... so maybe this really is simply too much code to handle, and not an infinite loop of any kind (the seemingly much-longer freeze with only slightly more code could be due to GC thrashing).

Are we filtering out large files from Tern? It seems like anything over 100-200 KB is a safe bet that it's a minified library or build artifact that should be ignored...

@peterflynn
Copy link
Member Author

...and deleting the bottom half of app.js (from line 9731) gets it to level off at ~840 MB

@Qantas94Heavy
Copy link

According to https://github.com/adobe/brackets/wiki/JavaScript-Code-Hints:

  • max-file-size
    Files larger than this number of bytes will not be parsed. The default value is 524,288 bytes (512KB).

This is probably a conservative value, feel free to change it yourself in a .jscodehints file in the project root if your project doesn't contain any other files over your limit for code hints.

@dangoor dangoor self-assigned this Mar 19, 2014
@dangoor
Copy link
Contributor

dangoor commented Mar 19, 2014

@peterflynn I'm pretty sure it's not just a matter of it being "too much code to handle". These cases seem to often be edge cases for Tern's inference. This is probably not a narrow enough case for Marijn to troubleshoot, though. Minified files aren't so good for code completion anyhow.

I wonder if there's a way that we could detect a case like this, prompt the user and then save a file exclusion?

@peterflynn
Copy link
Member Author

Nominating for 1.0 -- I'm not of the view that Brackets has to magically just work in project with 200 MB of JS code, or 100,000 files, etc., but (a) this project wasn't really that big, and (b) we should fail a little more elegantly than just crashing.

(Same goes for #7262 - not sure whether to dupe that to something else yet or not)

@peterflynn peterflynn changed the title Code hints: CPU stays at 100% with specific project Code hints: CPU stays at 100% with specific project, may eventually crash May 2, 2014
@redmunds
Copy link
Contributor

@peterflynn @dangoor Is anyone still seeing this one? Using Peter Flynn's gist the cpu barely moves on Mac 10.8. On Win7, cpu maxes out for ~30 sec, then it goes back to normal.

UPDATE: OK, I'm seeing same behavior on Mac as Win now. Brackets UI is functional and responsive during this time, so it doesn't seem bad.

@dangoor
Copy link
Contributor

dangoor commented Jun 13, 2014

@redmunds This is the kind of case for which the new timeout in Tern should be handy. Marijn would like reproducible cases, but to stop the pain today just being able to disable hints for problematic files will help.

@dangoor
Copy link
Contributor

dangoor commented Aug 13, 2014

This issue is fixed in master (you get a popup warning you about problem files and exclusions are automatically added for those files). I was able to successfully get hints for app.js, though it's possible that even that file will fail for some people because it's so large.

Note that I just filed #8750 because it appeared that I needed to reopen the project after the exclusions were added in order for hinting to work.

FBNC to @peterflynn

@redmunds
Copy link
Contributor

redmunds commented Oct 2, 2014

This was fixed in 0.43 so changed Milestone.

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

6 participants