Bug 47616

Summary: Support typed arrays in workers
Product: WebKit Reporter: Jian Li <jianli>
Component: WebCore JavaScriptAssignee: Jian Li <jianli>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ap, eric, levin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
Proposed Patch
jianli: commit-queue-
Proposed Patch
jianli: commit-queue-
Proposed Patch levin: review+, jianli: commit-queue-

Description Jian Li 2010-10-13 13:28:55 PDT
Since ArrayBuffer will be used in FileReader/FileReaderSync, we need to support adding typed arrays in workers. This involves:
1) Exposing constructors in WorkerContext.
2) Adding NoStaticTables attributes.
Comment 1 Jian Li 2010-10-13 13:55:49 PDT
Created attachment 70656 [details]
Proposed Patch
Comment 2 Eric Seidel (no email) 2010-10-13 14:25:58 PDT
Attachment 70656 [details] did not build on mac:
Build output: http://queues.webkit.org/results/4393008
Comment 3 Jian Li 2010-10-13 15:22:50 PDT
Created attachment 70671 [details]
Proposed Patch

Fixed mac build error.
Comment 4 Eric Seidel (no email) 2010-10-13 15:50:10 PDT
Attachment 70671 [details] did not build on mac:
Build output: http://queues.webkit.org/results/4466012
Comment 5 Jian Li 2010-10-13 16:03:44 PDT
Created attachment 70678 [details]
Proposed Patch
Comment 6 David Levin 2010-10-13 22:52:32 PDT
Comment on attachment 70678 [details]
Proposed Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=70678&action=review

Consider removing the 3D_CANVAS in the Conditional in workers.

Also I see that the attributes are already out of sort order, but I think we can keep them mostly sorted with the moves that I suggested.

> WebCore/html/canvas/ArrayBuffer.idl:33
> +        NoStaticTables

I'd move NoStaticTables to be sorted.

Following the general idea: If ordering doesn't matter, sort.

> WebCore/html/canvas/ArrayBufferView.idl:27
> +    interface [Conditional=3D_CANVAS|BLOB, CustomToJS, OmitConstructor, NoStaticTables] ArrayBufferView {

Consider moving before OmitConstructor.

> WebCore/html/canvas/Float32Array.idl:33
> +        NoStaticTables,

After Generate...

> WebCore/workers/WorkerContext.idl:117
> +        attribute [Conditional=3D_CANVAS|BLOB,EnabledAtRuntime] ArrayBufferConstructor ArrayBuffer; // Usable with new operator

Why are we exposing these in Workers when 3d canvas is enabled?
Comment 7 Alexey Proskuryakov 2010-10-14 10:57:21 PDT
> need to support adding typed arrays in workers. This involves:
> 1) Exposing constructors in WorkerContext.
> 2) Adding NoStaticTables attributes.

A general comment: exposing any feature in workers involves making sure that its implementation is thread safe. This is by far the most important and complicated step.

Watching the bugs, I'm not convinced that such analysis is being performed for each feature that's being added to workers.
Comment 8 Jian Li 2010-10-14 11:05:23 PDT
(In reply to comment #7)
> > need to support adding typed arrays in workers. This involves:
> > 1) Exposing constructors in WorkerContext.
> > 2) Adding NoStaticTables attributes.
> 
> A general comment: exposing any feature in workers involves making sure that its implementation is thread safe. This is by far the most important and complicated step.
> 
> Watching the bugs, I'm not convinced that such analysis is being performed for each feature that's being added to workers.

Thanks a lot for reminding. We're not supporting passing type array objects between main thread and worker thread. We only allow them to be constructed and used in one single thread. I've checked the implementations and it seems to be fine for sole use in single thread. Anything else I need to analyze?
Comment 9 Alexey Proskuryakov 2010-10-14 11:24:16 PDT
Yes, I also didn't spot anything suspicious in the implementation. Unlike a lot of WebCore code, it's not using any static data.
Comment 10 Jian Li 2010-10-14 12:07:26 PDT
Fixed as suggested and committed as http://trac.webkit.org/changeset/69782.
Comment 11 David Levin 2010-10-14 14:05:59 PDT
(In reply to comment #7)
> A general comment: exposing any feature in workers involves making sure that its implementation is thread safe. This is by far the most important and complicated step.
> 
> Watching the bugs, I'm not convinced that such analysis is being performed for each feature that's being added to workers.

Thanks for the reminder Alexey!

I've been trying to watch that (but in honestly for this one in particular I didn't look at closely as I should have at all of the under lying implementation until your reminder -- even thought it turned out alright).

I'll make a special note each time I review one of them that I did this, so anyone scanning reviews can see what outside of the sparse comments was done.