posit-dev / shinylive

Run Shiny on Python and R (compiled to wasm) in the browser
https://shinylive.io/py/examples/
MIT License
195 stars 15 forks source link

Plotly fails to initialize upon app start #116

Open valentin-kamm opened 6 months ago

valentin-kamm commented 6 months ago

I have written a Shiny App that will render two plotlyOutputs when it is started. I'm hosting this app as a shinylive app on a Microsoft Internet Information Services webserver. When visiting the website, only the second plot is actually rendered correctly, the first plot fails with the following error message in the browser console:

Uncaught (in promise) ReferenceError: Plotly is not defined at Object.renderValue (plotly.js:162:18) at htmlwidgets.js:539:22

As soon as I modify the first plot, i.e. using some control widgets to filter the underlying data causing the plot to re-render, everything works fine.

Furthermore, everything works fine when I run the shiny app locally using RStudio, which leads me to believe that the issue might be caused by shinylive.

Edit: Here is a simple demo app showing the problem: https://valentin-kamm.github.io/shinylivePlotlyIssueDemo/

Luke-Symes-Tsy commented 2 months ago

I have the same issue, which I logged here as I thought it might be related to webR: https://github.com/r-wasm/webr/issues/330