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

"canvas is not a constructor" #12

Open
lakeinchina opened this issue Jun 29, 2018 · 2 comments
Open

"canvas is not a constructor" #12

lakeinchina opened this issue Jun 29, 2018 · 2 comments
Assignees

Comments

@lakeinchina
Copy link

I compile ejecta-v8 as a module of ejecta-v8-sample.when i 'run in Ejecta-v8 View' , it crash.
plasma.js:

	var canvas = require('canvas');
	console.log("canvasA="+canvas);
	var c = new canvas(view);

ag.boersego.bgjs.sample I/BGJSV8Engine-jni: viewCreated called [object Arguments]
ag.boersego.bgjs.sample I/BGJSV8Engine-jni: canvasA=[object HTMLCanvasElement]

beginning of crash
ag.boersego.bgjs.sample E/AndroidRuntime: FATAL EXCEPTION: Thread-4296
Process: ag.boersego.bgjs.sample, PID: 23679
ag.boersego.bgjs.V8Exception: An exception was thrown in JavaScript
at ag.boersego.bgjs.JNIV8Function._callAsV8Function(Native Method)
at ag.boersego.bgjs.JNIV8Function.callAsV8Function(JNIV8Function.java:22)
at ag.boersego.bgjs.sample.DemoEjectaFragment.initializeV8(DemoEjectaFragment.java:76)
at ag.boersego.bgjs.sample.DemoEjectaFragment.access$200(DemoEjectaFragment.java:24)
at ag.boersego.bgjs.sample.DemoEjectaFragment$1$1.onGLCreated(DemoEjectaFragment.java:97)
at ag.boersego.bgjs.V8TextureView$RenderThread.run(V8TextureView.java:743)
Caused by: ag.boersego.bgjs.V8JSException: [TypeError] canvas is not a constructor
at global.startPlasma(js/plasma.js:106)

any help?

@lakeinchina
Copy link
Author

well,canvas is a function,so I replaced

var c = new canvas(view);

with

var c = canvas(view);

And it works,but why?

@unverbraucht unverbraucht self-assigned this Aug 29, 2018
@unverbraucht
Copy link
Contributor

These are two different ways of calling constructors in v8 native-backed functions. I'll look into it, thanks.

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

2 participants