[whatwg] Canvas in workers

Robert O'Callahan robert at ocallahan.org
Sun Oct 13 16:27:09 PDT 2013


On Sun, Oct 13, 2013 at 6:07 PM, David Bruant <bruant.d at gmail.com> wrote:

> Le 13/10/2013 23:33, Robert O'Callahan a écrit :
>
>
>>
>>                bool commit();
>>
>>     Boolean as return value for success? :-s
>>     A promise instead maybe? throw instead of false at least?
>>     In any case, it looks like commit could be a long operation (tell
>>     me if I'm wrong here. Do you have numbers on how long it
>>     takes/would take?), having it async sounds reasonable.
>>
>>
>> "commit" does not need to be async, it doesn't have to block in practice.
>>
> Just so that I better understand how commit works, what happens in this
> case:
>
>    // draw things
>   wc.commit();
>   // draw other things
>   wc.commit();


Two frames get queued as eligible for presentation. Which ones reach the
screen is unspecified of course.


>  Personally I don't see this as a violation of run-to-completion
>> semantics. The important thing is that the dimensions of the WorkerCanvas
>> (and any other state observable by the worker) do not change except during
>> the call to commit(). Effectively commit() itself performs the change.
>>
> Hmm... Interesting point of view...
> That's the only way to learn that the dimensions have changed? Via
> commit() throwing an error/returning false? It feels very ad-hoc. It
> doesn't seem to scale very well to other reasons why commit() might fail.
>

What other reasons are there?

I also imagine that the normal pattern will be "draw then commit", so it
> means that you always spend efforts drawing without ever knowing if what
> you're drawing is ever going to end up on screen; which feels like a waste
> of resources.


I don't see this as being a problem, or at least no more of a problem than
it already is.


>  Of course it's OK for DOM API implementations to change state :-).
>>
> I don't understand what you mean here.
>

It's OK for calling DOM methods to change state visible to script.

What happens to WorkerCanvas in the canvas element is removed from the
> document or display:hidden-ed?
>

It's unaffected.

Rob
-- 
Jtehsauts  tshaei dS,o n" Wohfy  Mdaon  yhoaus  eanuttehrotraiitny  eovni
le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o  Whhei csha iids  teoa
stiheer :p atroa lsyazye,d  'mYaonu,r  "sGients  uapr,e  tfaokreg iyvoeunr,
'm aotr  atnod  sgaoy ,h o'mGee.t"  uTph eann dt hwea lmka'n?  gBoutt  uIp
waanndt  wyeonut  thoo mken.o w  *
*



More information about the whatwg mailing list