Re: exposing CANVAS or something like it to Web Workers

On Mon, May 14, 2012 at 1:16 PM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Mon, May 14, 2012 at 10:01 PM, Gregg Tavares (勤) <gman@google.com> wrote:
>> I'd like to work on exposing something like CANVAS to web workers.
>>
>> Ideally how over it works I'd like to be able to
>>
>> *) get a 2d context in a web worker
>> *) get a WebGL context in a web worker
>> *) download images in a web worker and the images with both 2d contexts and
>> WebGL contexts
>>
>> Any thoughts?
>
> Have we gotten any further with use cases? See
> http://lists.w3.org/Archives/Public/public-whatwg-archive/2010Mar/thread.html#msg144
> for an old use case thread that went nowhere. Or
> http://lists.w3.org/Archives/Public/public-whatwg-archive/2011Feb/thread.html#msg274
> where you requested general DOM access which cannot be implemented
> everywhere.

One of the strongest use-cases we have found within mozilla is to
enable compiling applications written in other languages and for other
platforms to the web platform. For example emscripten [1] supports
compiling C/C++/OpenGL programs to javascript + WebGL.

Such programs generally use things like synchronous IO and have their
own event loops, thus not returning to the platform event loop.

So a good strategy for tools like emscripten is to create code which
is intended to run in a worker. That way you don't have to return to
the event loop, and you have access to things like full featured
synchronous XHR (including support for .responseType) without
degrading the user experience.

However a big problem is that you can't do graphics inside a worker.
It would be great to expose canvas since that is the graphics model
these programs have today.

[1] https://github.com/kripken/emscripten

/ Jonas

Received on Monday, 14 May 2012 21:16:00 UTC