Hey all,
Thanks creating such a useful library.
I'm noticing some odd behavior when instantiating multiple Canvas objects. Any updates happening in useRender are performed twice as fast when the second canvas is added. Possibly the useRender callbacks are being called once for each renderer regardless of the renderer they should be attached to?
https://codesandbox.io/embed/react-three-fiber-multi-render-test-m3h2q
I've created a codesandbox reproducing the issue in it's simplest form. After 5 seconds a second canvas is added and the first cube's rotation speed increases for some reason.
As far as I can tell this issue started somewhere around v2.0.11, seemed to be working alright before that.
Thanks for all the help
Dex

Gif for quick reference
that doesn't make any sense, so weird - looks like for some reason it calls the useRender twice. 馃く will have to investigate a bit ...
Clearing the subscribers when creating the initial canvas state seems to fix the issue. I'm not familiar enough with the code to know if that's a good idea but happy to make a PR if it seems like a reasonable approach.
https://github.com/DexterShepherd/react-three-fiber/commit/68ed44b1050cb71337b4c697560cb3d8c04c0634#diff-acdd4dfc96db39da09ff08b9a2fdc0e2
sure, go ahead! :)
tho isn't subscribers:[] part of defaultRef already?
I don't think the object spread operator performs a deep clone, so all objects that spread defaultRef would point to the same copy of subscribers.

oh my ... you're right, that was a terrible oversight. the problem goes even deeper now, because it mutates that defaultRef, camera, scene and all. It's a wonder it's kind of working.
It should be fixed, but i had to fix the other parts as well (scene, cam, raycaster, etc) which all were equally affected, not just subscriber.
Awesome thanks for getting to this so quickly :)
I was wondering why my game sped up after a hot reload, I wonder if this is why, I'll try bumping versions
Most helpful comment
that doesn't make any sense, so weird - looks like for some reason it calls the useRender twice. 馃く will have to investigate a bit ...