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

"WebGL is not supported" after switching from Electron Forge React #220

Closed
4 tasks done
sebastianvitterso opened this issue Jul 19, 2023 · 1 comment
Closed
4 tasks done
Labels
bug Something isn't working

Comments

@sebastianvitterso
Copy link

sebastianvitterso commented Jul 19, 2023

Describe the bug

I'm currently in the process of transitioning from the template from Electron Forge, React with Typescript, to using Electron Vite, as I've grown to like Vite better than Webpack.

A lot of config has been changed, but now it works - with one notable exception:

In my project, we use plotly.js (and therefore also react-plotly.js), which uses webgl under the hood. That worked perfectly before I made the switch, but for some reason, it now just shows me the blue message WebGL is not supported by your browser - visit https://get.webgl.org for mor info above the empty plot.

image

I have opened the url in the electron application, using location = 'https://get.webgl.org', and it works there, so I know the warning isn't shown because the webgl-api is unavailable.

I've also tested the following in the console, which seems to show that the webgl api exists and works as expected.
image

The message is created by plotly.js (source), but I can't seem to see what has changed, causing it to show this message.

Electron-Vite Version

1.0.25

Electron Version

24.6.2

Vite Version

4.4.2

Plotly Versions

// package.json
"@types/plotly.js": "^2.12.24",
"@types/react-plotly.js": "^2.6.0",
"plotly.js": "^2.24.3",
"react-plotly.js": "^2.6.0",

Validations

@sebastianvitterso sebastianvitterso added the bug Something isn't working label Jul 19, 2023
@sebastianvitterso
Copy link
Author

Turns out, electron-vite wasn't the issue. My CSP was changed from "allow anything" to an explicit whitelisting, and for some reason plotly.js (the default version) used unsafe evals to initialize, so without a CSP containing script-src 'self' 'unsafe-eval';, it wasn't possible to run it. I remedied the problem by instead using plotly.js-strict-dist-min, as recommended here

This is the post that got me on the right track, btw.

@sebastianvitterso sebastianvitterso closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2023
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

1 participant