Bug 474549 - copying two lines of javascript freezes eclipse
Summary: copying two lines of javascript freezes eclipse
Status: NEW
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.7   Edit
Hardware: Macintosh Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Victor Rubezhny CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-08 14:14 EDT by adam brin CLA
Modified: 2015-10-27 17:49 EDT (History)
5 users (show)

See Also:


Attachments
eclipse config info (761.28 KB, text/plain)
2015-08-08 14:14 EDT, adam brin CLA
no flags Details
eclipse log file (988.65 KB, application/octet-stream)
2015-09-10 13:21 EDT, adam brin CLA
no flags Details
eclipse diagnostics (osx) (40.46 KB, application/octet-stream)
2015-09-10 16:44 EDT, adam brin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description adam brin CLA 2015-08-08 14:14:07 EDT
Created attachment 255727 [details]
eclipse config info

If helpful, I have this same problem.  

Project:
https://bitbucket.org/tdar/tdar.src/

File:
src/main/webapp/js/maps/tdar.leaflet.js

Copying the first 2 lines (below) consistently crashes eclipse:

TDAR.leaflet = {};
TDAR.leaflet = (function(console, $, ctx) {



Version: Mars Release (4.5.0)
Build id: 20150621-1200
Comment 1 Victor Rubezhny CLA 2015-09-10 12:26:26 EDT
adam,

what do you mean by "copying first 2 lines..."?
The lines you're pointed are bit different from what you specified... Do you mean "copying whole the content"?.. Nothing is "crashing" for me when I either select whole the content or I collapse the definition and select the only 2 lines specified. Or maybe there is some precautions on how exactly the selection is to be done? 

And what do you mean by "eclipse crashes"? OOMEs/GC overhead limit exceeded in error log or a real application crash? Could you please attach .metadata/.log (with related exceptions) and/or hs<pid>.log (with thread dumps)?

Regarding the memory consumption... I can suggest you to add exclusions of **/*.min.js to any source root in Include Path of the project (Right click on the project, then select Properties->JavaScript->Include Path: Source tab). Then it needs to increase available memory settings (in ecipse.ini, for example). 

There is a problem with this project: it contains a whole (?) set of dependencies placed into /src/main/webapp/includes folder and it looks like the dependencies are just copied into this folder manually instead of getting them by usage of bower/npm. We're excluding the folders where bower/npm downloads the dependencies from parsing/validating but it's almost impossible to do with such a project. 

Bug #466260 for sure also plays a role in this issue, so there is a sense to wait for WTP Mars.2 (where it supposed to be fixed)

Thanks in advance.
Comment 2 adam brin CLA 2015-09-10 12:48:03 EDT
Hi Victor,
  Thanks for taking a look into this.  I'll try and take your comments one-by-one:

>> what do you mean by "copying first 2 lines..."?

If, in eclipse, I open tdar.leaflet.js in the Javascript Editor and select the first two lines of that file, and then hit Command+C to copy (mac).  Eclipse becomes unresponsive. In mac parlance, I get the "beachball" and do not get any error message. I've actually left eclipse open like this for 15 minutes waiting to see if it would be come responsive again, but it never does.

Since reporting the issue initially, it does seem like there's a correlation between copying some text that has a "$" in it. 

>> Regarding the memory consumption... I can suggest you to add exclusions of 
>> **/*.min.js to any source root in Include Path of the project (Right click on the
>> project, then select Properties->JavaScript->Include Path: Source tab). Then it 
>> needs to increase available memory settings (in ecipse.ini, for example). 

I've added exclusion and will see if this helps.

>> There is a problem with this project: it contains a whole (?) set of dependencies 
>> placed into /src/main/webapp/includes folder and it looks like the dependencies are 
>> just copied into this folder manually instead of getting them by usage of bower/npm. >> We're excluding the folders where bower/npm downloads the dependencies from 
>> parsing/validating but it's almost impossible to do with such a project. 

That is true, this project existed prior to bower being a widely adopted solution, and we're still in the process of migrating to it.

I'll attach a log file the next time we get this behavior.
Comment 3 adam brin CLA 2015-09-10 13:21:08 EDT
from OS X's console log:

9/10/15 10:15:29.000 AM kernel[0]: process eclipse[5190] thread 4599522 caught burning CPU! It used more than 50% CPU (Actual recent usage: 84%) over 180 seconds. thread lifetime cpu usage 153.288770 seconds, (86.832486 user, 66.456284 system) ledger info: balance: 90020199061 credit: 151559782103 debit: 61539583042 limit: 90000000000 (50%) period: 180000000000 time since last refill (ns): 106963563650 

9/10/15 10:15:31.667 AM spindump[23807]: Saved cpu_resource.diag report for eclipse version 4.5.0 (4.5.0.I20150603-2000) to /Library/Logs/DiagnosticReports/eclipse_2015-09-10-101531_Adams-iMac.cpu_resource.diag


9/10/15 10:19:31.041 AM com.apple.xpc.launchd[1]: (org.eclipse.platform.ide.51436[5190]) Service exited with abnormal code: 143

attaching additional files (though hs<pid> files found, and I didn't see any log entries found in the related timespan.
Comment 4 adam brin CLA 2015-09-10 13:21:36 EDT
Created attachment 256495 [details]
eclipse log file
Comment 5 Victor Rubezhny CLA 2015-09-10 14:41:31 EDT
Adam, 

Regarding your .log file I've found the following things:

1) I see a number of "class/source not found" stacktraces by jdt... I don't have any of similar stacktraces, so it looks like your project has some incorrect settings regarding Java Build Path. Maybe it's because of some improper maven configuration in pom.xml's, or maybe you did changed something manually, so you'd better check it.

1) It looks like you're using Tern.java. This currently doubles the parsing/validation as well as the memory consumption. You should try WTP Mars.2 (is to be released soon) where there will be possible to turn JSDT parsing off (it's good to do this in case Tern.java is used)

