This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242545 - Updating JavaScript libraries takes too long, and overloads the CPU.
Summary: Updating JavaScript libraries takes too long, and overloads the CPU.
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal with 5 votes (vote)
Assignee: Jan Stola
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-04 10:57 UTC by vlntyn
Modified: 2015-08-21 01:54 UTC (History)
5 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vlntyn 2014-03-04 10:57:48 UTC
Steps to reproduce:
In new 'HTML5 Application' creation dialog, step 4 (JavaScript Files) press 'update' (update the list of JavaScript libaries).

NetBeans starts a large file download (285.8 MB) without any notification to the user.
'https://github.com/cdnjs/cdnjs/archive/master.zip'
GitHub, where the file is hosted throttles the download of this file down to ~25-40 KB/sec, so the download will take approximately 2.5 hours.
Meanwhile NetBeans IDE uses a big amount of CPU resources.

Expected behaviour:
1. On pressing 'update' NetBeans IDE should only update the list of available libraries (download small text file ) and their current version;
2. Download only selected JavaScript libraries on demand (smaller download size);
3. Do not load the CPU while updating and downloading.

- - - -
Product Version = NetBeans IDE 8.0 RC1 (Build 201402242200)
Operating System = Mac OS X version 10.9.2 running on x86_64
Java; VM; Vendor = 1.7.0_51
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.51-b03
Comment 1 vlntyn 2014-03-07 08:21:34 UTC
Better solution:

1. On pressing 'update'-Label, only a list of JS-libraries should be downloaded from 'http://cdnjs.com/packages.json' (~7.5 MB). 

2. Parse the downloaded JSON-file, and fill the table.

