Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too much CPU cycles & memory on Gulp watch after the latest cli updates #428

Closed
SecuriTeam opened this issue May 19, 2015 · 10 comments
Closed

Comments

@SecuriTeam
Copy link

Hello,

I'm experiencing too much CPU & memory usage after the latest cli updates..

I've come to notice that it occurs when there are rapid notifications to the gulp watch process due to rapid change/save.

It happens a lot and each time I have to kill the live reload and initiate another because my browser tab/window become unresponsive.

If there is anyway to provide you with logs or something, please help me help you.

Your system information:

Cordova CLI: 5.0.0
Gulp version:  CLI version 3.8.11
Gulp local:   Local version 3.8.11
Ionic CLI Version: 1.4.3
Ionic App Lib Version: 0.0.19
OS: Windows 7 SP1
Node Version: v0.12.2
@SecuriTeam
Copy link
Author

Upgrading to CLI 1.4.4 to see if it makes any difference.

Edit: it's even worse than what it was!
the app stops loading on the first page after gulp finishes minifing my SCSS files.

ionic $ [01:24:26] Using gulpfile g:\fakepath\gulpfile.js
[01:24:26] Starting 'sass'...
[01:24:26] Starting 'watch'...
[01:24:26] Finished 'watch' after 89 ms
CSS changed:  g:\fakepath\www\assets\css\style.css
CSS changed:  g:\fakepath\www\assets\css\style.min.css
[01:24:30] Finished 'sass' after 3.4 s
[01:24:30] Starting 'default'...
[01:24:30] Finished 'default' after 8.98 ?s
q
Closing Gulp process

g:\fakepath>ionic serve --lab
Gulp startup tasks: [ 'default', 'watch' ]
Running live reload server: http://localhost:35729
Watching : [ 'www/**/*', '!www/assets/lib/**/*' ]
Running dev server: http://localhost:8100
Ionic server commands, enter:
  restart or r to restart the client app from the root
  goto or g and a url to have the app navigate to the given url
  consolelogs or c to enable/disable console log output
  serverlogs or s to enable/disable server log output
  quit or q to shutdown the server and exit

ionic $ [01:25:36] Using gulpfile g:\fakepath\gulpfile.js
[01:25:36] Starting 'sass'...
[01:25:36] Starting 'watch'...
[01:25:36] Finished 'watch' after 88 ms
CSS changed:  g:\fakepath\www\assets\css\style.css
[01:25:39] Finished 'sass' after 2.95 s
[01:25:39] Starting 'default'...
[01:25:39] Finished 'default' after 11 ?s
CSS changed:  g:\fakepath\www\assets\css\style.min.css
q
Closing Gulp process

g:\fakepath>
g:\fakepath>ionic serve --lab
Gulp startup tasks: [ 'default', 'watch' ]
Running live reload server: http://localhost:35729
Watching : [ 'www/**/*', '!www/assets/lib/**/*' ]
Running dev server: http://localhost:8100
Ionic server commands, enter:
  restart or r to restart the client app from the root
  goto or g and a url to have the app navigate to the given url
  consolelogs or c to enable/disable console log output
  serverlogs or s to enable/disable server log output
  quit or q to shutdown the server and exit

ionic $ [01:26:45] Using gulpfile g:\fakepath\gulpfile.js
[01:26:45] Starting 'sass'...
[01:26:45] Starting 'watch'...
[01:26:45] Finished 'watch' after 90 ms
CSS changed:  g:\fakepath\www\assets\css\style.css
[01:26:48] Finished 'sass' after 3.43 s
[01:26:48] Starting 'default'...
[01:26:48] Finished 'default' after 26 ?s
CSS changed:  g:\fakepath\www\assets\css\style.min.css

@SecuriTeam
Copy link
Author

I'm upgrading Chrome to latest stable release, and updated node to 0.12.3 .. will test and return.

@SecuriTeam
Copy link
Author

Still occurs with Chrome 43.0.235x, Ionic CLI 1.4.4, node 0.12.3.
I can't nail the reason yet.
Chrome tab becomes unresponsive and I have to kill the page to kill the overload.

@jbavari
Copy link

jbavari commented May 20, 2015

@SecuriTeam Is the slowness with gulp watch?

What version was this working fine in before you noticed the slowness? I'd like to compare what changes have been made since then.

What tasks are outlined in your gulpfile.js? The default task takes 11 seconds.

@SecuriTeam
Copy link
Author

Hello,

I've just compiled and pushed a new dev/release version to my phone..
I'm experiencing the same issue as well.. not always.. but yes, the app`s CPU usage spikes up to 25% on my phone.

