Search Unity

Editor Lag - Tracked down to Unsupported.IsDeveloperMode

Discussion in 'Editor & General Support' started by WillCrate, Nov 19, 2018.

  1. WillCrate

    WillCrate

    Joined:
    May 16, 2016
    Posts:
    9
    Unity version: 2018.2.16f1 (Also reproduced on 2018.1.9f2 and 2018.3.0b10 BETA)
    Platform: Windows 10 64bit
    Specs: Intel i7-5820k 6-core 3.3ghz, 16GB RAM, Geforce 1080 (Latest drivers 416.94)
    Editor is running in DX11
    Project: Fresh 3D Template project. 0 changes.

    My repro: As simple as using WASD to move around in the scene view drops frames by a ton. So badly that I can actually release the keys and the scene will still be trying to move the camera as if the keys are still pressed down. Eventually it catches up.

    So I profiled the editor and tracked it down to Unsupported.IsDeveloperMode in deep profiling mode. See attached pics. Note, there are more calls to that than just what is highlighted. Follow the profile to data to see each one.

    What is this? I assume plenty of others aren't having this as an issue or else it would have already been reported/fixed. Any ideas of what I can do to fix this?

    P.S. I was UNABLE to reproduce this on 2017.4.15f1 LTS, 2017.2.4f1, 2017.1.5f1, or 5.6.6f2.

    2018.2 Deep1.png 2018.2 Deep2.png
     
  2. WillCrate

    WillCrate

    Joined:
    May 16, 2016
    Posts:
    9
    Ok so I found a fix. I am actually a bit surprised at this one. Unsupported.IsDeveloperMode() seems to have been added to 2018.x+ versions of Unity.

    The developer mode it speaks of is not some developer mode for some type of peripheral like an android phone. It seems to be a developer mode for the unity editor itself. There is even a comment in their C# code that they release publicly for the Preferences window stating that its not intended for users just yet. However after looking into what the preferences window does with that call I noticed it sets a "DeveloperMode" EditorPref.

    I wrote code to log the current value which ended up logging false:
    Code (CSharp):
    1. bool test = UnityEditor.Unsupported.IsDeveloperMode();
    I then set DeveloperMode to true:
    Code (CSharp):
    1. UnityEditor.EditorPrefs.SetBool("DeveloperMode", true);
    Not only did the lag in editor go away but I also had some extra developer mode icons and info in the editor. Such as allocated memory and object count.

    I then set it back to false assuming its not really supposed to be on for regular users just yet. I expected my lag to return but nope. It remains smooth.
    Code (CSharp):
    1. UnityEditor.EditorPrefs.SetBool("DeveloperMode", false);
    Since Unsupported.IsDeveloperMode() is an extern function, its actual code is in C++ and thus is hidden from me. My guess is my registry for EditorPrefs had some values that it did not like. Perhaps setting it to true/false sets some other EditorPref along with "DevelopmentMode"? Or maybe the registry value was something other than an expected value of 0 or 1? I am not sure.

    I hope this helps someone else that may come across this issue. I also submitted a bug report in hopes that Unity could prevent such lag even with whatever state was causing it.
     
  3. tataygames

    tataygames

    Joined:
    Aug 4, 2016
    Posts:
    25
    Hi its still the same nothing happens
     
  4. WillCrate

    WillCrate

    Joined:
    May 16, 2016
    Posts:
    9
    I actually had this issue return in the middle of using the editor. The profiler did not show Unsupported.IsDeveloperMode() like it did before. As a guess I set "DeveloperMode" editor pref to true again and it fixed it yet again. I am not sure what the deal is but my submitted bug report still has an open status.
     
    ghostitos likes this.
  5. SmashedAvocado

    SmashedAvocado

    Joined:
    Dec 19, 2013
    Posts:
    36
    This fix worked for me.

    I was experiencing lag on 2018.3.10f1, whenever I clicked and held the mouse button down, everything would drop to 20 FPS.

    Adding "UnityEditor.EditorPrefs.SetBool("DeveloperMode", true);" stopped the lag.

    No other solutions I could find online fixed the issue except this line of code.

    Specs:
    Intel i7-6950X (10 core)
    GTX 1080Ti (419.67 drivers. Gysnc off.)
    Windows 10, 64-bit

    What editor are you using @WillCrate ? I just tried out JetBrains Rider - wondering if that is a contributing factor.

    Update: Also setting the bool back to false retained the performance. i.e. no more lag after turning that bool on and off in code.
     
    ghostitos likes this.