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

Dynamic binary eval. #5168

Closed
kilgaloon opened this issue Jul 30, 2016 · 27 comments
Closed

Dynamic binary eval. #5168

kilgaloon opened this issue Jul 30, 2016 · 27 comments
Assignees

Comments

@kilgaloon
Copy link

Hello everyone,

I just noticed that when i try to load binary files dynamicaly, for example, using for loop and looping through some array for example:

var arr = ["home","front"];

for(i=0;i<arr.length;i++) {
require('nw.gui').Window.get().evalNWBin(null, process.cwd() + '/' + arr[i] + '.bin');
}

home.bin get executed twice. It never get to front.bin.

Anyway no mather how much arr is long, first element will be evaled for arr.length times.

OS: Debian Jessie x64
NW: 0.14.6

@ghostoy
Copy link
Member

ghostoy commented Jul 30, 2016

I will look into this issue.

Strahinja [email protected]于2016年7月30日周六 23:15写道:

Hello everyone,

I just noticed that when i try to load binary files dynamicaly, for
example, using for loop and looping through some array for example:

var arr = ["home","front"];

for(i=0;i<arr.length;i++) {
require('nw.gui').Window.get().evalNWBin(null, process.cwd() + '/' +
arr[i] + '.bin');
}

home.bin get executed twice. It never get to front.bin.

Anyway no mather how much arr is long, first element will be evaled for
arr.length times.

OS: Debian Jessie x64
NW: 0.14.6


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#5168, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAczeAez-n4rVJ0bMW8GczXrpNq5jmsTks5qa2p3gaJpZM4JY06U
.

@ghostoy
Copy link
Member

ghostoy commented Aug 1, 2016

@kilgaloon I cannot reproduce this issue. Here is my test case: https://gist.github.com/ghostoy/183649c64060b088a610ebc142fae3d2

I got foo and bar both in the console.

@kilgaloon
Copy link
Author

Can you put for loop in another bin, then try.

@ghostoy
Copy link
Member

ghostoy commented Aug 2, 2016

@kilgaloon What do you mean by "another bin"? A third one?

@kilgaloon
Copy link
Author

@ghostoy Yes, put for loop in third bin, lets say main.bin and try it like that

@kilgaloon
Copy link
Author

kilgaloon commented Aug 2, 2016

For me it actually doesn't mather where im doing for loop. im using following snippet of code:

   results = ["main","front","admin"];     
   for(i=0;i<=results.length;i++) {
      nw.Window.get().evalNWBin(null, process.cwd() + "/plugins/" + results[i] + "/" + results[i] + ".bin");
    }

every of this bins have corresponding log depending of their name console.log('main loaded.') etc.
So, what ever i do i get 3 main loaded, if i put front to be first element i will get 3 front loaded. This is getting weird since you guys can't reproduce this. But im getting same with jQuery.each function or with classic for loop.

@ghostoy
Copy link
Member

ghostoy commented Aug 2, 2016

@kilgaloon Could you upload your entire test app as attachment?

@kilgaloon
Copy link
Author

I'll contact you on gitter

@ghostoy
Copy link
Member

ghostoy commented Aug 2, 2016

@kilgaloon It's quite late for me. Please send attachment to Github and I'll check it tomorrow.

@kilgaloon
Copy link
Author

Project is kinda big, can you give me some where i can privately share it with you?

@semmel
Copy link

semmel commented Aug 4, 2016

I can confirm that multiple evalNWBin commands always execute just the .bin which was first specified. It has nothing to do whether the bins have a relative or absolute path.
System: OS X, nwjs 0.16.0 (SDK)
To demo I took @ghostoy 's gist and added some buttons which trigger the evaluation of the separate bins. See my fork. It's funny to watch on the system console.

Is there some caching going on with evalNWBin?

By the way, I noticed that executing evalNWBin from the developer console does not work.

@kilgaloon
Copy link
Author

I can confirm that also when i start app and momentally open developer console, brhavior will be same like its not included.

@ghostoy
Copy link
Member

ghostoy commented Aug 5, 2016

You can send mail to me cong.liux#gmail.com

Strahinja [email protected]于2016年8月4日周四 18:38写道:

