-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Bug] WebGL context already attached to device webgl-device-1 #9379
Comments
Are you using StrictMode? |
@Pessimistress yes.. but the error didn't happen until 9.1.0 |
Yes, just trying to understand the cause. @ibgreen in StrictMode context is initiated-finalized-initiated again on the same canvas. |
The same problem . Strict mode has no effect on anything ( Downgrade to v9.0.40 helped me |
I could imagine that the following fix could help, but what I am not so sure about is why it wasn't a problem in 9.0. Perhaps the Device class has undergone more changes than I remember. I suppose someone who can repro this could try the fix quickly by adding the one line to webgl-device.js in your local luma.gl file in nodule_modules. |
@ibgreen No, that does not fix the bug. The first In v9.0 You can reproduce this by modifying the get-started example: - createRoot(container).render(<Root />);
+ createRoot(container).render(<React.StrictMode><Root /></React.StrictMode>); |
Yes,
If it is really so important not to attach WebGL context to a previously used Or maybe, just maybe, make it a lot easier diff a/react/src/deckgl.ts b/react/src/deckgl.ts
@@ -183,15 +183,20 @@
useEffect(() => {
+ const timer = setTimeout(() => {
const DeckClass = props.Deck || Deck;
thisRef.deck = createDeckInstance(thisRef, DeckClass, {
...deckProps,
parent: containerRef.current,
canvas: canvasRef.current
});
+ }, 0);
- return () => thisRef.deck?.finalize();
+ return () => {
+ clearTimeout(timer);
+ thisRef.deck?.finalize();
+ };
}, []); pros - do not create an instance unnecessarily (dev+StrictMode only, but still) |
Thanks for the good input everyone. I updated the PR. I'm adding a new experimental option
I see what you mean,
In one sense is not so important, in that this feature mainly exists to support deck.gl's usage.
|
Hi,
Is this error related to this thread? |
Description
After upgrading to version 9.1.0 deck crashes with an error
I use it with the react component -
<DeckGL />
from@deck.gl/react
Flavors
Expected Behavior
No crash
Steps to Reproduce
https://stackblitz.com/edit/vitejs-vite-ecrh7kpz?file=src%2FApp.tsx
Environment
Logs
The text was updated successfully, but these errors were encountered: