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

Introduce CanvasRenderingContext2D and WebGLRenderingContext #16370

Closed
ghost opened this issue Oct 21, 2017 · 7 comments
Closed

Introduce CanvasRenderingContext2D and WebGLRenderingContext #16370

ghost opened this issue Oct 21, 2017 · 7 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@ghost
Copy link

ghost commented Oct 21, 2017

Feautre request: Introduce CanvasRenderingContext2D and WebGLRenderingContext constructors in Node.js. There are a few modules on npm trying to simulate them, but their performance and number of methods (and also number of issues) simply cannot be compared with, for example, Chrome's implementation.

Node.js doesn't have to display rendered image, just let users obtain rgb24 byte stream to use for further purposes. I tried to create a good implementation and publish it as npm module, but it was a huge failure.

What do you think about this idea? If you want new developers for this purpose, then I cannot help you. But I'm sure this will be a great step for Node.js.

@mscdex
Copy link
Contributor

mscdex commented Oct 22, 2017

-1 These sorts of things are best left to userland.

@mscdex mscdex added the feature request Issues that request new features to be added to Node.js. label Oct 22, 2017
@addaleax
Copy link
Member

@6-8-axnw1bom81v5xa3nh48c It might be helpful if you could mention what difficulties you were running into when developing this as an npm module? Moving the work into Node wouldn’t get rid of any of these…

(Unless there’s anything in here that definitely can’t be done without support from inside Node, I’d agree with @mscdex, this should be done in userland…)

@ghost
Copy link
Author

ghost commented Oct 22, 2017

@addaleax Thanks for the response. Well, implementing WebGL is much harder than I thought. In order to create an useful, fast and efficient WebGL engine, one must create GLSL parser and compiler, code optimizer, translate the code into assemblies, use CUDA or other engine to embed the compiled code into GPU, implement efficient vector and matrix operations, multiplication, transposition, inverse, determinant, and also a lot of operations on vectors, dot and cross product, angle and so on.

Also, by creating GLSL parser, one must take care about syntax and type errors in the shader code, prevent compiling bad code, detect memory leaks, and moreover, optimize everything so that it works fast like in Chrome. "What difficulties you were running into when developing this?" - well, if it was easy, everyone would create its own engine for this purpose. Thats a lot of work and its definitely not easy.

As for 2D canvas context, it is not such a big problem. There are already some fast modules which (although not supporting all methods defined by the standard) allow users to render 2D graphics and obtain byte stream.

@addaleax
Copy link
Member

@6-8-axnw1bom81v5xa3nh48c I don’t think any of that is going to be easier when being implemented inside of Node…

@Fishrock123 Fishrock123 changed the title Feature request Introduce CanvasRenderingContext2D and WebGLRenderingContext Oct 22, 2017
@Fishrock123
Copy link
Contributor

I think you probably want a headless browser. Chrome supports running like that natively these days, you'll just have to find how to launch it without launching a window.

@ghost
Copy link
Author

ghost commented Oct 22, 2017

@Fishrock123 Thank you for suggestion. There are already headless browsers (like PhantomJS) and also it is easy to launch even Chrome in headless mode (at least on Windows). However, the problem is because there is no way to transfer the image data buffer to Node.js, except using WebSocket or XMLHttpRequest. Both ways are extremely slow for huge renderings, and therefore completely useless.

@TimothyGu
Copy link
Member

@6-8-axnw1bom81v5xa3nh48c A quick Google search turns up headless-gl which uses ANGLE, so obviously not GPU-accelerated, but probably still faster than WebSocket etc.

Either way, this question is better suited for nodejs/help than here, which is used for issues in Node.js itself. Thus, closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

4 participants