Plotly graph not displaying in Shiny when running app first time, but show up subsequently


I am having difficulty getting plotly graphs to show up in Shiny. What I have noticed is that the plots do not show up the first time I run the app, but then show up subsequently. I used the following example as an illustration:

I had installed the CRAN version of Plotly, but I uninstalled it, and installed the latest devtools version instead (plotly_4.9.0.9000).

My session info is:

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] plotly_4.9.0.9000 ggplot2_3.1.1 shiny_1.3.2

loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 pillar_1.3.1 compiler_3.5.3 later_0.8.0 plyr_1.8.4 tools_3.5.3
[7] digest_0.6.19 viridisLite_0.3.0 jsonlite_1.6 tibble_2.1.1 gtable_0.3.0 pkgconfig_2.0.2
[13] rlang_0.4.0 rstudioapi_0.10 crosstalk_1.0.0 yaml_2.2.0 withr_2.1.2 dplyr_0.8.1
[19] httr_1.4.0 htmlwidgets_1.3 grid_3.5.3 tidyselect_0.2.5 glue_1.3.1 data.table_1.12.2
[25] R6_2.4.0 tidyr_0.8.3 purrr_0.3.2 magrittr_1.5 scales_1.0.0 promises_1.0.1
[31] htmltools_0.3.6 assertthat_0.2.1 mime_0.6 xtable_1.8-4 colorspace_1.4-1 httpuv_1.5.1
[37] labeling_0.3 lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4

I faced the exact same issue. I used a workaround.
I was earlier launching the app from cmd prompt: rscript.exe tool.R
I, now, changed it to 2 steps. I created a run.R which had the following command:


I, then, launched it like this: rscript.exe run.R
It works now