title: Synchronizing a requestAnimationFrame callback with a web worker
body: <p>Conceptually I have a requestAnimationFrame callback that look like this:</p>
  
  <pre><code>render(now) {
      a = A(now); // long running computation
      b = B(now); // another long running computation
      [update DOM using a, b]
      requestAnimationFrame(render)  // re-trigger animation   
  } 
  </code></pre>
  
  <p>I would like to run A() in a web worker to increase the frame rate.
  Since small inconsistencies in timing are acceptable I would like 
  to convert to something like this which runs all computation of
  A() in a web worker.</p>
  
  <pre><code>render(now) {
      a = [wait for/retrieve previous result for A(now') from web worker]
      [start new computation of A(now) in web worker]
      b = B(now); 
      [update DOM using a, b]
      requestAnimationFrame(render)
  } 
  </code></pre>
  
  <p>My main problem is with the "wait for/retrieve previous result" part.
  Using "await" or similar here causes problems because control can
  go back to the browser before the DOM update has taken place.</p>
  
  <p>I am interested in a solution in either Dart or JavaScript.</p>