posit-dev/r-shinylive

App fails to start if a PNG/JPEG file exists in the project

Closed this issue · 6 comments

Using latest github version. Steps to reproduce:

  • Create a folder "foo"
  • Place a PNG or JPEG image in the folder
  • Add an "app.R" containing an empty shiny app
  • Run shinylive:::export("foo","site"); httpuv::runStaticServer("site")
  • Get an error "Robj construction for this JS object is not yet supported"
  • The same happens if a PNG is placed inside a directory
  • I have tested with other non-image files and it seems to work fine

@daattali I don't think this is supported yet, I've gotten around this by hosting things like images on remote URLs instead of exporting them with the app. If you look at app.json the entire app is there with its folder structure. If you include something like a csv you'll see the csv is parsed within app.json. So I'm guessing the same process to parse images just isn't supported yet.

If that's true, then instead of failing fatally, maybe {shinylive} should explicitly look if there are any image files, and if there are then give a message to the developer at export() time, saying that any images were not included.

Please can you report the output of shinylive::assets_info()? On my machine, this reports:

shinylive R package version:  0.1.1.9000
shinylive web assets version: 0.3.0

Exporting including binary files such as images should work from shinylive assets v0.3.0 onwards. Installing the latest assets can be done by updating to the latest dev version of shinylive with pak::pak("posit-dev/r-shinylive") and then running shinylive::assets_download().

If you are using v0.3.0 or later of the assets, and still see this issue, please can you post the exact content of app.R and image file(s) for me to take a look at?

I have the same:

> shinylive::assets_info()
shinylive R package version:  0.1.1.9000
shinylive web assets version: 0.3.0

The app.R doesn't seem to matter. I'm using the following:

library(shiny)

ui <- fluidPage(
  "test"
)

server <- function(input, output, session) {

}

shinyApp(ui, server)

If I have any PNG or JPEG in the same folder (I used this one) or in a subdirectory, then I get this error:

image

Interesting, thank you for taking the time to confirm and reporting back!

This does currently work for me, with the app just showing the output "test", so I am unable to reproduce.

Unfortunately, the error message "Robj construction for this JS object is not yet supported" is from webR and is fairly generic. It can essentially be read as: "Something has gone wrong starting the R Shiny app". Improving this output in the UI is on the radar, but for the moment the JS developer tools should say more. Are there any error messages in there?

A few other things to try, particularly if you've used older Shinylive assets in the past:

  • Can you please remove the site directory from your disk entirely, before trying again, in case other assets are not being replaced there.
  • Can you try serving the output on another port, i.e. httpuv::runStaticServer("site", port=7777). Perhaps your browser is caching older assets in its cache or the Shinylive service worker.

Forcing the port does fix it. It seems like only the default port of 7446 fails but any other port is fine, so you're right it was a caching issue. One reason I didn't notice this is because even after retarting my session and restarting the IDE, it kept happening, because I just noticed that 7446 keeps being used as the default port. I'm used to shiny, where the port is randomized on every session, which would not be able to have this issue.