-
Notifications
You must be signed in to change notification settings - Fork 46
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
Cannot read property 'firstChild' of null [solved] #44
Comments
Hey Chayemor, This isn't a If you
|
Mmm, seems to still be doing it. After clearing cache with your code (
The same exception occurs because the Thanks for the help either way. |
try |
Prints out proper |
that was fast... |
Had tried it already XD. |
let's try to hack it, put everything in a |
or maybe in the |
I've had this issue before though, with totally different js files in new windows in I'm pretty sure I found some hack for it a long time ago, I just can't figure out what it was... for the sake of insanity, let's do something crazy.. copy |
This is insane. Same problem. I even installed require-new module. (link)
I went ahead and did NOT require module on my first window. Still happens. How is that even possible? But if I change the app's package.json file and set video_emit as first window to open up, then it works. But if I open a new window, same problem. |
Don't be amazed, I've even seen errors/console.logs leak to the main window from the |
I don't know what else to do, clearing cache is not workign and I really need to be able to use wcjs-player in opened window. :S |
Uhm... I'm testing this in the simplest of ways, if you turn on the toolbar of nw.js, you'll see that it has 2 refresh buttons, one on the right, another on the left. If you refresh the new window with the left refresh button, it just gives the same error again, but if you refresh it with the right button, the player starts in the new window. A programatic refresh ( |
Ok, I hacked it. :) Example Usage:
Looking through other tickets related to this error, it seems that only |
Now the player loads, but the global variable is brand new, not sharing the one it had with parent window. All the functions the parent window *loaded * on global variable are gone. ( from your proof of concept) ** index.html **
new_window.html
The new_window.html output is undefined. |
Try using |
Or if you have more complex needs you could connect the two windows with websockets to pass data between them. |
Appreciate all your help! I'll be trying Electron, if it doesn't work well I'll stick with NW.js and use localStorage. Thanks. |
Hi! I have the same problem and it's also connected to this issue @Chayemor for me worked mixed context mode (in package.json add chromium-args: "--mixed-context") so any modules required with require() are running in the same context. @jaruba since I have some other problems in mixed-mode and prefer not to use it if possible, I'd like to ask whether it will be possible to somehow wrap wcjs-player module and pass a proper window object (for example when we create a new player)? Thanks |
@KiresMA I remember attempting that with a different user at one point (to pass the We can try it again though, if you'd like.. it's not too complicated as you may imagine.. just replace all instances of
at the top of the script file, then delete these lines https://github.com/jaruba/wcjs-player/blob/master/index.js#L48-L69 and on this line https://github.com/jaruba/wcjs-player/blob/master/index.js#L222 add something like:
that should be everything.. then you can just do:
If you test this and it works for you, I'll gladly accept a Pull Request for it, as it's a very common issue with NW.js |
That different user probably was me :) that's why it didn't work for me last time and now either. By the way, thank you for your quick answers! You are really quick in responses! :) |
https://github.com/jaruba/wcjs-player/blob/master/index.js#L41-L45 - This can also be moved in the I think we thought about this the wrong way in the first place.. because the way I made So instead of doing:
What we should actually do is:
Then use it like:
And it should work! :) |
@KiresMA Good catch on https://github.com/jaruba/wcjs-player/blob/master/index.js#L81 , it all makes sense now.. I think this could even be taken one step further and we could localize each |
Here's my final train of thought.. https://github.com/jaruba/wcjs-player/blob/master/index.js#L38-L69 Should be changed to:
Then we'd go here: And change it to something like:
Then replace all occurrences of I hope I made it all clear enough.. And if it works, we'd have localized Same usage would apply:
|
I tested the last code I recommended with NW.js 0.17.1 32bit, and something very strange is happening.. I still get:
from:
but if i do:
right above it, it logs:
correctly.. same goes for everything else in the module, it's like although I'm sending everything to the proper |
Well, for me it's the same situation :( |
i think this should be discussed with the NW.js guys directly, but they rarely if ever answer any of their issues (or at least that was the case in the past) i switched to using Electron instead of NW.js in my projects just because of the fact that the Electron guys always answer their issues, and actually want to help fix them too |
I don't know if this is wcjs-player issue or NW.js issue. It seems that when module is called on new Window, somehow the
window
objects points to parent window.Environment
Problem
New window is opened from parent window. Webchimera module is loaded but it crashes because its window object points to parent Window.
PARENT
video_emit Window
In node_modules\wcjs-player\index.js line 82 I added
console.log(window.document);
PARENT CONSOLE OUTPUT
video_emit CONSOLE OUTPUT
Somehow when the function in wcjs-player module executes, the window object points to the parent Window always instead of window.video_emit.window . Am I loading the module wrong in the child window?
I know that adding new-instance: true to the
gui.Window.open
of the parent would fix this, but I need parent and new window to communicate via the global variable usable only if they are on the same render.The text was updated successfully, but these errors were encountered: