gcalmettes / reveal.js-d3

Full integration of animated javascript-based visualizations (D3, vega-lite, semiotic, etc ...) into Reveal.js presentations
https://gcalmettes.github.io/reveal.js-d3/demo/
MIT License
135 stars 31 forks source link

Fix race condition that can create multiple iframes #11

Closed cscheid closed 6 years ago

cscheid commented 6 years ago

This change fixes a race condition on reveald3 whereas sometimes multiple iframes can get created.

Because the check for the presence of previous iframes was previously done before an await statement, two calls to initialize can happen concurrently, both of them get an empty list, both of them asynchronously await, and both of them create the new iframe. By checking for the presence of the iframe and creating an iframe inside the same synchronous block, we guarantee no race conditions.

gcalmettes commented 6 years ago

Thanks @cscheid!