Search Unity

Help Wanted SaveAndReimport performance on TextureImporter

Discussion in 'Profiler Previews' started by Jexalicious, Mar 27, 2021.

  1. Jexalicious

    Jexalicious

    Joined:
    Apr 2, 2016
    Posts:
    5
    I have a project that has started to have a large number of assets and I've noticed a very significant slowdown on some of my editor scripts. In some cases a script that used to take 40s, was taking 8 minutes.
    I'm currently using latest 2019 LTS version.

    In these scripts, I do a lot of image processing and generation, which require me to set specific parameters per texture on the importer as well.

    I've been profiling it and I found the major slowdown cause to be in the SaveAndReimport calls.
    I've managed to reduce the number of calls by detecting redundant ones. But I've reached a point where I can't remove any more calls.

    The thing I find weird, is that by going deeper on what SaveAndReimport is doing, I noticed that it is spending an obscene amount of time looking for AudioMixerControllers, which should have nothing to do with a TextureImporter to begin with.

    upload_2021-3-27_18-6-0.png

    From what the FindAllAudioMixerControllers actually does, the amount of time it takes should be related to the amount of assets in my project.

    I could live with it if this was actually a necessary operation. But to me I don't see why Unity would have to call this method when reimporting a texture.

    Has anyone come across this issue? Is there a way I could prevent Unity from calling this?
     
  2. Jexalicious

    Jexalicious

    Joined:
    Apr 2, 2016
    Posts:
    5
    UPDATE:

    Apparently to stop that from happening I just had to close the Audio Mixer window...

    But this just makes the issue stranger. By simply having an unrelated window open, Unity was slowing down my scripts by obscene amounts. This does not seem like intended behavior to me.
     
unityunity