NW.js doesn't close properly.
Problem description
Whenever a user closes the nw.js built game, there's a high percentage chance (over 50% from my experience) that the nw.js window closes but nw.js remains an open task in the background. It can be seen in task manager,
This prevents the user from opening the game again when they try to launch the nw.js build. This also shows that the user is "playing the game" on Steam.
Attach a .c3p
No .c3p required. I tested it, and it occurs with construct example projects built with latest version of nw.js
Steps to reproduce
- Open any example project
- Go to export and select nw.js
- Select latest version of nw.js and build
- Wait for build to complete
- Open the resulting nw.js build
- Close the game
- Inspect your task manager, and you'll see its still open even though the window is gone.
- If it closed successfully, repeat step 5-7 again. Its not 100% reproducible, more like 50%.
Observed result
Nw.js remains technically open via a background task that isn't terminated
Expected result
It should close the window and the task 100% of the time.
More details
This is a regression, the issue has been documented and fixed in the past.
I will try to take a look at this, but it may be that it ends up being a problem with NW.js itself and outside of our control, so you may want to report it directly to NW.js instead.
If you are publishing for Windows, where possible I would advise to use the Windows WebView2 export option instead - it's better supported and is our own wrapper so it's much easier for us to fix any issues that come up with it.
I've encountered this issue for at least 7 years, with NWjs still in the background after the game closes.
Issues which don't reliably reproduce are always difficult to deal with, but I've added in a possible workaround for the next beta. As it's sporadic, marking to check when the next release comes out to see how it works for others with the workaround.
r413 has a potential workaround for this, but it's tricky to verify as it's a sporadic issue. Can anyone previously affected still reproduce the issue in the latest beta?
NJWS no longer closes with "close browser" action, it freezes the game and the window is still open.
But if you use the mouse to close it, then it works and I'm able to open my game again
It looks like you filed a separate issue regarding the Browser 'Close' action. However apart from that - closing using the X button on the window instead - is this issue resolved?
We've had a workaround in since r413 but nobody has confirmed if it works yet - if it does that's OK, but if it doesn't it's probably out of our hands anyway and ought to be reported directly to NW.js to follow up, so closing this issue now.
As far as i can tell the bug has been resolved, ill report otherwise. I haven't seen it occur across 100+ shutdowns, where previously it would've happened approximately 50 of those 100.