Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on start when using binary #6061

Closed
bylee20 opened this issue Jul 27, 2017 · 9 comments
Closed

Crash on start when using binary #6061

bylee20 opened this issue Jul 27, 2017 · 9 comments
Assignees

Comments

@bylee20
Copy link

bylee20 commented Jul 27, 2017

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

@Christywl
Copy link
Contributor

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?

@bylee20
Copy link
Author

bylee20 commented Sep 7, 2017

@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.

@Christywl
Copy link
Contributor

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

@bylee20
Copy link
Author

bylee20 commented Sep 9, 2017

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

@Christywl
Copy link
Contributor

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?

@bylee20
Copy link
Author

bylee20 commented Sep 11, 2017

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

@noviwiden
Copy link

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

@Christywl
Copy link
Contributor

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

@rogerwang
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants