r-wasm / webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.
https://docs.r-wasm.org/webr/latest/
Other
865 stars 68 forks source link

Running from p5.js #176

Closed ries9112 closed 1 year ago

ries9112 commented 1 year ago

Hello, I am trying to use webR from p5.js and I can't quite get it to work. Would anyone know how to get things working here? https://editor.p5js.org/ries9112/sketches/gBvkHLIUq

georgestagg commented 1 year ago

I've taken a look and it looks like the p5js website is not served Cross Origin Isolated, so the default communication channel used by webR cannot be used in that environment.

Additionally, it looks like p5js works by taking your scripts (HTML & JS) and turning them into Blob URL objects. It is my understanding that service worker scripts cannot be loaded from a Blob object, and so the alternative service worker approach for webR also cannot work in that environment.

For those reasons, I don't think webR can work from inside p5.js with its current technical stack and server setup. Since the situation is not likely to change in the short term, I'm going to close this issue.

If you would still like to experiment with webR in different environments, there is more information in the documentation about the technical requirements for serving pages containing webR at https://docs.r-wasm.org/webr/latest/serving.html.