Construct-bugs icon indicating copy to clipboard operation
Construct-bugs copied to clipboard

NW.js doesn't close properly.

Open BluePinStudio opened this issue 1 year ago • 2 comments

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

  1. Open any example project
  2. Go to export and select nw.js
  3. Select latest version of nw.js and build
  4. Wait for build to complete
  5. Open the resulting nw.js build
  6. Close the game
  7. Inspect your task manager, and you'll see its still open even though the window is gone.
  8. 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.

BluePinStudio avatar Sep 14 '24 21:09 BluePinStudio

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.

AshleyScirra avatar Sep 16 '24 13:09 AshleyScirra

I've encountered this issue for at least 7 years, with NWjs still in the background after the game closes.

JeFawk avatar Oct 02 '24 10:10 JeFawk

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.

AshleyScirra avatar Oct 24 '24 15:10 AshleyScirra

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?

AshleyScirra avatar Oct 29 '24 16:10 AshleyScirra

NJWS no longer closes with "close browser" action, it freezes the game and the window is still open.

image

But if you use the mouse to close it, then it works and I'm able to open my game again

image

alastajj avatar Oct 29 '24 22:10 alastajj

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?

AshleyScirra avatar Oct 30 '24 11:10 AshleyScirra

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.

AshleyScirra avatar Nov 05 '24 16:11 AshleyScirra

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.

BluePinStudio avatar Nov 05 '24 21:11 BluePinStudio