Search Unity

Editor: Domain reload and / or scene reload

Discussion in '2019.3 Alpha' started by Lars-Steenhoff, May 17, 2019.

  1. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,070
    • Editor: Domain reload and / or scene reload could be disabled when entering play mode to allow faster iteration times in the editor.

      This is amazing, instant play without any lag, thanks for including this!

      First test are really promising, there were sometimes missing references, but that was a problem with a script that I purchased. Enabling domain reload fixed that for now, but I will investigate it more.
     
  2. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,800
    Is this enabled by default? If not, how do you turn it on? It sounds amazing!

    Edit: Figured it out. Edit->Project Settings->Editor->Enter Play Mode Settings.

    So far it's feeling like magic!

    Does anyone know what the drawbacks are of it? Is there a way to manually trigger domain reload and is that even necessary?
     
    Last edited: May 18, 2019
    Lars-Steenhoff likes this.
  3. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,165
    The main drawback is that none of the state stored in the domain is reset. So for example, if you have static variables in your classes and you have [ExecuteInEditMode] scripts or custom Editor scripts which cause those static variables to be set, then turning off the domain reload means the static variables will not be nulled/zeroed when entering play mode anymore.
     
  4. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,800
    That makes me want to write a script that resets all static variables on entering play mode.
     
  5. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    312
    Get rid of your static variables.
     
  6. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,165
    Note that re-initializing all the static variables is a big part of where domain reload time actually goes. If we just did a blanket reset of all static state, then we'd also need to rerun all the [InitializeOnLoad] methods etc, and almost all the cost savings would be gone (like we'd be skipping re-JIT of the code but that'd be all). If you want to create your own tools to reset static state, you will definitely want to pick and choose what you apply that to.
     
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,070
    Would it be an idea to make one extra option ?
    Domain reload with only re-JIT

    I don't know what impact re-JIT has on a large project with many scripts?

    I say this because I have some projects with many scripts that I purchased on the asset store and I can't remove all the static variables from those assets because I simply would not know how.

    This way there is perhaps still some time saving while not trowing up errors for static variables.
    Might be interesting to explore
     
  8. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    312
    Small Feedback: We saved around 17 seconds. Went from 23 seconds of intial loading screen to 6 seconds. Full launch halfed due to this. Thanks!!!
     
    5argon, Seb-1814, Griz and 4 others like this.
  9. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,165
    I believe the team looked into it, and the impact of JIT itself is negligible.
     
  10. Pyromuffin

    Pyromuffin

    Joined:
    Aug 5, 2012
    Posts:
    68
    This is very cool!
    There seems to be a bug with shuriken though. Particle systems don't start playing when switching to play mode unless you start them in the editor by hitting the "play" button in the "particle effect" scene gui.
     
  11. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,261
    Just when I thought I could settle down with 2018.3 new prefabs, 2019.1 has timeline signals I need to make my UI.
    Then when I think I could settle down with 2019.1, then this killer feature came.

    Mine went from 11s to 0.5s. This is unreal. Thanks a lot for this feature!
    I might as well print out the release note and frame it.
     
    Seb-1814 and Griz like this.
  12. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    450
    no this is Unity
    :p
     
    Gua likes this.
  13. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,261
    Thank you
     
  14. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    263
    Thank you for testing the feature!
    We are working on docs to explain all drawbacks and how to avoid those (statics not being reset, [NonSerialized] fields being kept, etc.)

    Please file a bug for this - I suspect the scene reset path doesn't reinitialize Particle system properly.
     
    richardkettlewell likes this.
  15. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    85
    Hi, I have a few questions:
    - is there a reload when you stop in editor ?
    - is there any impact on scriptable objects or other things you would live edit on play and then press stop (same question but before pressing play)
     
  16. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    263
    No. There is no domain reload when you exit playmode.
    Domain reload only happens when scripts are recompiled and has to be integrated, and (by default) when entering Playmode.

    The feature doesn't change any exit playmode behavior. So there is no impact on things you edit and press stop.
    When you press play with domain reload disabled the data of scriptable objects remains. The major difference between enterplaymode without domain reload and with domain reload is - 1) static fields are not reset and static type initializers are not called, 2) fields marked with [NonSerialized] keep their values.
    The editing workflow is unchanged.
     
  17. mountblanc

    mountblanc

    Joined:
    Sep 24, 2015
    Posts:
    71
    I starting a new project from scratch using Unity 2019.3.0a5 (due to this feature) for a week now (in my limited spare time) And i have to say I never want to go back to older versions.
    Even do some Packages like 2D Animation and Vector Graphics are not working (yet)
    The only thing i want back is the time i wasted before this feature existed! ;-)
    I suspect do due to the static 'limitation's that many current editor related assets will break. (or at least act strange at times)
    Luckily I only use one asset so far and that gives me no problems.

    The play button turned into a Harry Potter button. Touching it feels like magic!
     
  18. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    I'm really happy but at the same time really mad.
    They should've done it a long time ago and we would have saved countless hours.
    It's too bad that they just realize and they better be sorry but at the same time, I'm really happy we can have a better future. It a funny feeling.

    It's better late than never but it will take a while before we all adopt it. If one asset you are using causing a problem, you cannot use Instant Play, and it will be very disappointing.
    Therefore, I wanted to have them to make the Instant Play available as soon as possible (for 2019.2 ??) so that Asset developers have time to make it compatible but then, it looks like we will have to wait until 2019.3 releases (Most of the asset developers will not touch beta product after being burned by beta so many times)
    Unity has broken so many promises delivering stuff late and why they can't they deliver something earlier than scheduled just for once? It's an optional feature and it won't hurt anyone.

    Well, if they can't deliver it earlier, the only thing I ask is to make sure it's easy/rock-solid to integrate once 2019.3 release so that asset developers will easily optin and as fast as possible. Since we know it's possible to support Instant Play, I cannot wait any longer. Waiting for 2019.3 and beyond is just too painful.

    Thanks.

    ps. I wanted to test this on my project but the stupid missing UI assembly is stopping me from it. Don't they do any sort of compatibility testings before they do something? Sigh...
     
    alexeyzakharov likes this.
  19. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    182
    @alexeyzakharov for a large AAA project that takes ~10 to 20 minutes to first enter play mode (reproducible on multiple employee machines), is there a general % of time reduction expected?

    and are there other editor performance improvements Unity is working on?
     
    alexeyzakharov likes this.
  20. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    263
    Hi @XRA!
    Is it possible to take a profiler capture (ProfilerEditor + Hierarchy View)?
    If you say first enter play mode, building sprite atlases comes to my mind. Do you use a lot of those?

    There is a work going on in multiple areas, but I'm not sure if that covers your use case. 10 to 20 minutes to enter playmode is for sure too much. If we could pinpoint it better, we could understand how to fix/avoid such a long hang.