Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Undesired Behavior From Throw On Detach After Project Upgrade

Discussion in 'XR Interaction Toolkit and Input' started by hunter_unity368, Jul 5, 2022.

  1. hunter_unity368

    hunter_unity368

    Joined:
    Oct 6, 2021
    Posts:
    6
    Over the past month or so we have begun to have a surprising issue occur in our Quest 2 project. We suddenly noticed that - only in builds - occasionally when holding an object and releasing it it could fire off with a massive speed out of your hand in a seemingly random direction. This could happen when picking up the object and releasing it stationary, throwing it, etc. So in short, any time you release the object there is a chance it will fire off a mach 10.

    At first, we assumed this was some kind of issue with our code and we begun to disable systems one by one until we were using the original XR Toolkit components with no additional functionality on any of the objects, just interactors & interactables in a purely sterile scene. Unfortunately, the problem still persisted. This prompted us to ensure all packages were up to date and so forth, yet still the same outcome.

    After all that testing we decided to go back through our commits one by one and find where the problem seemingly started and two different builds a week apart where one worked fine and the other didn't. Diff checking the two commits showed only one change and that was upgrading the project from 2020 LTS to 2021 LTS to access some necessary features for our project.

    From here I did the following:
    1. Built the project under 2020.3.23f1 LTS (2020 Build)
    2. Upgraded the project
    3. Built the project under 2021.3.5f1 LTS (2021 Build)

    After running 2020 Build there was no issue after thorough testing, so then I ran 2021 Build and the issue happened nearly immediately after grabbing and releasing an object.

    This was the exact same build with only that difference. I am very surprised to see this problem and that no one else seems to be having it.

    Our project is on a very tight schedule and we have multiple demonstrations coming up, this bug can cause many large issues. So if anyone has had this issue or can provide potential solutions I would be very grateful.
     
    BV0176 and jjmontes like this.
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    220
    Can you try deleting the output build folder and the
    Library
    folder from your project and try building again with 2021? It's possible that there may be a bug with the upgrade where there's leftover files from 2020 that is conflicting with the newer version since you said you are not seeing it in the Editor but only in standalone builds.

    I tried to reproduce the issue you are seeing by upgrading a project from 2020.3.23f1 to 2021.3.5f1 but could not reproduce the problem. Are you building for the Windows, Mac, and Linux platform or Android? Is your Scripting Backend project setting Mono or IL2CPP?

    If you are able to upload your project using Help > Report a Bug we may be able to identify any issues specific to your project configuration.

    Something to note is that XR Grab Interactable does not currently ignore collisions with the player object when you pick it up, so if you are using a Character Controller or some other kind of Collider on your XR Origin hierarchy, the interactable may be overlapping with a Collider and it could move to resolve that collision when you release it. Could that issue be related to the unwanted behavior you are seeing where it shoots off in some random direction?
     
  3. hunter_unity368

    hunter_unity368

    Joined:
    Oct 6, 2021
    Posts:
    6
    Thank you for the assistance!

    I just tested deleting the Library folder and building again in 2021, however the issue is still present.

    We are building for Android as an APK to run on the Quest 2, and our Scripting Backend is currently Mono.

    I was thinking this might be the case, however after disabling all additional colliders except for the trigger required to use the Direct Interactor and the one on the target Interactable I still had the same issue. Additionally, things worked on an unchanged project when using 2020.3.23f1 but didn't on the 2021.3.5f1 project. Not that that could have been the issue though.

    Due to the project being an unannounced game with large stakeholders there's some worry over submitting the project with the Report a Bug dialogue. I understand that that would by far be the most optimal way of getting this resolved, however. What is the degree of confidentiality with the submission? Preferably, is there a document or web page I could use to discuss with the project managers about this. Worst case is that I will branch and try to cut everything out of the project that is not imperative to the problem, but I worry that that could alter the state of things and perhaps just obscure the bug.
     
  4. hunter_unity368

    hunter_unity368

    Joined:
    Oct 6, 2021
    Posts:
    6
    Due to how pressing the issue has become, I have taken the time to cut down our project to deliver as quickly as possible with test scenes and so forth to display the bug.

    I have used the Help > Report a Bug functionality and submitted it as "XR Toolkit Undesired Behavior From Throw On Detach After Project Upgrade". Please let me know if there is more I can do at this time.
     
  5. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    220
    Unfortunately I don't have access to the bug report project until the triage team transfers it to our board, and they are all out on holiday today, so I won't be able to hear back until tomorrow.

    Do you have the bug number, usually in the format IN-####, so I can expedite getting it transferred when they become available?
     
  6. hunter_unity368

    hunter_unity368

    Joined:
    Oct 6, 2021
    Posts:
    6
    Understood, the bug number is IN-9419. Please let me know if there is anything more I can do to help! I appreciate you looking into this.
     
  7. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    220
    I was able to reproduce the problem with the project you submitted with the bug report. It seems that for the times when the object launches away, it happens after there is a frame that has an unexpectedly low
    Time.deltaTime
    . For a 72 Hz device, it should be somewhere around 0.01388 seconds, but every now and then I'm seeing a value of
    Time.deltaTime = 1E-05
    , which completely skews the captured velocity that is used when computing and setting the Rigidbody's velocity in
    XRGrabInteractable.Detach
    . I was able to get the error to occur more frequently when I rotated my head around while tossing the object up repeatedly.

    Until we can release a new version of the XR Interaction Toolkit where those outliers can be ignored, I recommend you update your
    XRGrabInteractableExtended
    class to override the
    Detach
    method and after calling the base method, scale the Rigidbody's
    velocity
    and
    angularVelocity
    values to lower values if those magnitudes are high. The computed velocities for each frame in the 20 frame window used in the
    XRGrabInteractable
    is unfortunately private, so you won't be able to filter it yourself, you'll just have to adjust the final result in
    Detach
    . You may want to monitor for unexpectedly low
    Time.deltaTime
    values to hint that you'll want to zero out or clamp the velocities.

    I'll ask the team if there are any known issues with the frame times being odd on the Quest 2 and if there are any settings that impact those outlier delta times.
     
    BV0176, jjmontes and hunter_unity368 like this.
  8. hunter_unity368

    hunter_unity368

    Joined:
    Oct 6, 2021
    Posts:
    6
    I'm relieved to hear that you were able to replicate the bug and more or less find a source.

    Thank you very much for the update on this, it will be slightly frustrating to have the object's throwing physics suddenly act unexpectedly, but having it just go a little farther/shorter than expected or fall straight down is certainly better than them going out of bounds.

    However, I think in the meantime that should be able to hold us over until a new version of XR Interaction Toolkit is released.

    Please let me know if anyone is able to inform you of any frame time issues on the Quest 2 or perhaps anything else that could potentially help resolve the issue fully.