-
-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] Support simple dynamic runtime without shiny #2232
Comments
Hi, Can you share a reproducible example of what you mean by dynamic runtime without shiny ? I am not quite sure to follow what you tried. htmlwidgets can often be used inside plain HTML documents without a shiny backend. It is most often JS and CSS. when self contained, everything is embeded but when not self contained, the resources will need to be loaded when served. You can have CORS error in your browser depending on how you serve maybe. Are you opening the document as a file in the browser ? or are you deploying to a server ? Or maybe serve the document locally ? When does the CORS error happens. That is just rough hints on what I have understand. Please precise dynamic runtime without shiny to that I can give a more precise answer. Sorry if I misunderstood. Thanks! |
Please use the following script to install install.packages("threeBrain")
threeBrain::download_N27()
threeBrain::merge_brain() In your rmd file, copy-paste the following code: brain <- threeBrain::merge_brain()
plot(brain) In the rendered html, open console, and you will see CORS error. Remark: the CORS error exists no matter the requested file exists or not. Just want to provide a simple example here. ReasonThe widget used to work fine in static mode. However, since the security fix, most browsers now treat requests to local files with different paths (even sub-directory) as CORS. This patch breaks static htmlwidgets whose What's the problem (not really) with shinyrmd runtime?In My naive proposalRender the rmd in static mode, but host a simple server (without shiny) to show the html later. I guess this wouldn't change any existing code. Although I also request changes in |
Thanks for the clearer example. CORS can indeed be an issue with some tools when the html file is not properly served. Requests are made to
Do you mean using a local web server ? Does it solves the issue ? I don't see any CORS using this method but it seems that threeBrain writes the JSON file in some place not found by the resulting Rmd file. 🤔 |
Seems like threebrain looks for the file in So I believe there is some wrong interaction with the tools maybe currently |
Whether the file exists doesn't matter as I have corrected the path but still files cannot be loaded. The issue is for static files, web browsers won't even try to load local files if not in the same path (not even child path).
Yes. That's exactly what I was thinking about, a local server without shiny.
That's right, I'm doing that right now. However, it would be better if we could just click the Here's the result of using |
That is a lot clearer now !
It matters because I can't reproduce the issue on my end using the CRAN version of the
So this would be a feature request in the RStudio IDE so that knitting the file using the button will rneder using Currently, the way you are doing it is the right way to do it.
Maybe a helper function could be made to do this in a single step. Some in servr package tries to do this. Maybe something with the Job API in RStudio IDE could be useful. Anyway, the limitations of Viewer rendering in RStudio IDE after Thanks for opening this issue! |
A lesson learnt. Sorry for the inconvenience, and thanks for explaining to me.
Yes I've filed a feature request in the RStudio IDE. What I'm curious about is how Another question is if |
They use shiny R package to serve the website. At some point it will call
When there is Unless I am still missing something about what "dynamic" mode (or document) means from you... |
Gotcha. Thanks! |
Issue has been open in rstudio/rstudio#9977 I'll close this one here and we'll follow there. Thanks! |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Current
rmarkdown::render
function supports 4 runtime optionsWhen I was trying to embed some htmlwidgets with no
self_contained
(large datasets: ~200MB 3D mesh files) understatic
runtime, the browser gives me CORS error.So I tried to run the document with
shinyrmd
andshiny_prerendered
, the browser gave me JavaScript errors (basically JS objectShiny
was not working as expected). The reason why this happened was becausehtmlwidgets
allowed the widgets to have different behaviors with/without shiny. When the widgets detected shiny, they tried to call shiny input update functions, but sinceshiny
behaved different than the normal dashboard mode, JS error was raised.Would it be possible to have dynamic runtime, but without shiny?
[PS]: I also tried
shiny
runtime out of curiosity, but got C Stack error.The text was updated successfully, but these errors were encountered: