0 Favourites

[TEMP. BROKEN] The Big NW.js Roundup - Tips & Tricks

    • Topic Overview

      Introduction

      Hi, my name is TheRealDannyyy and I've decided to create this topic in order to keep track of the latest changes, bugs and workarounds for C2's desktop exporting method.

      Table Of Contents

      Getting Started

      • Installing & Updating
      • The Use Of Custom Builds

      Main Structure

      • Important Files & File Paths
      • How To: Modify The Package Manifest Files
      • How To: Add Chromium-Args & Js-flags

      Bugfixes & Workarounds

      • How To: Workaround Recording Issues & Canvas Flickering
      • How To: Workaround Steam Overlay Not Appearing (Refresh)
      • How To: Workaround Steam Overlay Not Appearing (In-Process)
      • How To: Workaround Steam Overlay Issues With Letterbox Scaling
      • How To: Open Multiple NW.js Preview Windows
      • How To: Force GC To Instantly Unload Audio From Memory

      Custom Features & Debugging Tools

      • How To: Speed Up The Startup Time Of Your Game By Up To 20%
      • How To: Set Your Own Application Icon
      • How To: Hide/Prevent Chrome Devtools For The End-User
      • How To: Test Your Game On Higher Framerates Than 60FPS
      • How To: Use The Built-in NW.js FPS Counter
      • How To: Secure/Hide Your Game Assets
      • How To: Modify/Remove Right-Click Context Menus
      • How To: Fetch & Make Use Of Command-line Arguments

      References

      • Helpful Links
      • External Bugreports
    • NW.js - Basics

      Getting Started

      Installing & Updating

      Since Construct 2's r187 update, all NWjs related files can be downloaded from THIS place. The installer will do the job for you and install all the necessary files and runtime components you need.

      The Use Of Custom Builds

      If you don't want to wait for the latest stable NWjs installer or would like to test out the latest beta builds of NWjs, you also have the option to visit THIS website and do everything on your own.

      Main Structure

      Important Files & File Paths

      The following is a list of all files and paths that you will surely have to visit at some point while working with C2 and NWjs. Everything is based on default paths so they might be different on your end.

      • NWjsForC2 Source Folder (C:\Program Files\NWjsForC2):

      Here you can find all the base files that C2 uses for the export. This is also the path where you have to paste in any custom builds if you decided to use them.

      • C2 Folder For NWjs Files (...\Construct2\Construct2-Win...\exporters\html5\nwjs):

      This path holds important ".json" files and usually 2 folders "win32" and "win64" with images inside.

      • "package.json" & "package-win.json" (...\Construct2\Construct2-Win...\exporters\html5\nwjs):

      These json files contain important commands that the exported version of NWjs can make use of. It's recommened not to add any debugging related "Chromium-Args" in those files.

      • "package-preview.json" (...\Construct2\Construct2-Win...\exporters\html5\nwjs):

      This json manifest for NWjs is only being used while previewing your games inside Construct 2. It's recommended to add all the debugging related "Chromium-Args" in this file only.

      How To: Modify The Package Manifest Files

      Modifying or adding chromium args is a thing that every NWjs user has to learn and do at some point. The most common misconception is that you're required to do it manually for each export but that's not the case! Since Construct 2 is copying over the package.json files, it's actually easier to just edit the source files directly.

      How To: Add Chromium-Args & Js-flags

      The majority of features or bugfixes found in this topic will require chromium-args or js-flags to be added to the package manifest files manually. Below you will find examples on how to do it.

      Steps To Add Chromium-Args To Package.json File(s):

      • Open the "package.json" file(s)
      • Find the "chromium-args" property (Screenshot)
      • Add a Chromium-Arg at the correct place with 1 empty space in between other args (Screenshot)

      Steps To Add JS-Flags To Package.json File(s):

      • Open the "package.json" file(s)
      • Find the "js-flags" property, manually add it if it's not available (Screenshot)
      • Add a JS-Flag at the correct place with 1 empty space in between other flags (Screenshot)
    • NW.js - Workarounds

      Bugfixes & Workarounds

      How To: Workaround Recording Issues & Canvas Flickering

      Game canvas is occasionally flickering and going black for a second or two. Recording software randomly stops because of unknown technical reasons.

      Steps To Add/Fix/Workaround:

      • Open the "package.json" file(s)
      • Add --disable-direct-composition to the "chromium-args" properties

      How To: Workaround Steam Overlay Not Appearing (Refresh)

      Steam Overlay doesn't appear at all or certain features aren't working. The game has no moving elements that trigger a refresh on the current layout.

      Steps To Add/Fix/Workaround:

      • Add a small 2x2 sprite into one of your layouts (e.g. loader layout)
      • Add a movement behavior like rotate
      • Set the sprite opacity to 0% and make it global

      How To: Workaround Steam Overlay Not Appearing (In-Process)

      Steam Overlay doesn't appear at all or certain features aren't working. The game canvas refreshes constantly but it's still not working as expected.

      Steps To Add/Fix/Workaround:

      • Open the "package.json" file(s)
      • Add --in-process-gpu to the "chromium-args" properties

      How To: Workaround Steam Overlay Issues With Letterbox Scaling

      The Steam Overlay doesn't scale correctly on games with letterbox scaling enabled. Black bars around the game canvas glitch out and the Steam Overlay is still visible.

      Steps To Add/Fix/Workaround:

      • Download and install THIS plugin
      • Set the events up based on your Steam plugin (Example HERE)

      (Bugfix/Workaround provided by BackendFreak.)

      How To: Open Multiple NW.js Preview Windows

      NWjs doesn't allow multiple application instances running at once. Previewing with multiple NWjs windows in Construct 2 doesn't work.

      Steps To Add/Fix/Workaround:

      • Add the browser and keyboard plugins
      • Add the condition on button pressed
      • Add the execute javascript action and execute this code:
      "window.open('" & Browser.URL & "');"
      • Open as many windows as you like by pressing the selected button

      How To: Force GC To Instantly Unload Audio From Memory

      Garbage Collector is not doing the job and bloats memory usage. Frequent game crashes related to reaching the system's memory limit.

      Steps To Add/Fix/Workaround:

      • Open the "package.json" file(s)
      • Add --expose-gc to the "js-flags" properties
      • Execute the following JS code using the browser plugin:
      "global.gc();"
    • NW.js - Features

      Custom Features & Debugging Tools

      How To: Speed Up The Startup Time Of Your Game By Up To 20%

      Game takes a long time to start up. Game files are heavily compressed. The "package.nw" file is very large and contains a lot of assets.

      Steps To Add/Fix/Workaround:

      • Go to your exported Win32/Win64 folder(s)
      • Rename "package.nw" to "package.zip" and unzip it
      • Rename the unzipped folder to "package.nw" and remove all the old files
  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Great job. I'm sure I'll be visiting this thread often

  • Great post. If you'd make a tutorial of it I think more users would find it.

    Edit: In my humble opinion, the workarounds should be included in the manual. Ashley I think it's important to keep the manual up to date with information like this to inform the developers about how they can make their game working in certain situations. I don't think that it's a good practice to have them dig through forum topics or find tutorials for things that they think should work out of the box. What do you think?

  • There are two more things worth to mention.

    1. You should remove the current version of the NW.js you have currently installed before installing the new one. Otherwise your OSX export size will be huge. Some more info here: viewtopic.php?f=146&t=181578

    2. Changing the Mac icon.

    a) convert your PNG to ICNS (here for example: https://iconverticons.com/online/)

    b) copy ICNS file to [yourGameName].app/Contents/Resources

  • So the single process thing was resolved, too?

  • So the single process thing was resolved, too?

    If you mean the issue with screen recording and/or screen flickering, it was not about multi processing, but yes it is resolved. Please see this post for more details:

  • BackendFreak

    Yes, this means that "--in-process-gpu" is off the table and not needed anymore?

    Btw: thanks for taking the heroic effort and putting up with all the bug reports. We were really in a tight spot with these NW.js shenanigans and now we seem to approach a point where stuff is actually usable for mass deployment again.

  • --in-process-gpu is needed for greenworks to work though, as far as I'm aware, however I've never been able to get greenworks to work.

  • Prominent

    I must say I never had a problem using Madspy's Steam plugin.

  • Prominent

    I must say I never had a problem using Madspy's Steam plugin.

    Did you try the experimental greenworks version prior to using madspy's, did you have problems with that one?

  • The experimental one never worked for me (not fully anyway).

  • Yes, this means that "--in-process-gpu" is off the table and not needed anymore?

    It is possibly not needed any more. I'm currently not able to test it, I think MadSpy might know more about that?

  • Are there more than one package.json files? I only edit the one inside package.nw o.O

    EDIT: nevermind i'm retard as always, they're in exporters\html5\nwjs

    I always used to directly edit the exported file...

  • Updated the Roundup with the following change(s):

    • Easy Way To Modify "Chromium-Args"
    • How To: Set Your Own Application Icon
    • How To: Fix Unusual NW.js MacOSX Exporting Size

    Thanks for your suggestions, keep'em coming!

  • Someone stick this post plz

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
91 7,684
zenox98's avatar
zenox98
Unread hot topic
164 38,121
totoe's avatar
totoe
Unread hot topic
98 7,602
norum82's avatar
norum82