Project is kinda big, can you give me some where i can privately share it
with you?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#5168 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAczeNW-FqImhTD51W_jTyudpJq7DUIdks5qccEpgaJpZM4JY06U
.

@ghostoy
Copy link
Member

ghostoy commented Aug 5, 2016

@rogerwang I can reproduce this issue with 0.14.6 and 0.16.0.

I've updated my gist @ https://gist.github.com/ghostoy/183649c64060b088a610ebc142fae3d2.

Steps to reproduce:

  • build foo.js and bar.js with nwjc
  • launch the app. test() run for first time at start.
  • click "test" button. test() will run again.
  • watch the output in console

This issue seems to be more easier to reproduce on 0.16.0.

On 0.14.6, it only produces the logs from later script, i.e. bar.bin, when run test() for a second time.

[27680:27680:0805/122054:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/foo.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27680:27680:0805/122054:INFO:CONSOLE(0)] "foo", source:  (0)
[27680:27680:0805/122054:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/bar.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27680:27680:0805/122054:INFO:CONSOLE(0)] "bar", source:  (0)
[27680:27680:0805/122056:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/foo.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27680:27680:0805/122056:INFO:CONSOLE(0)] "bar", source:  (0)
[27680:27680:0805/122056:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/bar.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27680:27680:0805/122056:INFO:CONSOLE(0)] "bar", source:  (0)

And on 0.16.0, it always produces the logs from former script, i.e. foo.bin:

[27817:27817:0805/122147:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/foo.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27817:27817:0805/122147:INFO:CONSOLE(0)] "foo", source:  (0)
[27817:27817:0805/122147:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/bar.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27817:27817:0805/122147:INFO:CONSOLE(0)] "foo", source:  (0)
[27817:27817:0805/122151:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/foo.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27817:27817:0805/122151:INFO:CONSOLE(0)] "foo", source:  (0)
[27817:27817:0805/122151:INFO:CONSOLE(15)] "evalNWBin(null, '/home/user/Workspace/test/nwjc-test/bar.bin')", source: chrome-extension://oaohmlchfoanhbkbdhppgoadbhammijj/index.html (15)
[27817:27817:0805/122151:INFO:CONSOLE(0)] "foo", source:  (0)

@kilgaloon
Copy link
Author

Good you reproduced this, one more thing to mention, there is also no difference if you put them in loop or you put them like this (using @ghostoy gist):

nw.Window.get().evalNWBin(null, process.cwd() + '/foo.bin');
nw.Window.get().evalNWBin(null, process.cwd() + '/bar.bin');

When i do this to more bins, same thing happen, first always get evaled n times where n = evalNWBin functions.

@kilgaloon
Copy link
Author

@ghostoy @rogerwang Is fix for this going to happen anytime soon? im just curious.

@mscreenie
Copy link
Contributor

@ghostoy Can bins be loaded via http or https urls?

@ghostoy
Copy link
Member

ghostoy commented Aug 11, 2016

@mscreenie No. Currently only supports local files.

@mscreenie
Copy link
Contributor

Thanks should I open something to request that as a feature?

@ghostoy
Copy link
Member

ghostoy commented Aug 15, 2016

@mscreenie Yes, thanks.

@rogerwang
Copy link
Member

@kilgaloon will fix it soon around 0.17 release, which will happen soon.

@kilgaloon
Copy link
Author

@rogerwang Nice to hear that. Can't wait.

@rogerwang
Copy link
Member

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

The root cause is NW is using previous cache of code.

@kilgaloon
Copy link
Author

Great, nice to hear that, my project has been stalling because of this issue. Can't wait to see this working. Thanks

@prominentdetail
Copy link

prominentdetail commented Nov 13, 2016

I have this issue on 0.14.7 LTS
I can't use 0.17

@namaljayathunga
Copy link

I still have this issue on 0.14.7 LTS. Please fix this issue. thanks

@xianlong1226
Copy link

Due to our system to support the xp, we have to use 0.14.7 version, please repair this version as much as possible.

wanghongjuan added a commit to wanghongjuan/nw.js that referenced this issue Jun 26, 2018
- Add test for issue nwjs#5168
- This test is failed on v0.16.0, passed on v0.31.3
@wanghongjuan wanghongjuan self-assigned this Jun 26, 2018
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

9 participants