Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug in Unity? Importing / Compressing a lot of (huge) Audio Files hangs / freezes

Discussion in 'Editor & General Support' started by sendel76, Aug 10, 2011.

  1. sendel76

    sendel76

    Joined:
    Mar 17, 2010
    Posts:
    36
    Hi,

    Reason for this post: I think i found a serios bug in Unity 3.4 Pro Importer.

    if you import a lot of Ogg-Files Unity will freeze/hang after a while. The first x files get compressed as expected but then it slows down until complete freeze.

    I thought its a problem related to ogg-files - but nah nah! Its the importer! I replaced all OGG-Files with WAV-Files and scripted a "set all AudioFiles to compressed and reimport it" - and guess what: Same issue here. First wav-files get imported / converted but then slows down until full freeze.

    Here is the script I use (but you could also just paste a lot of OGG files to you project)

    ReimportAllAudioFiles.cs Editor Script (c#) so you could force all audiofiles in a directory to reimport.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4.  
    5. using System.Collections;
    6. using System.IO;
    7.  
    8. public class ReimportAllAudioFiles : ScriptableObject
    9. {
    10.     [MenuItem ("Custom/Audio/ReimportWav")]
    11.     protected static void ReimportAllAudio ()
    12.     {
    13.        
    14.         string realPath = Application.dataPath;
    15.         realPath = realPath.Remove( realPath.Length - 6 );
    16.        
    17.         string selectedPath = realPath + AssetDatabase.GetAssetPath( Selection.activeObject );    
    18.        
    19.         string [] fileEntries = Directory.GetFiles( selectedPath, "*.wav", SearchOption.AllDirectories );
    20.        
    21.         foreach (string file1 in fileEntries )
    22.         {
    23.             string file = file1.Replace( "\\", "/" );
    24.             file = file.Remove( 0, realPath.Length );
    25.             Debug.Log("AssetDatabase.ImportAsset("+file+");");
    26.             AssetDatabase.ImportAsset( file );
    27.         }
    28.  
    29.     }
    30.  
    31.    
    32. }
    33.  
    34.  
    and NewAudioSettings.js to setup all audio import properties when a AudioAsset gets imported.

    Code (csharp):
    1.  
    2. class NewAudioSettings extends AssetPostprocessor
    3. {
    4.     function OnPreprocessAudio ()
    5.     {
    6.         var audioImporter : AudioImporter = assetImporter;
    7.        
    8.         Debug.Log("My Asset Post Processing " + audioImporter.assetPath);
    9.  
    10.         if ( audioImporter.format != AudioImporterFormat.Compressed )
    11.         {
    12.             audioImporter.threeD = false;
    13.             audioImporter.compressionBitrate = 128000;
    14.             audioImporter.format = AudioImporterFormat.Compressed;
    15.             audioImporter.loopable = true;
    16.         }
    17.         else
    18.         {
    19.             Debug.Log("Asset already compressed");
    20.         }
    21.        
    22.     }
    23. }
    24.  
    here is the list of files with size description I use in that unity iOS Project. I use Unity 3.4 Pro for iOS on a Mac Pro i7 Dual Core (12 virtual CPU Threads), 8GByte Ram, OS is Lion


    Code (csharp):
    1.  
    TOTAL 207 Files about 436.636.814 Bytes

    So - i think this is a serios bug in Unity - may be only in the Mac Version - don't know. Is there any solution for that bug? Is there a possibility to report such bugs?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Bug Reporting - in the help menu the bug reporter
     
  3. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Bug confirming: you are at the right place. Is somebody able to repeat?
     
  4. sendel76

    sendel76

    Joined:
    Mar 17, 2010
    Posts:
    36
    I encountered that this bug is only on Macs - may be just my mac or may be just Mac with Lion. The PC will just do it fine. I could maybe create a sample project to demonstrate that bug. Will post that tomorrow since Im kind of busy right now.

    I will test it on an older mac, too. And then posting again with sample project. Thank you for the quick response!
     
  5. arslan-arshad-ali-68

    arslan-arshad-ali-68

    Joined:
    Aug 18, 2015
    Posts:
    5
    In Unity 2017.4.2 Mac OS Catalina Wav files are the issue. Unity Freezes while importing them
     
    shenle04517 likes this.
  6. shenle04517

    shenle04517

    Joined:
    Sep 19, 2017
    Posts:
    5
    me too
     
  7. Vladyslav_Murka

    Vladyslav_Murka

    Joined:
    Jan 28, 2020
    Posts:
    3
    Have you found an answer? Any solution?
    I can not open project becuase of OGG files, they not gonna imported,
    and asset importer menu is getting time but nothing is happening
     
  8. Vladyslav_Murka

    Vladyslav_Murka

    Joined:
    Jan 28, 2020
    Posts:
    3
    Joined:
    Jan 28, 2020
    Posts:
    1

    In Unity 2017.4.2 Mac OS Catalina Wav files are the issue. Unity Freezes while importing them
    Have you found an answer? Any solution?
    I can not open project becuase of OGG files, they not gonna imported,
    and asset importer menu is getting time but nothing is happening
     
  9. Vladyslav_Murka

    Vladyslav_Murka

    Joined:
    Jan 28, 2020
    Posts:
    3



    Have you found an answer? Any solution?
    I can not open project becuase of OGG files, they not gonna imported,
    and asset importer menu is getting time but nothing is happening