Hacker News new | comments | show | ask | jobs | submit login

PPAPI is a platform for plugins to safely port existing native code, and implement performance critical components. The PPAPI platform capabilities (audio, canvas, webgl, etc) already exist as regular JavaScript APIs in Chrome. So, if you want to use them on normal web content you can. However, in doing so you incur both the strengths and limitations of the web platform (e.g. JavaScript dispatch, IPC overhead, and a single-threaded execution context).

You gave the example of using canvas from a web worker. Unfortunately, the whole web platform is built on the assumption of a single-threaded execution pipeline. Web workers get around this by using postMessage and not having access to the DOM, shared variables, and other stateful parts of the platform. Canvas and WebGl as spec'd and implemented are tied to these stateful parts of the platform (DOM, etc.), which is why you cannot use them from a worker.

So, your desired change would involve either a major overhaul of the web as spec'd and implemented, or a change to the Canvas and WebGL standards. The first is probably not going to happen. The second is achievable and implementable, but wouldn't help address the use cases I described in my first sentence.




I'm well aware that, at the moment, the canvas context is restricted to a single thread. But this could be changed. All you have to do is to provide an API to move a canvas context to a different thread/worker. This is quite simple. There's a Mozilla bug on it: https://bugzilla.mozilla.org/show_bug.cgi?id=709490

It requires no more engineering effort than it took to implement the corresponding code in the PPAPI, and probably a lot less. Moreover, non-NaCl and non-plugin code could benefit from it.

As explained before, what would need to be done is simply to expose native versions of the Web APIs. These APIs would mirror the Web APIs more or less exactly (maybe using pointers to buffers instead of typed arrays, for example, but otherwise they'd be the same). In the cases in which Web APIs are not sufficient, both the native and JavaScript versions would be extended. In this way, "performance critical components" of native code and Web content would both benefit.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: