Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question XRGeneralSettings.AttemptInitializeXRSDKOnLoad() massively slows down entering Playmode

Discussion in 'VR' started by Kawalyn, Jun 25, 2021.

  1. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    Hey,

    all of a sudden my EnterPlaymode time is abysmal again. Had the same issue 2 weeks back and fixed it by reinstalling my project... but that's not a valid fix to do every other week as the project file size is pretty large.

    Normally the EnterPlaymode time isn't the best anyway due to some SteamVR shenanigans but when this (i assume) bug happens it goes up from roughly 20 seconds to an unbearable 1 to 3 minutes. Every single time.

    Checking the profiler the culprit is the XRSystem.

    upload_2021-6-25_13-12-8.png

    GC is going mental during startup as well with more than 30 to 40MB of GC alloc.

    No idea what to do about it, help would be greatly appreciated because watching loading bars isn't quite my favourite thing in the world.

    OS: Windows 10
    Unity: 2020.3.10f
    XR Plugin: 4.0.1 (scared to update to 4.0.6 because getting it to work with SteamVR in the first place was a nightmare)
    OpenVR XR Plugin: 1.1.4
    SteamVR in project: v2.7.3 (sdk 1.14.15)
    SteamVR app: 1.17.16

    Thanks.

    EDIT: Right after posting this the next startup took 2 seconds. It seems to be totally random when the XRSystem decides to take forever. Restarting the engine doesn't help either.
    EDIT2: After some testing the chance of the process taking forever diminishes the longer one stays in the editor without recompiling the code base. After a recompile it almost always take more than 2 minutes to enter playmode. Horrible working condition, feel like i spent 2 hours looking at loading bars today >.<
     
    Last edited: Jun 25, 2021
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    This doesn't make any sense as `AttemptInitializeXRSDKOnLoad` does not do writing to the asset DB in any way. Not sure what changes are being written in there.

    Couple Q: Does this happen if you DON'T use SteamVR?
    Could you enable "Deep Profiling" in the profiler and try to capture this hang then? That might net more info as to what is happening.

    If you still can't get anywhere, can you strip this down to a small repro case, file a bug and report the case id here?

    TIA
     
  3. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    Hey, thanks for the fast reply and sorry for my own delay, had to work on different projects the past days.

    The Deep Profiling tip helped, now the culprit is clear but i am not sure how/where to check the .dll with the method call in question.
    upload_2021-6-30_16-11-57.png

    Seems like some path reference broke in the back... i was getting ~200 "(Unknown) script is missing" warnings from the InitializeActionManifest... action a while back, but of course now that i want to screenshot them they're not popping up anymore... loading times are still scuffed. Feel like SteamVR itself might be broken on this machine, as the other machine with same OS has no issues whatsoever. Gonna reinstall and see if that helps.

    Also tried creating new SteamVRInput settings before saving and generating the actions file, the first load afterwards worked flawlessly in 3 seconds but right after it was back to 3 minutes load times.

    I'll post the warning log when i get it again, right now i have to finish some stuff for a deadline tomorrow >.<

    Sorry if the first post sounded annoyed, wasn't in the best mood and i can't say that working with SteamVR is helping, so much frustration every other week because something decides to break.

    Thanks again for your support, highly appreciated!
     
  4. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    Reinstalling SteamVR and restarting didn't help either... so possibly a corrupt file in the OpenVR / XR stuff? :thinking:

    At least the warning came back, here you go:
    upload_2021-6-30_16-49-16.png

    Code (CSharp):
    1.         public bool InitializeActionManifestFileRelativeFilePath()
    2.         {
    3.             string oldPath = ActionManifestFileRelativeFilePath;
    4.             string newPath;
    5.  
    6.             if (OpenVRHelpers.IsUsingSteamVRInput())
    7.             {
    8.                 newPath = System.IO.Path.Combine(OpenVRSettings.GetStreamingSteamVRPath(false), OpenVRHelpers.GetActionManifestNameFromPlugin());
    9.              
    10.                 string fullpath = System.IO.Path.GetFullPath(".");
    11.                 newPath = newPath.Remove(0, fullpath.Length + 1);
    12.  
    13.                 if (newPath.StartsWith("Assets"))
    14.                     newPath = newPath.Remove(0, "Assets".Length + 1);
    15.             }
    16.             else
    17.             {
    18.                 newPath = null;
    19.             }
    20.  
    21. #if UNITY_EDITOR
    22.             if (newPath != oldPath)
    23.             {
    24.                 ActionManifestFileRelativeFilePath = newPath;
    25.                 UnityEditor.EditorUtility.SetDirty(this);
    26.                 UnityEditor.AssetDatabase.SaveAssets();
    27.                 return true;
    28.             }
    29. #endif
    30.             return false;
    Seems like the path is corrupt or missing so he refreshes the AssetDatabase on every game start in editor. It is a simple public variable in the script, but i am lost how to access it further.

    EDIT: Far shot but could this be due to windows path length restrictions? The project is in a quite nested structure so maybe the lowest path he accesses is simply to long to work properly in windows?
     
  5. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
  7. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    @joejo Sadly not yet as i'm on vacation just now and had to finish another project for a deadline before - i'll try to solve it when i'm back at the office next week
     
  8. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    NP, thanks. Will wait for your reply then.
     
  9. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    Thought unlocking the path length helped but sadly a couple of hours later i'm back to 3min+ loading times.
    Opened a new issue over in the steamVR repo, click here.
     
  10. StCost

    StCost

    Joined:
    Mar 1, 2017
    Posts:
    30
    Same issue here
     
  11. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    Yeah wouldn't count on a fix, SteamVR support is basically non-existant it seems.
     
  12. StCost

    StCost

    Joined:
    Mar 1, 2017
    Posts:
    30
    I tried to see what the hell is going in that piece of code. Seems like it tries to write new path, but for some reason it never updates. It's always stays the same upload_2021-9-15_18-47-41.png

    upload_2021-9-15_18-47-50.png

    Removing the actions.json file, steamVR settinngs, toggling "read only" didn't helped yet

    Temporarily commented the 185 line, so it won't make me to wait for 5 minutes just in case
     
    Last edited: Sep 15, 2021
  13. StCost

    StCost

    Joined:
    Mar 1, 2017
    Posts:
    30
    Well, seems like I fixed it.

    I don't know is it temporarily, or I really did fixed it, but it's gone for now. I'm using GitHub for version controls. I simply deleted my project and cloned it fresh new. All packages and libraries were rebuilt. Now I have regular 6s loadings. Even after scripts recompiling

    I'll be back, if issue will appear again. We'll see

    PS: I didn't had any warnings about that problem, so maybe source of my issue was in something else
     
    Last edited: Sep 15, 2021
    FyndNorway likes this.
  14. Kawalyn

    Kawalyn

    Joined:
    Apr 8, 2015
    Posts:
    14
    Sorry for getting back to you only now - for us the issue is happening in the URP.

    Been away for a few weeks and had to work on another project today. Everything went fine for the past 5 hours and now the terrible loading times are back. 2+ minutes already. Can't really reinstall the project every second day :D

    Then again i quit this job anyway as i'm fed up with buggy IT S***, so i'm out for good in a week. Party hard!

    EDIT: Now it feels like rolling a dice. Times vary from 5 seconds to 2 minutes.
     
  15. StCost

    StCost

    Joined:
    Mar 1, 2017
    Posts:
    30
    Just find this file again and comment the line 26 (idk which is line in real file). It's a workaround, but as long as you don't plan to change SteamVR settings in your project or rebuild packages - you'll be fine. At least you'll get rid of that long ass loadings

    As for me, since my previous comment, the issue is gone totally. So I'm free now