2) It looks like your eclipse was stopped by OS because of: "9/10/15 10:15:29.000 AM kernel[0]: process eclipse[5190] thread 4599522 caught burning CPU! It used more than 50% CPU (Actual recent usage: 84%) over 180 seconds.".
Sorry, I don't have/use Mac, to be sure, but it looks like some interesting info on the crash is written to /Library/Logs/DiagnosticReports/eclipse_2015-09-10-101531_Adams-iMac.cpu_resource.diag file. Not sure if this file has a human readable format, but, if it has, could you attach it to the issue? I hope somebody who is using Macs could explain on that .diag file in more details.

Thanks in advance.
Comment 6 adam brin CLA 2015-09-10 16:44:49 EDT
Created attachment 256500 [details]
eclipse diagnostics (osx)
Comment 7 adam brin CLA 2015-09-10 16:50:21 EDT
1) I've attached the debug file.
2) pardon my ignorance, I don't know what Tern.java is or how it would be turned on -- can you point me to where I might figure out how to turn it off / on?
3) I think the "Class not found" issues have to do with switching between branches of our source-code and files not existing as eclipse may or may not have refreshed its context.  One of our branches has a major refactor of our overall codebase.

thanks.
Comment 8 Angelo ZERR CLA 2015-09-11 00:55:31 EDT
Adam,

Your problem with tern.java is because it seems that you have a lot of JavaScript files to parse in your project. Please read https://github.com/angelozerr/tern.java/wiki/Tern-Performance

It seems that you are using 0.10.0, so I suggest you that you install 1.0.0 because it provides the capability to exclude path (it uses the exclude path of JSDT Include Path)

Hope it will help you.

Regard's Angelo
Comment 9 Mickael Istria CLA 2015-09-11 01:17:39 EDT
Moving to JSDT.
If it appears to be an issue caused by Tern.java, please close this issue as NOT_ECLIPSE and repprt it against the tern.java project issue tracker at GitHub.
Comment 10 Victor Rubezhny CLA 2015-09-11 06:53:41 EDT
(In reply to Mickael Istria from comment #9)
> Moving to JSDT.
> If it appears to be an issue caused by Tern.java, please close this issue as
> NOT_ECLIPSE and repprt it against the tern.java project issue tracker at
> GitHub.

When trying to reproduce the issue I found some problem JSDT Include Path configuration when the project is imported by Maven (m2e-wtp) that makes JSDT and Tern.java to process more files than it actually needs to process. 
So, I have a reason not to close the issue, since I have a problem to fix in JSDT and a working example that allows to reproduce the issue and test the fix.

But I still not sure why MacOSX kills eclipse (if it's what really happens)... On Fedora 21 I see some OOMEs and performance glitches, but no crashes.

Having a patch for Bug #466260 applied and a properly configured Include Path on the project makes it usable for me with 512M memory available.
Comment 11 Angelo ZERR CLA 2015-09-11 07:41:56 EDT
Vicor, pay attention, if you have a problem with JSDT Include Path which is not used by tern.java, please create an issue to tern.java (and if it's possible create a PR)

tern.java transforms JSDT Include Path to tern script path and the include/exclude is done by tern.java by using minimatch.java https://github.com/angelozerr/minimatch.java
Comment 12 adam brin CLA 2015-09-15 14:30:03 EDT
I uninstalled TERN.java (which was included as part of JBOSS tools) on Friday and have been testing today. I have not yet gotten the application to completely crash, but it still has between 5-30 seconds of unresponsiveness when I "copy" javascript code, so I'm not 100% sure that TERN is the root cause of the issue.
Comment 13 adam brin CLA 2015-09-15 14:44:39 EDT
(but I also don't mean that this is 100% eclipse's issue either as there may be another part of JBOSS tools that's causing this)