Skip to content
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

Assertion error in Safari, unless the Web Inspector is open #189

Open
WillemSleegers opened this issue Apr 4, 2023 · 15 comments
Open

Assertion error in Safari, unless the Web Inspector is open #189

WillemSleegers opened this issue Apr 4, 2023 · 15 comments
Labels
bug Something isn't working

Comments

@WillemSleegers
Copy link

I'm having a weird bug that WebR produces an assertion error in Safari but not if I open the Web Inspector. If I have the inspector open, refresh the page, it all works fine. It also works fine in Chrome. Any clues as to what may cause an error like this?

A screenshot of the error message:
Screenshot 2023-04-04 at 23 29 13

A link to the hosted page:
https://642c95d6d914dd11c91843b1--webr-template.netlify.app

Link to the code:
https://github.com/WillemSleegers/webr-template

@georgestagg
Copy link
Member

Interesting! No, I have not seen that error before. I think I will need to reproduce so as to learn more.

Your demo website seems to be working for me OK now, running in Safari 16.3 and Safari Tech Preview 16.4. Did you change something? If not, which version of Safari are you currently running?

@hrbrmstr
Copy link

hrbrmstr commented Apr 6, 2023 via email

@WillemSleegers
Copy link
Author

Odd! It's working fine for me now as well. Feel free to close the issue and I'll be back in case it pops up again.

@WillemSleegers
Copy link
Author

Coincidentally, I just started it up and I have the problem again. Same Netlify link.

Running Safari Version 16.4 (18615.1.26.11.23 and Ventura 13.3.1 (22E261).

@georgestagg georgestagg reopened this Apr 11, 2023
@georgestagg
Copy link
Member

Still no assertion error here, but I've reopened so we can track this.

@WillemSleegers
Copy link
Author

Thanks.

I just tried it on the most recent version of Safari Technology Preview, but same issue. No issue on my iPad though.

@WillemSleegers
Copy link
Author

I have since taken down the website where I had the issue. I've been messing around with another example and I ran into the same issue.

Hosted page: https://main--unrivaled-cranachan-f0332f.netlify.app
GitHub rep: https://github.com/WillemSleegers/webr-nextjs-example

@WillemSleegers
Copy link
Author

I should perhaps mention that I also get the following error message:
image

Despite the error message, the code runs after opening the Web Inspector and in Chrome I have no issues, so it appears to be something Safari specific.

@hypebright
Copy link

@WillemSleegers might be worth another try. I had the same issue on Safari 16.5.2 (18615.2.9.11.10), but since today I don't get the error anymore

@georgestagg georgestagg added the bug Something isn't working label Jul 26, 2023
@georgestagg
Copy link
Member

I have a hunch that this is related to CloudFront caching of webr.r-wasm.org and mismatched versions of the webR TypeScript library and the R.bin.wasm WebAssembly binary being used together, but I have no real evidence.

That would explain the transient nature, if it is the case then the problems would go away once CloudFront's caches are all back in sync with the backing storage.

I guess the right thing to do would be to tweak our CI scripts to force a cache invalidation on webr.r-wasm.org/latest whenever a new commit is pushed to main and deployed. This would be something useful to have in any case.

@baogorek
Copy link

Any updates on this? I have a single HTML file that runs fine in Chrome and Edge, but I'm getting messages similar to @WillemSleegers in Safari.
image

My webR code starts like this:

  <script type="module">
    import('https://webr.r-wasm.org/latest/webr.mjs').then(async ({ WebR }) => {
      const webR = new WebR();
      await webR.init();

@WillemSleegers
Copy link
Author

Yeah I also still get those messages. Would be nice to resolve that.

@georgestagg
Copy link
Member

The Not allowed [...] /web-worker.js.map and Cannot load [...] /web-worker.js.map messages are related to the browser trying to load debugging information (the .map file) from a source that has been loaded in a particular way to avoid Cross-Origin restrictions. They should be harmless, though I appreciate are an annoyance.


@baogorek Does your code run any computation with webR after init()? Even with those messages in the console log, it should still work. Can you share a full self-contained example of a failing script?

@baogorek
Copy link

@georgestagg , here's an example: https://github.com/baogorek/Miscellaneous/blob/master/R-code/hello-webR.html

I just reallized it halfway works on Safari. On Chrome, you'll see the attached image, although there is a few seconds delay to get the plot. On Safari, you'll see the "Hello, World! x= 12" from the first R code block, but the second part of the block - the plotting portion - failed.
image

So it looks like the problem is related to displaying the image:

      const rCode2 = `
          webr::install("ggplot2")
          library(ggplot2)
          webr::canvas()
          x <- rnorm(100)
          y <- rnorm(100)
          df <- data.frame(x=x, y=y)
          # Plot with axes, points, and labels all in one frame
          p <- ggplot(df, aes(x=x, y=y)) + geom_point()
          print(p)
          dev.off()
      `;

      await webR.evalRVoid(rCode2);

        for (;;) {
          const output = await webR.read();
          switch (output.type) {
            case 'canvas':
              if (output.data.event === 'canvasImage') {
                canvas.getContext('2d').drawImage(output.data.image, 0, 0);
              } else if (output.data.event === 'canvasNewPage') {
                 console.log("Not doing anything");
              }
              break;
            default:
              console.log(output);
          }
        }

Sorry that it looks like those messages were a red herring, but I guess it did make debugging more challenging. Let me know if you want me to start another issue.

@georgestagg
Copy link
Member

Sorry that it looks like those messages were a red herring, but I guess it did make debugging more challenging.

No worries, I understand.

Let me know if you want me to start another issue.

Yes, that is probably a good idea. When you open the issue please add what version of Safari you see the problems with (Safari -> About Safari in the top menu will tell you). Older versions of Safari didn't support a feature called OffscreenCanvas, which we use for plotting. This is potentially the root cause of the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants