Search Unity

Bug XRSettings.get_supportedDevices allocate

Discussion in 'VR' started by Max-om, Nov 22, 2022.

  1. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    upload_2022-11-22_17-24-21.png

    Is unity aware? It has been like this for ages.
     
  2. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
  3. ash_at_unity3d

    ash_at_unity3d

    Unity Technologies

    Joined:
    Jan 9, 2020
    Posts:
    41
    Do you know if this has been raised earlier? The intent is to NOT call this on a per frame basis, but to cache the value locally.

    Are you seeing the same value in `XRSettings.supportedDevices` or do they change over time? If you add a console log for `XRSettings.supportedDevices` is it consistent?
     
  4. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    I have raised a issue at steamvrs GitHub page. That was in Feb of this year. But i will let them know of your answer. Thanks
     
  5. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    105
    We did a quick test of this locally and we're always returning the same device list every frame from XRSettings.supportedDevices consistently, so nothing is changing there.
    The root cause of getting a new hash each call is that - GetSupportedDevices() creates a new dynamicArray at start of the method and copies it back out/ return. calling 'getHashCode` is a way to get a unique ID of any object. Every call, there will be a new array / object returned even though the array content stays the same and consistent and hash of new object is supposed to change.
    The best practice is don't call it every update and should cache the string array instead.
     
  6. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Thanks for feedback, i will make sure to relay this to Valve