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

0.6.0 - "Unable to get render view in Show" on Window.open #808

Closed
AndryBray opened this issue Jun 21, 2013 · 12 comments
Closed

0.6.0 - "Unable to get render view in Show" on Window.open #808

AndryBray opened this issue Jun 21, 2013 · 12 comments

Comments

@AndryBray
Copy link

Hello, I have updated to the last version 0.6.0 and my app is not working as before (0.5.0).

In my app I have 2 shortcuts. When I click a shortcut, a new window will be opened (with a remote url).

This is what I do and where I get the error:
"Uncaught Error: Unable to get render view in Show", source: window_bindings.js (214)

var url = 'http://192.168.1.1/...and so on.',
var path = 'a_unique_path';


if(typeof global.applications[path] != 'undefined' && global.applications[path] != null) 
{
   global.applications[path].show();
}
else {
    var wp = {
            frame : true,
            toolbar: true,
            width: 900,
            height: 750,
            show: false
    };
    var app = gui.Window.open(url, wp);
    global.applicationLocks[path] = true; //a global lock to avoid multiple windows
       //--->here I get the error
    app.on('loaded', function(){
        //--> here the script goes, but doesn't show the window.
    });
}

To see the window I have to click another time over the shortcut and it seams to work because if the window is still opened, the script will call just the .show() method.

@rogerwang
Copy link
Member

Hello. I'm not very sure how to reproduce this. Can you please provide a full case?

@AndryBray
Copy link
Author

I'm sorry but the full app it's too big. I can post the method where I get the problem.You can call this method passing the shortcut (DOM reference with a "data-path" attribute )

Just for info: I tried to delete the "wp" config in "gui.Window.open(url, wp);" and the window is opening.
Could it be a "show: false" param problem?

function openApplication(shortcut) {
    //shortcut is the DOM node of icon in a toolbar like window (the first window)

    //a little buffer for fast clicks
    if(clickBuffer != null)
        clearTimeout(clickBuffer);

    var path = shortcut.getAttribute('data-path');

    //global.applications is the stack of running apps (windows) for global access
    if(typeof global.applications[path] != 'undefined' && global.applications[path] != null) {
        //show again if it was hidden/yet launched
        global.applications[path].show();
    } 
    else {
        //check if any lock for process end waiting
        if(typeof global.applicationLocks[path] != 'undefined' && global.applicationLocks[path] === true) {
            //stop the action to wait lock releasing
            console.log('app locked... return');
            return false;
        }

        var url = appsEntrypointUrl + path + '/index.html';
        //loading params to set for window
        var wp = {
            frame : true,
            toolbar: true,
            width: 900,
            height: 750,
            show: false
        };

        var app = gui.Window.open(url, wp);
        app.path = path;
        console.log(app);

        //insert lock for current app
        global.applicationLocks[path] = true;

        app.on('loaded', function(){
            console.log('app loaded');
            //adding close listener
            this.on('close', function() {
                console.log('app close');

                var deletingPath = this.path;
                //here we will save the windows coordinates, size , ...
                this.hide();
                //saving (todo)....

                //closing
                this.close(true);

                //set up a little delay to wait for the end of process (before to let open it again)
                setTimeout(function() {
                    global.applicationLocks[deletingPath] = false;
                    //reset reference
                    global.applications[deletingPath] = null;
                }, 500);
            });

            //map app to global var
            global.applications[path] = this;

            // prevent default behavior from changing page on dropped file
            // to do dynamic behavior per app
            this.window.ondragover = function(e) { e.preventDefault(); return false };
            this.window.ondrop = function(e) { e.preventDefault(); return false };
        });

        app.show();
    } 
}

@AndryBray
Copy link
Author

I can confirm if I change the "show" param from false to true the window is opening. I think it's a problem if you start with an hidden window... am I wrong?

How can I add listeners before to "show" method?

So I changed "show" from false to true, deleted the app.show() at the end and it works, but I get the error
"Uncaught ReferenceError: require is not defined"
in the new window console.

@AndryBray
Copy link
Author

It seems that everytime I open the console I get this error at the end of the console
"Uncaught ReferenceError: require is not defined"
(anonymous function)

@rogerwang
Copy link
Member

I'm trying to reproduce it with the following code but it works:

<html>
<head>
<title>nwgui</title>
<script>
var nwgui = require('nw.gui');
    var wp = {
            frame : true,
            toolbar: true,
            width: 900,
            height: 750,
            show: false
    };
var win = nwgui.Window.open('http://www.google.com', wp);
win.on('loaded', function(){
  console.log("win loaded");
  this.on('close', function() {
          console.log('app close');
          });
});
</script>
</head>
<body>
</body>
</html>

@AndryBray
Copy link
Author

I forgot to tell you that I'm testing it on MacOS 10.8.4.

How can you open the window if the "show" is false and you don't call the win.show() ?

@AndryBray
Copy link
Author

About the showing problem I have fixed it moving the win.show() method inside the "loaded" callback like that

app.on('loaded', function(){
  app.show();
});

It's strange it was working on previous versions of nodewebkit.

Now seems to work well but when I open the dev tool window I get the error:
"Uncaught ReferenceError: require is not defined", source: (1)

Do I open a new issue for this?

@Mithgol
Copy link
Contributor

Mithgol commented Jun 21, 2013

Now seems to work well but when I open the dev tool window I get the error:
"Uncaught ReferenceError: require is not defined", source: (1)

Do I open a new issue for this?

You probably should. As far as I can tell, the above code fragments (that you provided as test cases for your current issue) do not contain any require, and thus the two issues are probably not related to each other.

@AndryBray
Copy link
Author

Yes, I didn't paste the require snippet because it was just a part of code... of course in my real app there is the "require" code. I'm going to open a new ticket. Thank you

@Subash
Copy link

Subash commented Jul 3, 2013

I am also randomly getting this error.

@tommoor
Copy link

tommoor commented Dec 16, 2014

Please reopen if this is still an issue in the latest build.

@tommoor tommoor closed this as completed Dec 16, 2014
@darshan-craft
Copy link

+1 to that.. Even I am facing the same issue. I am using node webkit version 0.12.0-alpha2 on Mac OS X

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

No branches or pull requests

6 participants