Perhaps it's bad coding on my side, so I'll get a closer look on logcat first.

@jbavari apparently it's not gulp or the watcher fault.. I was using afair 1.3.x (can't remember the exact version), but whenever cli warned me about new versions I would go ahead and install them immediately. Can't say if it happened because an update but it only started very recently.
Chrome updated auto couple of days ago, and today I even upgraded it to version 43.x.
I haven't updated node until today, after the issue started bugging me.. crosswalk is still the same version I installed (12.41.296.5).

my gulp default task only runs 'sass' task which is as follow

gulp.task('sass', function(done) {
    gulp.src(['./scss/style.scss'])
    .pipe(sass())
    .pipe(gulp.dest('./www/assets/css/'))
    .pipe(minifyCss({
      keepSpecialComments: 0
    }))
    .pipe(rename({ extname: '.min.css' }))
    .pipe(gulp.dest('./www/assets/css/'))
    .on('end', done);
});

my custom scss file might be a bit big (with lots of imports) so it might take a little longer than 11sec (depends on my hardware after all).

Anyway, with the unexpected results that I started experiencing recently showing up on my phone, I'm starting to think it might be some bad coding.. logcat should def. give me a better insight.

Will keep you posted.
Thanks.

@SecuriTeam
Copy link
Author

OK, I've noticed this so far..
If I open the app for the first time, it runs fine all the way until I press the back button and send it to background; this is when things get messy, I try to bring it foreground and the CPU usage spikes.

Logcat shows this as the last [ERROR] captured.

E/chromium(14586): [ERROR:runtime_javascript_dialog_manager.cc(69)] Not implemented reached in virtual void xwalk::RuntimeJavaScriptDialogManager::WebContentsDestroyed(content::WebContents*)

@jbavari
Copy link

jbavari commented May 21, 2015

Just taking a wild stab at this.. are you using the local notifications plugin? If so, have you seen this issue on the local notifications issue tracker?

Or this one?

Perhaps its related?

@SecuriTeam
Copy link
Author

Hey man,

No I'm not using the local notification plugin.. here is a list of my plugins:

com.brodysoft.sqlitePlugin 1.0.4 "Brodysoft SQLitePlugin"
com.ionic.keyboard 1.0.4 "Keyboard"
cordova-plugin-camera 1.1.1-dev "Camera"
cordova-plugin-crosswalk-webview 1.0.1-dev "Crosswalk WebView Engine"
cordova-plugin-whitelist 1.0.1-dev "Whitelist"
hu.dpal.phonegap.plugins.SpinnerDialog 1.3.1 "SpinnerDialog"
io.github.pwlin.cordova.plugins.fileopener2 1.0.11 "File Opener2"
io.securiteam.plugins.screen 0.1.0 "DeviceScreen"
nl.x-services.plugins.socialsharing 4.3.18 "SocialSharing"
nl.x-services.plugins.toast 2.0.4 "Toast"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.dialogs 0.3.0 "Notification"
org.apache.cordova.file 1.3.4-dev "File"
org.apache.cordova.file-transfer 0.5.1-dev "File Transfer"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.network-information 0.2.15 "Network Information"
org.apache.cordova.splashscreen 1.0.0 "Splashscreen"
org.apache.cordova.statusbar 0.1.10 "StatusBar"
org.pbernasconi.progressindicator 1.1.0 "Progress Indicator"

I have seen this issue yesterday while searching for the error messages that I've noticed in logcat..
However, I'm not receiving a black screen.. my interface shows up but not the content that is supposed to be fetched from the server.

I haven't had an issue with my app's root state code, (which all my ui-routes inherit from), but I'm starting to wonder if my network status monitoring functionality is related, or not.. I'll keep searching for a root cause because it hit me out of nowhere.

Thanks for the follow up.

@SecuriTeam
Copy link
Author

argh..
Been digging into this since morning and I'm yet to figure out what's wrong.

Here is my app's logcat .. maybe you can see something interesting to help us out :(

P.S: it seems the issue reoccur whenever I logout the user, then try to log back in..
what happens is that on successful login, the user is redirected with $state.go to the default route. I have caching disabled so the default state controller tries to populate the content from server. The console log shows a successful GET to the server, and nothing more after that.. no console logs..
Here is my controller of the default route.

@SecuriTeam
Copy link
Author

Low and behold!
The problem was an i where it should have been a j in multi nested loops...
If it wasn't for the nested loops my jsLint task would have found the problem 2 days ago ⚠️

Man!

Closing this now as resolved, and thank you for your time into trying to look into this.

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

No branches or pull requests

2 participants