Is It possible To Manipulate NW.js to Enable/Disable Certain Chromium Args Using JS?

837 views
Skip to first unread message

dannyy...@googlemail.com

unread,
Apr 15, 2018, 5:22:13 AM4/15/18
to nw.js
Hello NW.js Team!
I'm mainly developing HTML5 games with Construct 2 + NW.js and I'm really interested in features that fit into that category. Two important features that modern video games support in native backgrounds is setting the framerate (FPS) and V-Sync options on the fly, inside the game itself. While
--disable-gpu-vsync and --limit-fps=60 work great and can be hidden inside the manifest file, I would like to give my users/players the choice to set these settings inside the game itself.
So my simple questions would be:
  1. Is it possible to manipulate NW.js in order to limit to framerate (FPS) instantly, using JS code or something similar?
  2. Is it possible to manipulate NW.js in order to disable/enable V-Sync instantly, using JS code or something similar?

Cheers!

Roger Wang

unread,
Apr 15, 2018, 10:05:26 PM4/15/18
to nw.js
It would depends on how the switch is used in Chrome. IMO they are only effective when the browser is started. So you might want to modify package.json in your app and prompt user to restart your app.

dannyy...@googlemail.com

unread,
Apr 16, 2018, 10:30:19 AM4/16/18
to nw.js
Sounds good, thanks!

I'm a beginner with JS, do you know an API or something else in order to easily modify the chromium arg's property inside the manifest file?
Also is there a "Complete Reload" feature that can automatically close and re-open NWjs instead of the user doing it manually?

Russell Valentine

unread,
Apr 18, 2018, 11:32:31 AM4/18/18
to nw.js
package.json is just a json file you can read the file in as a string then do JSONIFY.parse(package_json_str); modify it then stringify it and save it again.

Maybe this document would be helpful.
https://www.codementor.io/codementorteam/how-to-use-json-files-in-node-js-85hndqt32

Russell Valentine

unread,
Apr 18, 2018, 11:34:50 AM4/18/18
to nw.js
Ohh and reloading, I have no tried it, but this maybe?
https://github.com/nwjs/nw.js/issues/4505

dannyy...@googlemail.com

unread,
Apr 20, 2018, 10:23:51 AM4/20/18
to nw.js
Thanks a lot for the help everyone, I think I can work something out with all the information in here.

Cheers!
Reply all
Reply to author
Forward
0 new messages