nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.21k stars 3.88k forks source link

node-webkit incompatible with Mac OS X - CPU usage goes to 100% and system hangs #2723

Closed Emasoft closed 9 years ago

Emasoft commented 9 years ago

Node webkit-helper is frequently using more than 100% of cpu on OS X, heating up the system and stopping all other processes, and making the system unresponsive until the webkit-helper process is killed manually from system monitor. This happens with almost all nw based applications I tried. It seems that node-webkit has a problem with the underling OS X. Upgrading to Yosemite didn't solved the issue.

rogerwang commented 9 years ago

I couldn't reproduce this in my OSX systems. Could you please provide a demo?

ccarlsen commented 9 years ago

I have similar CPU problems on OS X when I have animated gif's or videos in my app. node-webkit Helper goes insane if i have a couple of gifs in view at the same time.

DinisCruz commented 9 years ago

I have been running node-webkit on Yosemite without those performance issues. Is there a page or site that you can provide that shows the prob?

brunnopleffken commented 9 years ago

I'm also experiencing high CPU usage with node-webkit on OS X Yosemite, rendering just a simple HTML with some CSS3 like animate for loaders and transition for nav bar... "node-webkit" is constantly at ~25%, "node-webkit Helper" oscillating between 10 and 30%, heating up my MBPr a LOT...

screen shot 2014-12-02 at 21 02 52

rogerwang commented 9 years ago

@brunnopleffken could you upload your case somewhere?

kamesh-a commented 9 years ago

@ccarlsen exactly we are loading animated gif in our website, our cpu load instantly raises to high usage. @rogerwang will try to get an minimal sample, so issues can be addressed.

chino23 commented 9 years ago

I have the same issue.

When I run the app (quite a big one) in chrome, it's smooth as butter. Using node-webkit it lags so bad even the simple transitions stutter. CPU usage is insane.

Same for 0.9.2 to 0.11.2

MAC OS 10.10

chino23 commented 9 years ago

any progress on the performance issues on mac?

ghost commented 9 years ago

I have no idea if this is related but I have almost the polar-opposite issue (in 0.11.5)

On OSX (Mavericks - updated to latest), my app performance on OSX isn't great but worse is that frequently hangs/freezes.

When this happens it becomes totally unresponsive to any events or inputs and there's no messages/warnings or pattern to when it happens...

Sometimes it will come back after a few mins - mostly it just remains unresponsive until killed.

Oddly, it disappears from the 'Force Quit' list when this happens so I'm forced into Activity Monitor to kill the 'node webkit' and 'node webkit helper' processes before I can re-run it (wherein it will work for a while before crashing again)

Note: in Activity Monitor, the processes are shown using a small amount of CPU - around 1% - which grows over time (but would take days to reach 100%)

Given I'm running on Virtualbox - my issues COULD just be that (it's hardly a supported approach) but I could also be seeing a similar issue but the VM is preventing a CPU race condition or similar...

Just thought I'd share that - clearly there are issues with NW on OSX tho

AndryBray commented 9 years ago

I have opened a new ticket as I see the same problem on Windows as well https://github.com/nwjs/nw.js/issues/3046

Testing nwjs 0.12.0 alpha2 I have the same problem with webkit CSS3 animation. Tested on MacOS 10.6.8 and 10.8.5 (both 64bit). On the oldest, the CPU reaches 150%, on the new one 30/40%. This is a test case: http://codepen.io/anon/pen/jEGbdZ

Using nodewebkit 0.10.5 the CPU usage is less but in my opinion still too much (about 10% of a i7 quad core 2,8GHz)

PS: Testing the same on Chrome 40.0.2214.94 and the chrome process reaches 20 - 25 % of CPU usage.

tommoor commented 9 years ago

@rogerwang is there some way we can debug this, get inside the node-webkit process? This is happening every single day in our app and it's driving us up the wall :wink:

rogerwang commented 9 years ago

@tommoor I'll check it with @AndryBray 's case asap.

tommoor commented 9 years ago

@rogerwang I'm not sure whether the CSS3 issue is the same one or not, we're having this occur with the app completely idle - it will just gradually keep getting worse until it's using 100%+ of the CPU.

I want to help here - let me know how to debug the node-webkit Helper process and we'll probably find the problem in hours :smile:

rogerwang commented 9 years ago

tried the case here with Macbook Pro (10.10.1): Chrome 41: 40-45% NW.js 0.12.0-alpha3 live build: 40-45%

So still cannot reproduce it here. Will find another OSX system to try.

PS: please compare NW.js 0.12.x with Chrome 41, because nw12 is based on Chromium 41. Thanks.

rogerwang commented 9 years ago

@tommoor can you send me your app and steps to reproduce it?

tommoor commented 9 years ago

