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:
    15
    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:
    15
    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:
    55
    Hi its still the same nothing happens
     
  4. WillCrate

    WillCrate

    Joined:
    May 16, 2016
    Posts:
    15
    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:
    45
    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.
  6. anatomi

    anatomi

    Joined:
    Jan 9, 2016
    Posts:
    7
    Experienced sudden lag on 2019.3.0b12. This fix seems to have solved it.

    EDIT:: Also reset the bool - still works.
     
  7. rus89

    rus89

    Joined:
    Apr 22, 2015
    Posts:
    9
    I had the same problem. Everything was fine until some moment and then my game started flickering in the editor. I tried various solutions but nothing helped me until I deleted the Library and Temp folder from the project directory.

    First, I closed the Unity, then I delete the aforementioned folders, started Unity again, change the Build Settings and run the game.

    I working in Unity 2019.2.12f1 and on macOS Catalina 10.15.

    I hope this can help somebody.
     
  8. techygamer5132

    techygamer5132

    Joined:
    Mar 23, 2020
    Posts:
    2
    can some one help me
    i installed unity on my new pc
    it is perfectly capable of runing unity
    i am having trouble understanding hoow to seet it true or false and where is the script located
    iam using unity 219.1.13f1
    iam new to unitypls help
     
  9. pantang

    pantang

    Joined:
    Sep 1, 2016
    Posts:
    219
    I keep getting this when trying to upgrade past 2019.3.7.f1 and now in the new LTS my player characters(using a pretty much standard animated 3rd person controller which doesnt seem to be the cause) fall halfway through the ground. and seem to ignore half the volume of the colliders they have. lol starting to think 2019.3.7 is my new personal LTS.
     
  10. WillCrate

    WillCrate

    Joined:
    May 16, 2016
    Posts:
    15
    I gave a little more detail on this issue in this other thread: https://forum.unity.com/conversations/unity-2018-editor-is-slow.558676/

    You just want the script to run somewhere, anywhere. As the script is modifying your editor preferences which is saved in your PCs registry. The code is never intended to be committed and left in your project. So simply adding it to some Awake() function on a component that will run is enough for it to modify the registry and thus for you to see if your lag goes away. I do suggest profiling like I did in my original screenshots to verify that Unsupported.IsDeveloperMode() is actually lagging your editor though. Requires the profiler running in Deep Profile + Profile Editor though. Although I suppose running the code to see if it fixes the issue is even easier than profiling.
     
    Last edited: Aug 15, 2020
  11. WillCrate

    WillCrate

    Joined:
    May 16, 2016
    Posts:
    15
    Just to be thorough, I wanted to respond and state that I have never used JetBrains and my editor has always been some version of Visual Studio with their Unity tools installed.