NWJS not completely closing when exiting app

    Hey people, I've made a quick fix for nw.exe not closing which should work until this is fixed:

    1. Download this .bat file or create one yourself by opening notepad and entering the following: taskkill /f /im nw.exe before saving the file as nw_exit.bat

    2. Copy the nw_exit.bat to the \NWjsForC2\win64 and win32 folders, which will ensure the files are added to all new exports.

    3. In C2, find the event you use to close the game. Above the Browser Close action add a NWjs run file action. In the Path box add: """"&NodeWebkit.AppFolder&"nw_exit.bat"""""

    Here I also add a wait 0.1 second action and then the browser close action just in case the file doesn't run.

    4. Export the game. Now when you click on your exit button the .bat script should run, closing all nw.exe processes!

    I really have no idea what I'm doing when it comes to programming. My initial thought was to run javascript that could kill the process, and while there seems to be a way , I'd have no idea how to format this in a way C2 understands.

    I hope this helps you as much as it helped me!

    This is unrelated to the previous post.

    Browser close seems to work for the 32 bit export, but not for the preview.

    No way to test the preview for 64.

    The 32 bit preview, and 32 bit export seem to be different from each other somehow.

    Just to stress how important it is to get a fix for this - those who close the game through alt-f4, the close window button or if the game crashes will still have the additional nw.exe's running.

    For me, the 64 preview version works fine so far. But that's after copying all the project into a new one. Might be a problem of corruption of files. Not really sure.

    Hey people, I've made a quick fix for nw.exe not closing which should work until this is fixed:

    1. Download this .bat file or create one yourself by opening notepad and entering the following: taskkill /f /im nw.exe before saving the file as nw_exit.bat

    2. Copy the nw_exit.bat to the \NWjsForC2\win64 and win32 folders, which will ensure the files are added to all new exports.

    3. In C2, find the event you use to close the game. Above the Browser Close action add a NWjs run file action. In the Path box add: """"&NodeWebkit.AppFolder&"nw_exit.bat"""""

    Here I also add a wait 0.1 second action and then the browser close action just in case the file doesn't run.

    4. Export the game. Now when you click on your exit button the .bat script should run, closing all nw.exe processes!

    I really have no idea what I'm doing when it comes to programming. My initial thought was to run javascript that could kill the process, and while there seems to be a way , I'd have no idea how to format this in a way C2 understands.

    I hope this helps you as much as it helped me!

    I am very grateful since you save me a lot of trouble and allow me to release my newest demo on the schedule I planned out.

    For the close window option, I just export it as borderless and allow alt+F4 to activate the .bat file as well on the setting event sheet.

    Yup, no nwjs process to be seen anywhere once the .bat is used.

    Thanks for the quick fix.

    Is anyone else having random frame rate drops with the new node webkit?

    I tested in chrome and my game ran fine but when it runs with node webkit there is frame rate drops that randomly happen.

    How about starting a new thread , this one's crowded already.

    Sethmaster No worries, I'm glad it helped! Good idea with the alt-f4, I created an event and it works perfectly

    AlexFrancois thanks for your fix, I really needed this!

    for NWjs run file action I put "nw_exit" then export then just add nw_exit.bat to the package.nw

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads

    I think this is to do with NW.js 0.12 upgrades. The data folder NW.js 0.12 uses seems to have been in a different format to the one NW 0.13 uses, so if you in-place upgrade an app then it uses the 0.12 data folder in a 0.13 app and that seems to cause some weird issues (mostly just ghost processes, but I've seen one or two other related issues). Renaming the project causes it to start using a new empty data folder (because the data folder name is based on the project name). This fixes it and also explains why I can't reproduce the problem, because I'm just testing fresh 0.13 apps which work fine. Either way, it's a NW.js issue so it would probably be better to take this to the NW.js issue tracker, but we'd probably need a good repro for the NW.js devs. So, is anyone able to make a repro for this based on running a NW.js 0.12 app and then updating it to 0.13?

    -snip, just fixed with Alex's fix, thanks-

    I think this is to do with NW.js 0.12 upgrades. The data folder NW.js 0.12 uses seems to have been in a different format to the one NW 0.13 uses, so if you in-place upgrade an app then it uses the 0.12 data folder in a 0.13 app and that seems to cause some weird issues (mostly just ghost processes, but I've seen one or two other related issues). Renaming the project causes it to start using a new empty data folder (because the data folder name is based on the project name). This fixes it and also explains why I can't reproduce the problem, because I'm just testing fresh 0.13 apps which work fine. Either way, it's a NW.js issue so it would probably be better to take this to the NW.js issue tracker, but we'd probably need a good repro for the NW.js devs. So, is anyone able to make a repro for this based on running a NW.js 0.12 app and then updating it to 0.13?

    I started dissecting my project to see if I could create a capx for a bug. I renamed the project, then I removed all my sounds, and the Audio plug as I was planning to redoing all that anyway.

    I exported it, and both 32, and 64 bit did not have the ghost process.

    I then added one sound back with the Audio plug with an event to play it.*

    No extra process was there after I tested that export.

    *I noted that there were still references to the deleted sounds in the event commands.

    No I did not close C2 before doing this.

    Hey all,

    I noticed that putting the task kill within the game doesn't always get rid of the extra process.

    You are better off running your windows executable through a script.

    Create a file called rungame.vbs and put the following in (replace nw.exe with your game's exe on lines 2 and 4):

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "nw.exe", 1, true
    WScript.Sleep 500
    WshShell.Run "taskkill /f /im nw.exe", 1, true[/code:19hh0z3k]
    
    Next create a [b]GameLauncher.bat[/b] file with the following one line:
    
    [code:19hh0z3k]cscript rungame.vbs[/code:19hh0z3k]
    
    Put both the vbs and bat files in your win32 and win64 directories.
    
    Instruct your users to double click [b]GameLauncher.bat[/b] to run your game.  This ensures the game is actually closed and runs the task kill process.
    
    [i]Note:  If you game's exe contains a space (you evil person you), you must add quotation marks to the vbs script like so:[/i]
    
    [code:19hh0z3k]Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run """My Game.exe""", 1, true
    WScript.Sleep 500
    WshShell.Run "taskkill /f /im ""My Game.exe""", 1, true[/code:19hh0z3k]

    I have to say, any method by which you try to forcibly shut down the leftover processes is an appalling hack, and could just open another can of worms (e.g. do all users have permission to use VBScript? Is it always installed? Are its dependencies the same as NW.js?), not to mention being a classic treat-the-symptoms solution rather than fixing the real problem. It would be far better to put effort in to finding a repro that could be submitted to the NW.js developers as I said in my previous post.

    Look! I had the same problem mentioned here!

    NW.js ghost and random crashes, random fps drop in NW.js! That worried me a lot, because in NW.js v12 my project worked perfect!

    Already NW.js v13 beta 4 not!

    It was a while without updating the windows 8, I had disabled the Windows update. I activated yesterday to upgrade to upgrade the Windows and the problems have been corrected!

    Then I recommend updating the Windows if not doing it! (You can stop your headache!)

    PS: NW.js ghosts after closing still continue! the other problems have been fixed after activate Windows update and upgrade!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)