NW.js improvements in Construct 3

1
Official Construct Post
Ashley's avatar
Ashley
  • 16 May, 2017
  • 1,139 words
  • ~5-8 mins
  • 3,274 visits
  • 0 favourites

When adding the NW.js exporter in Construct 3, we made a series of improvements to make using NW.js easier and more flexible. Here's a few of the changes we've made.

Remember we've started the Newgrounds Gamejam and all Construct 3's features are enabled until May 28th — so you can try all of this right now!

New Version Manager

In Construct 2, you had to download and install a single version of NW.js (equivalent to a single version of Chromium). You ended up downloading all platforms even if you didn't need them all, and you couldn't use more than one version at a time.

For Construct 3 we added a new NW.js Version Manager to help give you more control.

With this dialog you can see all available NW.js versions, which have been downloaded, and download all or just some of the platforms for each version. The downloaded versions are saved to browser storage so it's quick to export with them, since it doesn't have to download it again. Downloading lots of NW.js versions can end up using a lot of storage space though, so there are options to delete versions as well.

Manage individual platforms

If you are only interested in a few platforms — for example just Windows, or just the 64-bit platforms across Windows, Mac and Linux — you can download (or delete) individual platforms for each NW.js version. This saves bandwidth and storage space for platforms you don't need.

Download in the background

The NW.js downloads may take a while to complete, especially on slow connections. So if you start a series of downloads from the version manager, they run in the background and show their progress in a small status bar at the bottom of the screen. This means you can continue working on your project while the download is progressing, and come back when it's finished.

New export options

There weren't many options available when exporting to NW.js in Construct 2. In Construct 3 we added several more, allowing for much better configuration.

First of all there's a new version selector, allowing you to switch between any version of NW.js. If you choose one which hasn't been downloaded, it downloads the selected platforms for that version when you export. The new Latest option is also useful for staying automatically up to date. While you can select any specific version of NW.js from the list, if you leave it on the "latest" option, it will switch to a new version when it's released. This means you always export with the latest version without having to do anything!

The Platforms section lets you select which individual platforms you want exported. This helps speed up exports by skipping platforms you don't care about.

There are several more new options:

  • Package assets compresses all your game's files in to a single file. Construct 2 always did this, creating a package.nw file. This slightly obscures your game's data, but has the downside that NW.js has to extract all the files from the package on startup, which can cause long startup times for very large games. Turning off this option means the game files are not packaged (they're simply copied to the same folder), which makes startup faster.
  • Compress final zip means the final zip that Construct 3 produces, which contains all the exported platforms, is compressed to reduce its size. If you turn it off, the final zip skips compression (using store-only mode in the zip). The main reason for this is to speed up exports: the zip can easily be hundreds of megabytes, and compressing it can often take a while.
  • Window frame, resizable window and kiosk mode are the same as they were in C2, affecting the style of the window.
  • Ignore GPU blacklist lets you control software rendering in NW.js. Some systems with poor quality graphics drivers can end up crashing or causing severe display glitches in your game. (This happens in the driver's native code — it's not the fault of HTML5, Chrome, NW.js or Construct, it's something everyone developing with computer graphics has to deal with.) Browsers provide blacklists to recognise faulty drivers or hardware and fall back to software rendering. This makes a trade-off: it guarantees the game works (if slowly), but in some cases games which by chance don't run in to driver problems, get unnecessarily slowed down. Rather than make a decision for you, we've added a checkbox so you can decide which trade-off you prefer.
  • Finally, Command line options lets advanced users add custom Chromium command line arguments. These can sometimes be handy for testing or for compatibility with other platforms, e.g. specifying --in-process-gpu in case your Steam game needs it.

Improved packaging

NW.js exports from Construct 2 often ran in to annoying file permission issues. Copying files from Windows to Mac would sometimes lose certain file attributes and the resulting app wouldn't work. There were workarounds to copy the files while keeping these attributes, but it could be inconvenient. Additionally on Linux you'd have to configure a few files to add execute permission before the NW.js app was allowed to be started.

The ZIP format is pretty old and obscure, but we did a lot of research, reverse-engineering and experimentation and finally solved this by customising the fine details of the zip file format to ensure compatibility across all systems. This means Construct 3 produces a zip which you can copy anywhere without worrying about how you copy it, and then when you extract the files from the zip on the destination system, everything is already correctly set up so it can immediately be executed! This means:

  • The extracted file permissions on Mac are correctly configured so the app can run without any fuss or further configuration
  • On Mac, the exported NW.js app is now also a directly runnable app bundle, so you can just drag-drop it out of the zip and double-click to run
  • The extracted file permissions on Linux are already configured to allow execute permission on executable files, so you can also run the app right away with no further configuration.

This all works regardless of which platform you export from originally; as long as you extract the files on the system itself, your app should run out-of-the-box.

Conclusion

Construct 3 provides far more customisation options when exporting with NW.js, ranging from choosing specific platforms in specific NW.js versions, auto-updating, adjusting packaging and compression options, and advanced options like ignoring the GPU blacklist or adding custom Chromium arguments. The improved packaging makes it much easier to test and deploy as well, providing apps that can run out-of-the-box across Windows, Mac and Linux, directly from the browser, and regardless of which platform you exported on.

Want to try it for yourself? You can use it now during the Gamejam!

Subscribe

Get emailed when there are new posts!