Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Resolved EditorApplication.isCompiling is always false

Discussion in '2019.3 Beta' started by RunninglVlan, Oct 31, 2019.

  1. RunninglVlan

    RunninglVlan

    Joined:
    Nov 6, 2018
    Posts:
    182
    Hello, noticed a bug that isn't present in 2019.2.11f1. I had an Editor script that logged Compilation Start and End, where Start depended on EditorApplication.isCompiling. In 2019.3.0b8 isCompiling is always false, presumably because of functionality which prevents doing anything in the Editor during Compilation. I guess it stops all running threads or something, and isCompiling would probably return true, but EditorApplication.update isn't triggered.
    Here's the code:
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Callbacks;
    3. using UnityEngine;
    4.  
    5. [InitializeOnLoad]
    6. public class Callbacks {
    7.  
    8.     private static bool startedCompiling = false;
    9.  
    10.     static Callbacks() {
    11.         EditorApplication.update -= OnUpdate;
    12.         EditorApplication.update += OnUpdate;
    13.     }
    14.  
    15.     private static void OnUpdate() {
    16.         if (EditorApplication.isCompiling && !startedCompiling) {
    17.             Debug.Log("Compilation started");
    18.             startedCompiling = true;
    19.         }
    20.     }
    21.  
    22.     [DidReloadScripts]
    23.     static void OnScriptsReloaded() {
    24.         Debug.Log("Compilation finished");
    25.         startedCompiling = false;
    26.     }
    27. }
    I've nothing against functionality which prevents doing anything in the Editor during Compilation, and maybe I wouldn't event write this Script if it was present before, but now I need it to compare compilation times when doing project structure optimizations.

    P.S.: I also noticed that InitializeOnLoad is called after compilation. Didn't know about it before. Maybe documentation needs to be updated as there is nothing said about compilation end?
     
    Last edited: Nov 1, 2019
    kkacperz and nicmarxp like this.
  2. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Aha.. I guess it's 2019.3 beta, or is it out yet?

    Actually it would be suuuuch a big improvement if the editor wasn't actually locked when compiling. Usually I could have adjusted some transform or do stuff while it's compiling/reloading that's not related to any scripts.

    And like if a script changed on the same object I'm working on, I'd be fine if it would reset or so.

    Is that technically impossible? The waiting time between pressing save and when you can go into play mode takes a looot of valuable dev time.

    On a sidenote, when I stand up and work on my stand-up desk, i try to jump around and do stuff while it's compiling.. so in some way I guess it's good.. :p
     
    WildStyle69 likes this.
  3. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
  4. RunninglVlan

    RunninglVlan

    Joined:
    Nov 6, 2018
    Posts:
    182
    @lukaszunity, thanks a lot.
    I started using compilationStarted/Finished. I also reported the bug about isCompiling. It's in FogBugz for now - Case 1196623.
     
    Last edited: Nov 8, 2019
  5. RunninglVlan

    RunninglVlan

    Joined:
    Nov 6, 2018
    Posts:
    182
    akuno likes this.
  6. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    88
    CompilationPipeline.compilationStarted
    CompilationPipeline.compilationFinished

    only work for the specific compiling time in the pipeline (2.2s on my project), not the whole time waiting for unity to become responsive again (7.7s in my project).

    A fix to that, or another way to measure total unresponsive time is highly useful to keep track of total iteration time. Specially in AA projects.
     
  7. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
    The Editor Iteration Profiler also tracks the Asset Refresh and Domain Reload time, which most likely the remaining 5.5 seconds in your project.

    https://forum.unity.com/threads/introducing-the-editor-iteration-profiler.908390/
     
    akuno and SugoiDev like this.
  8. unity_T1WL1huamuCWSQ

    unity_T1WL1huamuCWSQ

    Joined:
    Jun 18, 2019
    Posts:
    10
    What to do in batch mode. If I am setting Symbols like this?
    Code (CSharp):
    1. PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android,"DefineFive");
    2. #if DefineOne
    3.         Debug.Log("One is defined");
    4. #elif DefineFive
    5.         Debug.Log("Five is defined");
    6. #endif
    My Issue is that the log "Five is defined" is not being printed on Editor log in first attempt in batchmode. It is being printed if I run the command again. What callback I should use for this?
    I am using this command.

    Unity.exe -quit -batchmode -projectPath <MyProject Path> -executeMethod BuildByCMD.PerformBuild