@rogerwang unfortunately our app requires multiple users to work and only reproduces often after being open for many hours. It's going to be a lot easier if I can do the debugging on my end...

felicienfrancois commented 9 years ago

May be related to #3030 (CSS3 transitions not smooth on Mac OS X)

kamesh-a commented 9 years ago

Reproducible snippet. issue #2899


var http = require('http');
var fs = require('fs');
var path = require('path');

function download(url, callback) {

    var dest;

    if(/darwin/.test(process.platform))
        dest = path.join(process.env.HOME,'Downloads',path.basename(url));
    else if(/^win/.test(process.platform))
        dest = path.join( process.env.HOMEDRIVE, process.env.HOMEPATH,'Downloads',path.basename(url));
    else{
        console.warn('Platform is not Win/Mac');
        return;
    }

    var file = fs.createWriteStream(dest);

    var request = http.get(url, function(response) {

        response.pipe(file);

        var len = parseInt(response.headers['content-length'] || response.headers['x-goog-stored-content-length'], 10);
        var total = len / 1048576;
        var cur = 0;

        response.on("data", function(chunk) {
            cur += chunk.length;
            console.log("Downloading " + (100.0 * cur / len).toFixed(2) + "% " + (cur / 1048576).toFixed(2) + " mb\r" + " Total size: " + total.toFixed(2) + " mb")
        });

        file.on('finish', function() {
            file.close(); // close() is async, call callback after close completes.
            if (callback)
                callback('success');
        });

        file.on('error', function(err) {
            fs.unlink(dest); // Delete the file async. (But we don't check the result)
            if (callback)
                callback(err.message);
        });
    });
}

download('http://dl.node-webkit.org/v0.11.5/node-webkit-v0.11.5-osx-ia32.zip',function(){console.error(arguments)});
tommoor commented 9 years ago

Just another day...

186% CPU screen shot 2015-02-26 at 8 45 18 am

Javascript profiler shows essentially idle. screen shot 2015-02-26 at 8 45 34 am

ghost commented 9 years ago

33 threads! - what does that read when you first start the app?

Are you using setTimeout or (particularly bad) setInterval within your code?

On 26 February 2015 at 16:47, Tom Moor notifications@github.com wrote:

Another day...

[image: screen shot 2015-02-26 at 8 45 34 am] https://cloud.githubusercontent.com/assets/380914/6396541/dc8316b6-bd93-11e4-9fd0-829c07523312.png

[image: screen shot 2015-02-26 at 8 45 18 am] https://cloud.githubusercontent.com/assets/380914/6396542/dc97072a-bd93-11e4-9611-e0ea734d07ef.png

— Reply to this email directly or view it on GitHub https://github.com/nwjs/nw.js/issues/2723#issuecomment-76214071.

tommoor commented 9 years ago

setTimeout and setInterval are used in the code, yep.

ghost commented 9 years ago

It's a long-shot, but I've found that swamping setTimeout/setInterval with jobs can lead to high cpu usage and even a system lockup (on WIndows here)

As I said tho, it's a longshot.

On 26 February 2015 at 17:35, Tom Moor notifications@github.com wrote:

setTimeout and setInterval are used in the code, yep.

— Reply to this email directly or view it on GitHub https://github.com/nwjs/nw.js/issues/2723#issuecomment-76224754.

tommoor commented 9 years ago

I see, thanks - I don't think that's the case here, as you can see in the profiler our JS is doing no work and the app is sat idle. There are a couple of intervals but usually a min of every 1000ms.

rogerwang commented 9 years ago

@tommoor I'll add some tracing support so it would be helpful to know what's happening there. Before that is there something usual in devtools?

bebejane commented 9 years ago

i can report the same issues here. our app needs to run 24/7 so its frustrating having to restart it all the time. it seems to happen when the app is idle for a long time...

kennyhk commented 9 years ago

@bebejane, @rogerwang Yes, my app is same issues here. Must idle it for at least 800 sec.
idle it for 10000+ sec is good to reproduce this issue.

kennyhk commented 9 years ago

@rogerwang https://www.youtube.com/watch?v=HjTTxEtwTwE&feature=youtu.be

This demo show how to trigger the nwjs cpu issue by the following steps :

  1. Open an app that base on nwjs
  2. Idle it about 2 hours
  3. keep shake the app windows
  4. at 01:03, CPU usage is more then 100%!

Hope it can help for anything!

felicienfrancois commented 9 years ago

Is it related to App Nap ? What happens if you disable App Nap ?

dannykok commented 9 years ago

@felicienfrancois tested with my app with the same issue. Problem wasn't resolved by disabling App Nap. CPU goes way higher after idling the app for around 2-3 hours.

