Search Unity

Load AssetBundle with Animator Assertion failed

Discussion in 'Scripting' started by ben-maurin, Sep 20, 2017.

  1. ben-maurin

    ben-maurin

    Joined:
    Apr 7, 2016
    Posts:
    47
    Hello,

    I'm using assetbundle system to load data. When loading an asset that has dependencies with an animator I got this error :

    Code (CSharp):
    1. Assertion failed: Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
    2. 0x000000014098D85B (Unity) StackWalker::GetCurrentCallstack
    3. 0x0000000140990E0F (Unity) StackWalker::ShowCallstack
    4. 0x0000000140D36CE0 (Unity) GetStacktrace
    5. 0x000000014107C036 (Unity) DebugStringToFile
    6. 0x000000014107C80C (Unity) DebugStringToFile
    7. 0x0000000140AC9B4F (Unity) AnimationClip::BuildMecanimDataMainThread
    8. 0x0000000140ACAD53 (Unity) AnimationClip::Transfer<StreamedBinaryRead<0> >
    9. 0x0000000140AD16CD (Unity) AnimationClip::VirtualRedirectTransfer
    10. 0x000000014142D4F8 (Unity) SerializedFile::ReadObject
    11. 0x000000014143A181 (Unity) PersistentManager::LoadObjectsThreaded
    12. 0x00000001413CBE8B (Unity) LoadOperation::Perform
    13. 0x00000001413CC1A0 (Unity) PreloadManager::ProcessSingleOperation
    14. 0x00000001413CC30D (Unity) PreloadManager::Run
    15. 0x00000001413CCF47 (Unity) PreloadManager::Run
    16. 0x00000001415AF5CC (Unity) Thread::RunThreadWrapper
    17. 0x00007FFE4EEA2774 (KERNEL32) BaseThreadInitThunk
    18. 0x00007FFE4EFB0D51 (ntdll) RtlUserThreadStart
    I tried with LoadAssetAsync and LoadAsset , both trigger the assert.
    The loading call is in a coroutine.

    The object needed is correctly loaded, but the error is annoying (as I load multiple objects). I don't get this error when loading object that have no dependencies with an animator.

    Does anyone has any idea to avoid the assert?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Did you load all asset bundle dependencies, prior trying to load assets from that bundle? Asset bundles often depend on other asset bundles and without loading those dependencies first, trying to load assets can often result in unexpected behavior.

    https://docs.unity3d.com/Manual/AssetBundles-Dependencies.html
     
  3. ben-maurin

    ben-maurin

    Joined:
    Apr 7, 2016
    Posts:
    47
    I only have one big bundle (for testing) and load items by name, so I don't think it's a dependencies problem. The callstack looks like animator cannot be init during the thread used for assetbundle loading.
     
  4. ben-maurin

    ben-maurin

    Joined:
    Apr 7, 2016
    Posts:
    47
    Nobody tried to load a object with animator using assetbundles?
     
  5. shibasaki

    shibasaki

    Joined:
    Feb 12, 2015
    Posts:
    12
  6. GameTank

    GameTank

    Joined:
    Jul 16, 2014
    Posts:
    2
    using unity2017.2f1
    I get this:
    Assertion failed: Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
    0x00000001411AC76B (Unity) StackWalker::GetCurrentCallstack
    0x00000001411AF0FF (Unity) StackWalker::ShowCallstack
    0x0000000141089420 (Unity) GetStacktrace
    0x00000001405956C3 (Unity) DebugStringToFile
    0x0000000140595EA1 (Unity) DebugStringToFile
    0x00000001415F68CF (Unity) AnimationClip::BuildMecanimDataMainThread
    0x00000001415F7993 (Unity) AnimationClip::Transfer<StreamedBinaryRead<0> >
    0x00000001415FE37D (Unity) AnimationClip::VirtualRedirectTransfer
    0x00000001409A57B8 (Unity) SerializedFile::ReadObject
    0x000000014098BE4F (Unity) PersistentManager::ReadAndActivateObjectThreaded
    0x000000014098DE8A (Unity) PersistentManager::LoadObjectsThreaded
    0x00000001406B71DD (Unity) LoadSceneOperation::perform
    0x00000001406B6890 (Unity) PreloadManager::processSingleOperation
    0x00000001406B69FD (Unity) PreloadManager::Run
    0x00000001406B7667 (Unity) PreloadManager::Run
    0x00000001407B1918 (Unity) Thread::RunThreadWrapper
    0x0000000076B359CD (kernel32) BaseThreadInitThunk
    0x0000000076DAA561 (ntdll) RtlUserThreadStart