Nw.js: Crash on start when using binary

Created on 27 Jul 2017  路  9Comments  路  Source: nwjs/nw.js

I compiled my application with nwjc but when I use evalNWBin, the application crashes on start.
With original js file, it works fine.

When I tried with simple js file which contains one line alert() only, compiled binary works too.
Maybe some pacakge contains compatibility issue?

I attach my crash dump, here.

0c6e696d-ea69-44bc-b12b-7edd26faf958.zip

NW.js version: 0.24.0 SDK for window 64bit

P1 bug triaged

All 9 comments

I can't reproduce your issue. It works fine on Windows 8.1 with nwjs-sdk-v0.24.0.
Could you please share your sample for me to reproduce it?

@Christywl Finally, I could narrow down the problematic parts.

I'm using angular 1.6.6 and, here's minimal reproducible example code:

index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <script>nw.Window.get().evalNWBin(null, 'index.js.bin');</script>
  </head>
  <body ng-app="app" ng-cloak>
    <test></test>
  </body>
</html>

index.js:

'use strict';

const angular = require('angular');
const assert  = require('assert');

class Class {}
function Constructor () {}

const obj1 = new Class();
const obj2 = new Constructor();
assert(obj1 !== obj2);

const test = {
  controller: Constructor,
  template  : 'test'
};

test.controller = Class; // causes crash

const app = angular
  .module('app', [])
  .component('test', test)
  .name;

module.exports = app;

index.js.bin file is created by:

> nwjc index.js index.js.bin

When I giving controller using a class, the app crashes. If I give it as a constructor function by commenting outtest.controller = Class; // causes crash , it just works fine.

This code is tested on Windows 10 with nwjs-sdk-v0.25.0.

@xylosper , an error occurs when I use your codes on Windows 10 with nwjs-sdk-v0.25.0:
image

I'm sorry for incomplete example. I think 'mixed context' should be enabled.

I've tried to make a separated and complete example:

nw-crash.zip

Although this example does not crash, it says some reference error when binary used while it works perfect when js used.

D:\nw-crash\node_modules\angular\index.js:2 Uncaught ReferenceError: angular is not defined
    at Object.<anonymous> (D:\nw-crash\node_modules\angular\index.js:2:18)
    at Module._compile (module.js:597:30)
    at Object.Module._extensions..js (module.js:614:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Module.require (module.js:541:17)
    at require (internal/module.js:11:18)
    at self.require (<anonymous>:11:26)
    at <anonymous>:0:0

Use the updated sample, I see the same error and don't meet the crash. So the reported crash issue also doesn't reproduce for you now?

@Christywl
Still crash in my whole project, but I couldn't find exact part which causes crash yet.

I also have the same issue, and have narrowed it down to having something to do with classes.
When compiling with nwjc, the app crashes at some point. When running the regular index.js directly, everything works.

Example:

index.js

class DevClass {
  constructor() {
    console.log("DevClass constructor")
  }
}

var devItem = new DevClass()

console.log(devItem)

index-bin.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <script>
      nw.Window.get().evalNWBin(null, 'index.bin')
    </script>
  </body>
</html>
nwjc index.js index.bin

Opening the dev tools, the created devItem is shown via console.log, but when opening it and clicking on __proto__ the app crashes.

nwjc-crash-dev

Windows 10 with NW 0.25.0-sdk

I can reproduce the crash with noviwiden's codes on Linux/Windows 10 with nwjs-sdk-v0.25.2.

This is fixed in git and will be available in the next nightly build.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nawazishali picture nawazishali  路  3Comments

azer picture azer  路  3Comments

gengshenghong picture gengshenghong  路  3Comments

chino23 picture chino23  路  3Comments

daverave1212 picture daverave1212  路  3Comments