"Using web workers" needs code improvements

NEW
Unassigned

Status

4 years ago
11 months ago

People

(Reporter: Harald, Unassigned)

Tracking

Details

(Reporter)

Description

4 years ago
https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers#Passing_data

That convoluted unit test snippet can be simplified. Also the types are similar to JSON, why is it important to go into so much detail on the types that can be provided.

Another pain point is the various examples asyncEval, which is a bad use case for Web Workers (eval!) but which is the first extensive example. A nice example would be some expensive algorithm on a worker. Another good one is getting pixel data from canvas, transferring the typed array and doing some things with the colors.
Since this bug was filed, the article has been corrected and completed.

Harald, can you review: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Passing_data_examples

and see if it is better now?
Flags: needinfo?(hkirschner)
(Reporter)

Comment 2

3 years ago
Example #1 might need a line of why and where this would be useful.

Example #2 is still very complex and I am not sure how far it illustrates data passing vs whatever else it does.

Other ideas for examples: Physics simulation, decompression (https://github.com/ukyo/zlib-asm), crypto
Flags: needinfo?(hkirschner)
ni/ myself to be sure this stays on my radar
Flags: needinfo?(jypenator)
Flags: needinfo?(jypenator)
Assignee: jypenator → nobody
You need to log in before you can comment on or make changes to this bug.