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

Bug: App crashes when poping up a menu #5513

Closed
zaygraveyard opened this issue Nov 30, 2016 · 3 comments
Closed

Bug: App crashes when poping up a menu #5513

zaygraveyard opened this issue Nov 30, 2016 · 3 comments
Assignees

Comments

@zaygraveyard
Copy link

Using

  • nw v0.18.8 (sdk)
  • macOS 10.12.1 (16B2555)

How to reproduce

"crash.html"

<html>
  <head>
    <script type="text/javascript">require('./crash.js')</script>
  </head>
  <body>
  </body>
</html>

"crash.js"

var menu = new nw.Menu();
menu.append(new nw.MenuItem({
    label: 'Crash',
}));
menu.popup(0, 0);

Run an app having "main": "crash.html" in the "package.json"

What's expected

The app lunches without crashing and a menu is open in the top left corner of the window.
See the workaround below.

What actually happens

The app crashs.

Workaround

"nocrash.html"

<html>
  <head>
    <script type="text/javascript">
      global.newMenu = function() {
        return new nw.Menu();
      };
      require('./nocrash.js');
    </script>
  </head>
  <body>
  </body>
</html>

"nocrash.js"

var menu = global.newMenu();
menu.append(new nw.MenuItem({
    label: 'No Crash',
}));
menu.popup(0, 0);

Crash Dump

I will provide one if needed.

@ghostoy
Copy link
Member

ghostoy commented Dec 15, 2016

The issue is caused by calling in background page. However background page does not have a web page. So you will see the menu popup in the bottom left of the screen. I will fix the crash, but it's not recommended to call it in background page.

@zaygraveyard
Copy link
Author

@ghostoy Thank you
Is there somewhere I read more about background pages?

@ghostoy
Copy link
Member

ghostoy commented Dec 16, 2016

The background page is a default HTML loaded on start. See Chrome App Background Pages.

And "In NW.js, Node.js modules can be loaded in the context running in background page, which is the default behavior." See Javascript Context in NW.js.

rogerwang pushed a commit that referenced this issue Dec 20, 2016
zaygraveyard added a commit to zaygraveyard/koala that referenced this issue Apr 23, 2017
zaygraveyard added a commit to zaygraveyard/koala that referenced this issue Apr 23, 2017
* chore/update-nw:
  Add a workaround a bug in nwjs/nw.js#5513
  Update the URL to be relative.
  Replace `require(‘nw.gui’)` with the global `nw`.
  Remove setting the `localStorage` of the `global`. It’s set by default.
zaygraveyard added a commit to zaygraveyard/koala that referenced this issue Apr 25, 2017
* develop:
  Bump version to 2.1.0
  Update copyright year to 2017.
  Correct a contributor’s name.
  Update the compilers.
  Add a build system for making releases using gulp.
  Add a workaround a bug in nwjs/nw.js#5513
  Update the URL to be relative.
  Replace `require(‘nw.gui’)` with the global `nw`.
  Remove setting the `localStorage` of the `global`. It’s set by default.
  Improve the feature
  Use JSON files and update default JSON config files
  Support for AutoPrefix Config on CSS, LESS and Sass
  change the default value of maxBuffer oklai#162
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

2 participants