Search Unity

IsMatrixValid (matrix) error spam when splitting up SteamVR eyes

Discussion in 'AR/VR (XR) Discussion' started by keffertjuh, Aug 12, 2016.

  1. keffertjuh

    keffertjuh

    Joined:
    Oct 14, 2015
    Posts:
    7
    To show a RenderTexture correctly in VR I need to render it separately for each eye.

    In order to achieve this, I followed the steps described here: http://forum.unity3d.com/threads/steamvr-how-to-display-content-in-left-right-eye.396236/ (in comment #6) and subsequently disabled the eye camera in the provided CameraRig prefab, thus succesfully replacing the singular setup for both eyes by one attuned for each.

    The issue I have is that now a nondescript error shows up that just says "IsMatrixValid (matrix)" at what I assume is every (fixed)update, thus spamming my console. (http://puu.sh/qy8cv/08618e393e.png)

    The thing is, everything appears to work fine.
    Anyone got any idea what this is about?

    Notes:
    - Using latest SteamVR off asset store. (https://www.assetstore.unity3d.com/en/#!/content/32647)
    - Some (I assume) Chinese people encountered the same, trying to get an answer at HTC forums, implying that the issue started when SteamVR transitioned to version 1.1.1 (https://www.htcvive.com/cn/forum/chat.php?mod=viewthread&tid=1531)
    - Reimporting doesn't seem to work even though people suggest it does for them (https://steamcommunity.com/app/358720/discussions/0/353915309336222790/)
     
  2. uvartdev

    uvartdev

    Joined:
    Nov 29, 2013
    Posts:
    1
    Getting the same error here when toggling VR on and off or destroying and instantiating a new CameraRig, did anyone ever figure out what exactly causes this problem?
     
  3. keffertjuh

    keffertjuh

    Joined:
    Oct 14, 2015
    Posts:
    7
    As I recall, I went around the net and it seemed it was a known issue people just sort of learned to live with until someone fixes it
     
  4. BlackRainbowFT

    BlackRainbowFT

    Joined:
    Nov 28, 2015
    Posts:
    18
    @uvartdev
    I also encountered the issue a few times where the console would get spammed with IsMatrixValid(matrix).

    To fix this, make sure you're not switching between types of output (target display, target eye, regular camera vs. VR) while VR is enabled.

    In my case, for some stupid reason, I used to set VRSettings.enabled to true after loading a level (in my program the main menu, and choice between VR and monitor, is always done on a regular monitor). Once I enabled VR from the main menu, just before loading a scene in VR, it stopped outputting IsMatrixValid(matrix).

    I'm not an expert, but I think it's the camera trying to send output to something that isn't there anymore...
     
    crash664 likes this.
  5. crash664

    crash664

    Joined:
    Nov 22, 2012
    Posts:
    91
    @BlackRainbowFT you hit the nail on the head with my system! I was also trying to allow the user to switch between different mediums and then re-enabling VR in the proceeding scene. I just enable before shifting scenes now, problem solved :)

    Thank you!!!
     
    aralambomahay likes this.
  6. BlackRainbowFT

    BlackRainbowFT

    Joined:
    Nov 28, 2015
    Posts:
    18
    I'm glad I could be of help!
     
  7. kelloh

    kelloh

    Joined:
    Mar 2, 2015
    Posts:
    29
    I'm not sure how to apply @BlackRainbowFT's fix in my project. I'm never adjusting VRSettings.enabled. On a fresh project with the SteamVR asset and a Left camera and a Right camera, I get the assertion error every frame. Worse, throwing the exception shows up on the profiler :/ Anyone else have any luck with fixing this problem?
     
  8. crash664

    crash664

    Joined:
    Nov 22, 2012
    Posts:
    91
    I would suggest your problem lies in having a left and a right camera. I think the SteamVR camera prefabs only have one camera for the eyes and they, I believe, use the native Unity integration. Hopefully this provides an insight.
     
  9. kelloh

    kelloh

    Joined:
    Mar 2, 2015
    Posts:
    29
    Unfortunately I'm trying to use an anti-aliasing component that requires a left and a right camera, so that's not an option.
     
  10. JDMulti

    JDMulti

    Joined:
    Jan 4, 2012
    Posts:
    384
    The console spamming error: Assertion failed on expression: 'IsMatrixValid(matrix)', is however still present in the most simple VR setup containing a dual camera setup.

    I created a simple VR example to illustrate the issue and reported it.
    Issue number: 899259
     
  11. BlackRainbowFT

    BlackRainbowFT

    Joined:
    Nov 28, 2015
    Posts:
    18
    Yeah, I tried playing around with two cameras and I can't get rid of the error.

    Two cameras aren't needed to reproduce the error, by the way. One is enough: just set its output to either left or right.
     
  12. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    I'm encountering this "IsMatrixValid(matrix)" error. I'm still trying to figure it out but it seems like in my case it's because I'm instantiating the SteamVR camera before setting "VRSettings.enabled = true;". Instantiating the camera after setting it to true seems to make the error go away for me.
     
  13. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    185
    Can you clarify your answer? Have you got left and right cameras?
     
  14. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    Sorry, I barely remember this so I'll try.
    I'm using the default Steam Prefab camerarig, which uses a single camera from what I understand.
    What I'm doing is instantiating different cameras based on whether my app is running with Oculus, Vive or single camera (2D). I think the problem I had was caused by instantiating the SteamVR camera before setting "VRSettings.enabled = true;" in code.

    In the end, I'm still setting it afterwards so that might not be the case afterall. I might've been using an old SteamVR prefab or something. But I'm doing something like this...

    Code (csharp):
    1.  
    2. string[] prioritizedDeviceList = new string[] { "Oculus", "OpenVR", "None" };
    3. VRSettings.LoadDeviceByName(prioritizedDeviceList);
    4.  
    5. StartCoroutine(AutoDelayCheck());
    6.  
    7. ...
    8.  
    9. private IEnumerator AutoDelayCheck()
    10.     {
    11.         yield return new WaitForSeconds(1f);
    12.  
    13.       ...
    14.  
    15.       VRSettings.enabled = true;
    16.  
    17. }
    18.  
    19.  
    I think I waited to allow time for Unity to recgonize the detected device. There's some type of delay, longer than waiting for the end of the frame.
    Keep in mind, this might be wrong. Just something I ended up with that seems to be working good enough.
     
  15. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    We submitted a fix for this issue today. It should land in the next releases of 2017.2, 2017.1 and 5.6 over the coming weeks.
     
  16. xorap

    xorap

    Joined:
    Dec 14, 2017
    Posts:
    1
    Still having this problem in a fresh project/scene with the default rig. Not sure how to change VRsettings.enabled. Current Unity version is 5.6.1f1.
     
  17. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Fix for IsMatrixValid(matrix) shipped in the following versions:

    2018.1.0a1
    2017.3.0b4
    2017.2.0f2

    2017.1.1p3
    5.6.3p4
     
  18. Shovancj

    Shovancj

    Joined:
    Dec 21, 2011
    Posts:
    16
    I instantiate a prefab that has steam cam rig in it that is disabled. then disable the main camera. then enable the steam cam rig in the just instantiated prefab. I still get the IsMatrixValid Error in version 2017.3.0f3.

    Ive also tried unityengine.xr.xrsettings.enable = true before, after, and in between but still see the error.
     
  19. DDeathlonger

    DDeathlonger

    Joined:
    May 9, 2014
    Posts:
    73
    I get this and I DON'T split the eyes.. I use DEFAULT settings, I really don't think this is the cause of the problem...
     
  20. VRRehabInc

    VRRehabInc

    Joined:
    Nov 3, 2016
    Posts:
    5
    Same, I'm trying to update our project from 5.6.1f1 to 2017.3.0f3.
    This appears to be because we are using an orthographic camera to maintain compatibility between desktop and VR versions of our UI. This may cause other problems with our setup. Previously, Unity would simply ignore the orthographic setting in VR.
     
    DDeathlonger likes this.
  21. DDeathlonger

    DDeathlonger

    Joined:
    May 9, 2014
    Posts:
    73
    That sounds like a logical cause. Bump to this reply!
     
  22. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    This is all of a sudden a new error for us as of yesterday when updating out VR project from Unity 5.6.3 to Unity 2017.3. Im not sure how to fix it as we have the one camera in the scene which come with the VRCameraRig. We did nothing different, simply hit play once 2017 import was done and boom - that error plays 100's of times a second.
     
  23. schulzp

    schulzp

    Joined:
    Mar 2, 2018
    Posts:
    1
    Hi, I just ran into this with an additional SteamVRTrackedObject and did some debugging. I'm using SteamVR through the VRTK which has the whole [CameraRig] disabled until it's chosen as the available system. Since the tracked objects live outside the [CameraRig] they are enabled before the essential components below [CameraRig], one of which is the SteamVR Renderer. SteamVRTrackedObject#OnEnable tries to obain an instance of that renderer which at some level causes the assertion to fail.

    So I'd also double check that there are no Steam VR (tracked) objects which get initialized before the VR system.
     
    GENMA_Unity likes this.
  24. solidearthvr

    solidearthvr

    Joined:
    Jan 23, 2017
    Posts:
    50
    I was getting this error with 2017.1.0p4 so I installed the recommended build that has the patch (2017.1.1p3).

    However, I was still getting these errors.

    The problem turned out that the Edit->Player Settings->Virtual Reality SDKs got reversed somehow. For Vive at least, whenever OpenVR is not the first in the list of VR SDKs it causes a problem and in my case a boatload of IsMatrixValid errors.

    Matrix Errors when None is first in the VR SDK List

    2018-05-02_235440.png

    No Matrix Errors when OpenVR is First in the List
    2018-05-02_235458.png
     
  25. XSpitFire

    XSpitFire

    Joined:
    Jan 22, 2018
    Posts:
    15
    I am using 2020.2.6 with a HTC VIVE and had this issue. Solved it by going to Project Settings->XR Plug-in Management->OpenXR and enabling Multi-Pass
     
  26. anniepoulin

    anniepoulin

    Joined:
    Jul 29, 2021
    Posts:
    3
    I'm using 2020.3.26f1 with occulus Rift and I too had that issue. I use both Steam VR and Open VR in my project (R&D). The error got fix by going to: Project Settings->XR Plug-in Management->OpenVR and enabling single-Pass.

    The multi-pass on this setting cause the error in my project.
     
    Alani0 likes this.
  27. KCGames47

    KCGames47

    Joined:
    Nov 3, 2014
    Posts:
    39
    Same this... I had to set it to single-pass to fix the error on 2020.x and 2021.x.... but my game uses a shader that doesn't support single-pass... I'm really tired of using this product :S
     
  28. Yoirgla

    Yoirgla

    Joined:
    Jan 2, 2015
    Posts:
    20
    Hello fellas,

    Just a heads-up for people who have the issue and are looking for a quick and dirty fix :
    Here's my setup that was not working :
    -Unity 2021.3.4f1
    -URP (v12)
    -OpenVR (focus3 via Vive business streaming)
    -Multipass

    My project was workign fine in single pass but some shaders were messed up.

    Here's the fix i did on my project :

    Code (CSharp):
    1. List<XRDisplaySubsystem> displays = new List<XRDisplaySubsystem>();
    2.  
    3.     private void Awake()
    4.     {
    5.         StartXR();
    6.         SteamVR.Initialize();
    7.     }
    8.  
    9.  
    10.     public void StartXR()
    11.     {
    12.  
    13.         XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
    14.         XRGeneralSettings.Instance.Manager.StartSubsystems();
    15.     }
    16.  
    17.     private void Update()
    18.     {
    19.         EnforceStereoTexture();
    20.     }
    21.  
    22.  
    23.     void EnforceStereoTexture()
    24.     {
    25.         displays.Clear();
    26.  
    27.         SubsystemManager.GetInstances(displays);
    28.         foreach (var displaySubsystem in displays)
    29.         {
    30.             if (displaySubsystem.running)
    31.             {
    32.                 displaySubsystem.textureLayout = XRDisplaySubsystem.TextureLayout.SeparateTexture2Ds;
    33.             }
    34. }
    35. }
    36.    
    I hope this will help some of you like it helped me.

    Yoirgl.
     
  29. Simon_RebuffJiang

    Simon_RebuffJiang

    Joined:
    Dec 7, 2022
    Posts:
    1
    Thank you very much!!! This code also solved my problem, I'm using Unity 2021.3.2 and other conditions are the same as yours
     
  30. icormier

    icormier

    Joined:
    Aug 26, 2021
    Posts:
    16
    We happened to have the same issue and you can also directly change the SetupFrame function in XRSystem.cs Packages\com.unity.render-pipelines.universal\Runtime\XR\XRSystem.cs.

    Make sure you commit URP package in order to avoid getting refresh every time you open unity.
    upload_2023-7-13_13-3-35.png
     
  31. Alani0

    Alani0

    Joined:
    Aug 4, 2022
    Posts:
    1
    This solved my issue in 2023 with unity 2021.3.27f1