I am running it on Yosemite 10.10.2 macbook pro 15" retina 2013. End users reported similar findings on Macbook Air as well so I guess it may not be hardware dependent.

rogerwang commented 9 years ago

@kennyhk could you please send your app to me, or extract a case from it? That would be helpful for me to reproduce it here.

kennyhk commented 9 years ago

@rogerwang yes, but that is not my app in demo video : https://popcorntime.io

marcfowler commented 9 years ago

I get the same thing (OSX 10.10.3, on an iMac, with NW 0.12.0 and NW 0.12.1). I don't know if it's caused by CSS3 animations, though I have some running. Even if I remove those nodes, it doesn't go back down again. Even if I quit the window with them in, it doesn't seem to go down.

I'm using process.nextTick and a couple of ~30,000ms setTimeout/setInterval calls but nothing that I'd have expected to cause this.

kennyhk commented 9 years ago

@rogerwang hi, i done some test result, just for your information :

test case 1 - simple apps (no internet apps) with 10 hours idle

test case 2 - file download without idle

test case 3 - simple CSS3 animation with 3 hours idle

test case 4 - complex app with 3 hours idle on OSX 10.10

test case 5 - complex app with 3 hours idle on OSX 10.9

rogerwang commented 9 years ago

@MarcFowler could you please share your app to me? I'm eager to reproduce it here.

@kennyhk thanks for your effort and the information. Regarding test case 4, can it be reproduced every time? and what's the version inside the app? I'll check it.

kennyhk commented 9 years ago

@rogerwang

sorry for i don't know what is the version because that is not my app.

But I have another complex app, the result is same as test case 4, via v0.11.6 and v0.12.0 it can be reproduced every time with idle.

marcfowler commented 9 years ago

Sorry @rogerwang, it's a really complex app (i.e. with a lot of other stuff going on with it) and I've not got the ability right now to replicate it in a contained app. I'll do my best as soon as I can though. I have a very similar Mac (iMac 2011, though I have more RAM) to @kennyhk there and I get the same results. I can replicate the issue he outlined in case 4 too, which says something at least?

rogerwang commented 9 years ago

@kennyhk I'll check with popcorntime. Could you please share your "another complex app" to me?

kennyhk commented 9 years ago

@rogerwang i has been send an email to you (roger@nwjs.io) about my app. one more discovery, slow GUI response problem can trigger by minimize(hide to dock)/restore the app after idle.

rogerwang commented 9 years ago

@kennyhk regarding "one more discovery", does it apply to your app, or popcorntime, or any other NW apps? And does it mean minimize/restore after 3hrs idling, or minimize/restore after a short idle time after launching the app?

lealife commented 9 years ago

I have the same problems with nwjs-0.12.0 & 0.12.1 on mac ox image I just open a link with nwjs

rogerwang commented 9 years ago

@kennyhk I downloaded popcorntime 3.7 beta (newest version) but cannot reproduce it here. It's running on NW 0.9.2 btw.

rogerwang commented 9 years ago

I'll try to add some log here and make a special build for you to collect some information hopefully. That will happen soon after nw 0.13.0-alpha1 release. It's still best if it can be reproduced here.

ersingencturk commented 9 years ago

Same here, can it be related to graphic card ? Any chance if any having this problem have a mac with this card: Intel Iris Pro 1536 MB

screen shot 2015-05-12 at 06 53 13

eabovsky commented 9 years ago

Can confirm. CSS3 animations seem to be the cause of the CPU consumption spike.

I had a small animated element in my app which used CSS keyframes, which would run at ~30% cpu according to the activity monitor. After removing the animated element, average CPU consumption went from ~30% to 10%.

rogerwang commented 9 years ago

please try this build for the fix:

http://dl.nwjs.io/live-build/05-17-2015/0038f72-296de67-be948af-459755a-2bdc251-1764a45/nwjs-v0.12.1-osx-x64.zip

btw, It's supposed to fix the cpu hog while idling, not high utilization under load.

rogerwang commented 9 years ago

Thanks to @kennyhk for working with me closely on the issue. He verified the issue is fixed.

For issue similiar with this one (100% while idle), e.g. higher CPU utilization than Node, please submit separate issue. Thanks.

kennyhk commented 9 years ago

Thanks to @rogerwang! We wait in hope for the new release. NWJS the best!

chino23 commented 9 years ago

Thanks a lot @rogerwang . Really appreciate it!

eabovsky commented 9 years ago

Hey guys, another observation I just made on OSX:

If I use the "--disable-gpu-vsync " chromium flag, it will make my "nwjs Helper" process spike to 100%+ CPU.

stephan-nordnes-eriksen commented 9 years ago

In my case I had a simple d3.js animation (spinning thing) which, when removed, fixed the issue for me.