-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
@react-spring/three useSpring stops updating in XR session #1518
Comments
How do you 'start a VR session' without a VR Kit? 😕 |
I'm afraid you don't. Maybe this issue is better handled in https://github.com/pmndrs/react-xr? (Side note, if you are interested, consider getting a https://www.oculus.com/quest-2/ - they are really cheap and great for WebXR) |
Side note: a friend has one I was supposed to borrow a while back! annoying I never got it. I'm really sorry, I simply can't help actually look into this issue. I would be surprised if this were an issue with You could open an issue in |
There are various WebXR polyfills and browser extensions that you can use to test this behavior. A notable restriction of a session would be the lack of browser APIs (see I don't mind taking a look as well and/or verifying behaviors if that helps, but the soonest I'll be able to pickup a headset will be late Thursday (US central). |
Thanks for your input @CodyJasonBennett. I tried the browser extension emulator and it does not show the issue, unfortunately. I agree that it must have something to do with the animation loop, however, what is weird is that in my test I subscribe to r3f I have been trying to pinpoint where the issue started to happen as I used this for project earlier this year. This is the exact combination of library version I used back then and the spring is working in VR: The version before this, however, did not work in VR: Could this mean that the only reason it ever worked in 9.0.0-rc3 is because of the double frame loop bug? And this was fixed in 9.0.0 and later. In any case, it's not working in all the latest versions and that is what counts 🤷 I should mention I have only tried this on an Oculus Quest 2 so far, as I'm not in the office this week. |
IIRC, we let r3f drive the render loop for animation in spring, it could be something to do with that.... 🤔 |
I ran into the same issue for my WebXR game on my Quest 2. I don't seem to be having the problem om my valve index, using steamVR and chrome I've recorded a video with both my valve index and my oculus quest 2. As you can see, the buttons on my valve index have a hover effect and the level loads in as expected, but when doing the same thing on my quest the useSpring effects do not seem to start. When I quit the application and reopen the WebXR experience again, the state has been updated and is showing the I recently migrated to all newest versions and noticed the issue. I've updated your codesandbox with the packages I was using before and can confirm that these versions do work in the oculus browser:
I did not have to change the react-xr version because that did not seem to cause the issue.
Would be super weird that we both used the same version, got it to work, and stuck with it @ffdead 😃 I also wasn't able to get it working in other versions. If you need me to test something on oculus / valve index; let me know! |
Great that you were able to replicate it! Sounds like the issue could be with the Oculus Quest 2 browser in that case which is super weird since R3F and XR seems to work fine in general.
Yes, it's a bit weird. I've also mostly been using HTC Vive / Oculus Rift S in the past which makes it even more baffling that I just happened to pick the exact versions that also worked on Oculus Quest 🤯 @joshuaellis do you know if @react-spring/three only relies on the r3f |
I spent a few hours remote debugging my Oculus Quest 2 browser. This is what I could see: No active XR session
In active XR session
I'm not familiar with the internals of react-spring so I'm not sure what that means. I was a bit surprised to see separate frame loop logic for each target tbh. And I'm not sure I understand where the shared FrameLoop gets called from the three FrameLoop. Hope this helps nail down the issue. I will wait for someone who actually knows the internals of react-spring to comment 😅 |
Yeah when we released v9 there was some form of issue with three frame looping that we monkey patched with the old FrameLoop system... SpringValue.advance is triggered by the render loop. So what we're identifying is an issue in I think what we should focus on first is getting |
Also, great investigation so far! ⭐ |
Ok, here's what I think is going on: The main issue
Temporary workaroundMy temporary workaround is to monkey patch the three target to run // YourApp.js
import { addEffect } from '@react-three/fiber'
import { Globals } from '@react-spring/shared'
let nextFrame: Function | undefined = undefined
addEffect(() => {
if (nextFrame) nextFrame()
return true
})
Globals.assign({
requestAnimationFrame: (cb) => (nextFrame = cb)
}) Problems with the workaround
Conclusions
This feels like fundamental change so I suspect a core maintainer would be better suited to make the necessary changes. |
Thanks for the research! It's very helpful ⭐ it's also not easy to resolve (but when is it?). So it feels like step1 is getting everything to use a set global AnimationLoop function e.g in the context of web this would be |
Cool, so after some digging this weekend, it turns out that I then looked at the code for Edit: I want to say a real thank you to @ffdead, great research helped isolate the issue and wrote up incredibly clearly so I could think about how to solve it 🙌🏼 |
…1551) * chore: depreciate three-v5 * chore: add three-demo * feat: move rafz to part of monorepo * fix: use new rafz property to let r3f drive animation frames resolves #1518 * chore: delete travis * test: import from @react-spring/rafz * fix: update all values of animated array (#1430) (#1550) Co-authored-by: Michael Hutchings <michael.hutchings@cambridgeconsultants.com> * chore: update lock * fix: typescript errors * fix: allow declare Co-authored-by: Michael Hutchings <33626784+midanosi@users.noreply.github.com> Co-authored-by: Michael Hutchings <michael.hutchings@cambridgeconsultants.com>
this has been released on v9.2.2 in theory it should all be working, but we can reopen if it's not 🙏🏼 |
I just tried it out and it seems to run great inside XR on the Oculus Quest. Awesome job, big thanks! |
🐛 Bug Report
Springs stop updating when starting an active XR session.
Not sure if this a bug related to @react-spring/three, @react-three/fiber, @react-three/xr or a combination of all three.
To Reproduce
Expected behavior
The mesh should continue to animate scale inside the XR session.
Link to repro (highly encouraged)
https://codesandbox.io/s/react-xr-react-spring-bug-fkzt3?file=/src/index.tsx
Environment
@react-spring/three
>= v9.0.0@react-three/fiber
>= v6.0.3@react-three/xr
>= v2.1.0react
v17.xWorks as expected with the following old versions:
@react-spring/three
v9.0.0-rc.3react-three-fiber
v5.x.x@react-three/xr
v2.0.1The text was updated successfully, but these errors were encountered: