Re: [css-houdini-drafts] [css-animationworklet] Allow sending data to animators in worklet from main thread (#869)

An alternative approach is is support `postMessage`  on  `WorkletAnimation`. [AudioWorklet](https://developers.google.com/web/updates/2017/12/audio-worklet?#bi-directional_communication_with_messageport) has taken this approach.

Using postMessage has a few advantages:

- Well known semantic and API
- Support transfers in addition to sending copies
- Can be used as a bi-directional channel i.e., send data from worklet to main

There are however several concern with using postMessage:
1. Its semantic may require that we always keep the animator instance alive so that it can receive the message. (Our current implementation in Chrome currently keeps animator instances alive but spec allows animator instances to be torn down at any time). 

2. We want to ensure that the data sent by main thread is processed before the next animation frame so that animation can respond to it appropriately. Not clear if this is possible with postMessage.

-- 
GitHub Notification of comment by majido
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/869#issuecomment-477234102 using your GitHub account

Received on Wednesday, 27 March 2019 16:17:45 UTC