3. Download only user selected JS-libraries on demand, by generating a link from the following template:
'http(s)://cdnjs.cloudflare.com/ajax/libs/{name}/{version}/{filename}'
(e.g. 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.10/angular.min.js')


PS: I can provide source code (patch) for this solution. Just get in touch with me.
Comment 2 Tomas Mysik 2014-03-07 08:36:26 UTC
(In reply to vlntyn from comment #1)
> PS: I can provide source code (patch) for this solution. Just get in touch
> with me.

If you could do that, it would be perfect!

Thanks a lot!
Comment 3 Tomas Mysik 2014-03-07 08:37:59 UTC
BTW this change would mean that you must be online in order to install JS library - not sure if it is a problem or not (likely not, the same applies for the bundled JS libraries).

Thanks.
Comment 4 vlntyn 2014-03-07 15:43:33 UTC
(In reply to Tomas Mysik from comment #2)

To make it clear... the patch is not written yet, but I can make one.
What I need is time and some assistance (never worked on NetBeans code before).

As far as I understand, the module I have to work on is called 'web.clientproject.api'.

What are the requirements to compile the module?
'cd web.clientproject.api && ant' doesn't compile...

Greetings
Comment 5 Tomas Mysik 2014-03-10 08:03:29 UTC
(In reply to vlntyn from comment #4)
> To make it clear... the patch is not written yet, but I can make one.
> What I need is time and some assistance (never worked on NetBeans code
> before).

I would be more than happy to help you with it, of course. A good start is our FAQ for developers, see [1] (pick just what is interesting for you). Do not hesitate to write me directly to my e-mail.

> As far as I understand, the module I have to work on is called
> 'web.clientproject.api'.

Yes, the class you need to improve is CDNJSLibrariesProvider - all the operations are there (reading & updating the libraries). There is also a test for it (CDNJSLibrariesProviderTest) so please, improve it if possible to verify that it works as expected.

One note: I am not sure whether it will be possible to implement the JS libraries as you intent to do since we use common Library API and there could be some limitations - you will see :)

> What are the requirements to compile the module?
> 'cd web.clientproject.api && ant' doesn't compile...

Basically, the good start to work with NB sources is this wiki page [2]. If one wants to provide a patch, it should be easy since NB uses Mercurial - please, have a look at this wiki page how to do that [3].

BTW it is a good idea to build only e.g. PHP cluster (it takes much less time than the whole IDE):

ant -Dcluster.config=php build-nozip

Thanks a lot!
[1] http://wiki.netbeans.org/NetBeansDeveloperFAQ
[2] http://wiki.netbeans.org/WorkingWithNetBeansSources
[3] http://wiki.netbeans.org/HgHowTos
Comment 6 ikarus.nc 2014-04-14 10:20:24 UTC
Hi, I think there another problem related, when I update the cdnjs file the download doesn't take so much time but the js libraries list is stucked in a infinite "loading...", cleaning the cache does't resolve the problem, tell me if I have to open a new issue. Thank you

- - - -

Product Version: NetBeans IDE 8.0 (Build 201403101706)
Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Windows 7 version 6.1 running on amd64; Cp1252; it_IT (nb)
Comment 7 Tomas Mysik 2014-04-14 10:50:54 UTC
@ikarus.nc: Yes, please, submit a new issue and attach a profiler snapshot [1] taken during the infinite loading.

Thanks.
[1] http://wiki.netbeans.org/FaqProfileMeNow
Comment 8 Manachi 2014-09-27 12:12:08 UTC
This bug is really painful! My Netbeans is "Updating JavaScript libraries" at 39% after 2 hours+.  I'd scheduled some work time to sink my teeth into a new HTML5 project and it's totally stopped me in my tracks - for hours! It's a pretty serious bug I think.

Comment 1 sounds like a logical approach to a solution. (only download the latest file list, then download only the selected libraries). Any news on this?
Comment 9 Tomas Mysik 2014-09-29 05:28:25 UTC
Yes, this issue will be solved in the next NetBeans version.

Thanks.
Comment 10 terje7601 2014-11-05 12:11:05 UTC
I believe that, instead of downloading the packages.json file, it would be much better to use the API as described here: https://github.com/cdnjs/cdnjs#api

Not only because it's an official, supported way. But also because it's much more efficient: firstly, the packages.json contains plenty of data that NetBeans doesn't need. And secondly, with the API you can define the fields you want to retrieve & add a search query. E.g. retrieving a list of all libraries, with just "name", "version" and "latest" (a link to the latest version) is only 112.51 KB (using http://api.cdnjs.com/libraries?fields=version).

What do you think?
Comment 11 Tomas Mysik 2014-11-05 12:16:45 UTC
@terje7601: Try the dev build of NetBeans ;)
Comment 12 terje7601 2014-11-05 15:02:11 UTC
(In reply to Tomas Mysik from comment #11)
> @terje7601: Try the dev build of NetBeans ;)

:) That's just great, thanks.

Upon trying it out, I encountered a couple of issues:
* when trying to download the "d3" library, I got this exception: http://statistics.netbeans.org/analytics/exception.do?id=748843
* when downloading libraries, like "jquery" & "jquery-ui", a lot of files contain garbage. For example this file http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/css/jquery.ui.all.css is downloaded as garbage (lots of squares etc.) Just a wild guess: maybe the files are not "gzip decompressed"?
* NetBeans considers the latest version of jquery to be "2.1.1-rc2", even though the actual latest version is "2.1.1"
Comment 13 Vladimir Riha 2014-11-05 15:11:45 UTC
(In reply to terje7601 from comment #12)
> * when downloading libraries, like "jquery" & "jquery-ui", a lot of files
> contain garbage. For example this file
> http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/css/jquery.ui.all.css
> is downloaded as garbage (lots of squares etc.) Just a wild guess: maybe the
> files are not "gzip decompressed"?

It could be some encoding issue, it works fine for me. I'll try it later on non UTF8 system.

> * NetBeans considers the latest version of jquery to be "2.1.1-rc2", even
> though the actual latest version is "2.1.1"

Reported as #248426, thanks for catching that
Comment 14 terje7601 2014-11-06 10:39:24 UTC
(In reply to Vladimir Riha from comment #13)
> (In reply to terje7601 from comment #12)
> > * when downloading libraries, like "jquery" & "jquery-ui", a lot of files
> > contain garbage. For example this file
> > http://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/css/jquery.ui.all.css
> > is downloaded as garbage (lots of squares etc.) Just a wild guess: maybe the
> > files are not "gzip decompressed"?
> 
> It could be some encoding issue, it works fine for me. I'll try it later on
> non UTF8 system.

I reported this as bug 248453, as I have found "evidence" that it's actually due to gzip compression.
Comment 15 benji2006 2014-12-06 20:37:29 UTC
I am still seeing the problem reported earlier  - once the update finally finished, there is an infinite "loading"....version 8.0.2....just wasted a few days trying out Netbeans for HTML5 development only to be stuck on this....




ikarus.nc@netbeans.org 2014-04-14 10:20:24 UTC
Hi, I think there another problem related, when I update the cdnjs file the download doesn't take so much time but the js libraries list is stucked in a infinite "loading...", cleaning the cache does't resolve the problem, tell me if I have to open a new issue. Thank you

- - - -
Comment 16 Vladimir Riha 2014-12-06 22:35:24 UTC
Upcoming 8.1 will have new and better way to handle JS libraries. It is already implemented for CDNJS libraries, you can try it in nightly Dev build from http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 17 mhh1422 2014-12-28 06:29:55 UTC
(In reply to Vladimir Riha from comment #16)
> Upcoming 8.1 will have new and better way to handle JS libraries. It is
> already implemented for CDNJS libraries, you can try it in nightly Dev build
> from http://bits.netbeans.org/download/trunk/nightly/latest/

I have faced the same problem (downloading 1.5GB, taking time, then failing). The new way is great and much more efficient.
Comment 18 aeps 2015-04-23 11:05:50 UTC
With a root server with high bandwith: 2,35G  21,8MB/s   in 2m 3s