Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

EventEmitter codepath crashes node.js #30

Closed
Ivshti opened this issue Jul 26, 2015 · 14 comments
Closed

EventEmitter codepath crashes node.js #30

Ivshti opened this issue Jul 26, 2015 · 14 comments
Labels

Comments

@Ivshti
Copy link
Contributor

Ivshti commented Jul 26, 2015

When running webchimera.js in node.js, we get:

    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    _jsEventEmitter.Reset( isolate,
        v8::Local<v8::Function>::Cast(
            Require( "events" )->Get(
                v8::String::NewFromUtf8( isolate,
                                         "EventEmitter",
                                         v8::String::kInternalizedString ) ) )->NewInstance() );
 0   node                              0x000000010011e258 v8::Object::Get(v8::Handle<v8::Value>) + 20
1   WebChimera.js.node                0x000000010328f628 JsVlcPlayer::JsVlcPlayer(v8::Local<v8::Object>&, v8::Local<v8::Array> const&) + 728
2   WebChimera.js.node                0x000000010328f094 JsVlcPlayer::jsCreate(v8::FunctionCallbackInfo<v8::Value> const&) + 244
3   node                              0x0000000100133a23

The fault should be in how Require is implemented here
https://github.com/RSATom/WebChimera.js/blob/master/src/NodeTools.cpp

@RSATom RSATom added the bug label Jul 26, 2015
@RSATom
Copy link
Owner

RSATom commented Jul 26, 2015

Thanks! I'll check.

@RSATom
Copy link
Owner

RSATom commented Aug 1, 2015

Can you give me some .js for node.js to test?

@Ivshti
Copy link
Contributor Author

Ivshti commented Aug 1, 2015

Simply

var WebChimera = require("webchimera.js");
var player = WebChimera.createPlayer([ "-vvv" ]);
player.onFrameSetup = function(width, height, pixelFormat) { 
  console.log("frame setup",width,height) 
};
player.onFrameReady = function(frame) { typeof(display)=="function" && display() };
player.play("file:///Users/ivogeorgiev/Downloads/1.mkv"); // update that
global.player = player;

Node.js 0.12.2

@RSATom
Copy link
Owner

RSATom commented Aug 1, 2015

Thanks!

@Ivshti
Copy link
Contributor Author

Ivshti commented Aug 1, 2015

Did you reproduce it? I can't figure why this is happening.

@RSATom
Copy link
Owner

RSATom commented Aug 1, 2015

trying...

@RSATom
Copy link
Owner

RSATom commented Aug 1, 2015

by some reason Require("events") returns null on node.js/io.js

@RSATom
Copy link
Owner

RSATom commented Aug 1, 2015

will try investigate it deeply tomorrow.

@RSATom
Copy link
Owner

RSATom commented Aug 2, 2015

It seems the problem is on node.js require defined not as function of global.

  • nw.js: console.log(global.require) gives
function require(path) {
    return self.require(path);
}
  • node.js: console.log(global.require) gives
undefined

so to solve this issue I need understand where I can find require on Node.js

@Ivshti
Copy link
Contributor Author

Ivshti commented Aug 2, 2015

That makes sense. Can't we just get require from the current context?

@RSATom
Copy link
Owner

RSATom commented Aug 2, 2015

In c++ I need some object to get it's function, with nwjs I use global, and don't know what to use with node.js

@Ivshti
Copy link
Contributor Author

Ivshti commented Aug 2, 2015

Use module.

module.require

Module is like the global context in node.js

@RSATom
Copy link
Owner

RSATom commented Aug 2, 2015

thanks, I'll try

@RSATom RSATom closed this as completed in 5a6d93e Aug 2, 2015
@Ivshti
Copy link
Contributor Author

Ivshti commented Aug 2, 2015

Amazing, thanks!

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

No branches or pull requests

2 participants