Search Unity

Assertion failed on expression: 'm_InstanceID != InstanceID_None'

Discussion in 'Windows' started by tyomklz, Apr 14, 2017.

  1. tyomklz

    tyomklz

    Joined:
    Jul 31, 2015
    Posts:
    48
    Happens a lot when Unity does its Physics2D.IgnoreCollision() anywhere in the project, the worst is that error stacks on top of previous messages while adding new ones that just happened in the frame, in the end it may be over 15k error lines in the console in less than a second, which of course does quite enormous lag and Editor freezes until all errors texts are there in console interface.

    Ideas, suggestions, solutions? Anyone? Already tried sending the project as bug report, but no one could help in the end. It happens across all Unity versions I've been trying, including the latest 5.5 patch (5.5.3p1) and on different machines too, other team members I work remotely with have this problem as well.

    Edit: I've found my bug reports tickets, cases 862687 and 865898.

    Edit 2: Partial solution is to disable assertion messages for the console, where it still says what happens, but doesn't say why, that prevents editor from freezing, but I would like to know what is the actual way to resolve these errors anyway.

    Here's the full error text from the Console:
    Code (CSharp):
    1. Assertion failed on expression: 'm_InstanceID != InstanceID_None'
    2. 0x000000014151A29B (Unity) StackWalker::GetCurrentCallstack
    3. 0x000000014151BF4E (Unity) StackWalker::ShowCallstack
    4. 0x00000001414EC6D3 (Unity) GetStacktrace
    5. 0x00000001411EB65A (Unity) DebugStringToFile
    6. 0x00000001411EBACC (Unity) DebugStringToFile
    7. 0x0000000140DA646C (Unity) Collider2D::ColliderPairHashFunctor::operator()
    8. 0x0000000140DF4B97 (Unity) dense_hashtable<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,Collider2D::ColliderPairHashFunctor,dense_hash_map<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,unsigned int,Collider2D::ColliderPairHashFunctor,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::SelectKey,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::copy_from
    9. 0x0000000140DF9DDC (Unity) dense_hashtable<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,Collider2D::ColliderPairHashFunctor,dense_hash_map<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,unsigned int,Collider2D::ColliderPairHashFunctor,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::SelectKey,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::dense_hashtable<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,Collider2D::ColliderPairHashFunctor,dense_hash_map<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,unsigned int,Collider2D::ColliderPairHashFunctor,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::SelectKey,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >
    10. 0x0000000140DFDE03 (Unity) dense_hashtable<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,Collider2D::ColliderPairHashFunctor,dense_hash_map<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,unsigned int,Collider2D::ColliderPairHashFunctor,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::SelectKey,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::resize_delta
    11. 0x0000000140E0646A (Unity) dense_hash_map<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64>,unsigned int,Collider2D::ColliderPairHashFunctor,std::equal_to<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> >,stl_allocator<std::pair<std::pair<Collider2D const * __ptr64,Collider2D const * __ptr64> const ,unsigned int>,65,16> >::operator[]
    12. 0x0000000140E06B90 (Unity) Physics2DManager::IgnoreCollision
    13. 0x0000000025FFF87C (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Physics2D:IgnoreCollision (UnityEngine.Collider2D,UnityEngine.Collider2D,bool)
    14. 0x0000000025FFF6A1 (Mono JIT Code) [Physics2DBindings.gen.cs:262] UnityEngine.Physics2D:IgnoreCollision (UnityEngine.Collider2D,UnityEngine.Collider2D)
    15. 0x00000000274FDB80 (Mono JIT Code) [Breakable.cs:83] Breakable:Start ()
    16. 0x000000001F576C42 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    17. 0x00007FFEF67554B3 (mono) [mini.c:4937] mono_jit_runtime_invoke
    18. 0x00007FFEF66A83ED (mono) [object.c:2623] mono_runtime_invoke
    19. 0x000000014120855F (Unity) scripting_method_invoke
    20. 0x0000000140E38585 (Unity) ScriptingInvocation::Invoke
    21. 0x000000014120D3A1 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
    22. 0x000000014120D4B2 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
    23. 0x000000014120E347 (Unity) MonoBehaviour::Start
    24. 0x000000014120E8D9 (Unity) MonoBehaviour::DelayedStartCall
    25. 0x000000014094BD15 (Unity) DelayedCallManager::Update
    26. 0x0000000140BC29D2 (Unity) PlayerLoop
    27. 0x000000014148C442 (Unity) Application::UpdateScene
    28. 0x000000014148DA0F (Unity) Application::UpdateSceneIfNeeded
    29. 0x00000001414962D4 (Unity) Application::TickTimer
    30. 0x000000014155959E (Unity) FindMonoBinaryToUse
    31. 0x000000014155ABC1 (Unity) WinMain
    32. 0x00000001418762B8 (Unity) strnlen
    33. 0x00007FFF24ED2774 (KERNEL32) BaseThreadInitThunk
    34. 0x00007FFF25390D61 (ntdll) RtlUserThreadStart
     
    Last edited: Apr 14, 2017
  2. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    141
    I get this also, and seemingly randomly, when using IgnoreCollision.

    I have IgnoreCollisions being called when the project starts, 70% of the runs are fine, but some runs produce this error on the IgnoreCollision() call.

    I've not spent the time yet to figure out why it does it sometimes, but looking at the doco, it says that IgnoreCollision should only be used on Active game objects. (https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html)

    My suspicion is that its because I'm calling it on the GO when its actually disabled, and I'm guessing that there are some timing issues doing that and that is why the say you cant call it on disabled GOs.

    Seems a bit of a restriction to say you cant call it on disabled GOs, but I guess they don't want to code that. So I'm probably gonna have to enable them, call the IgnoreCollisions and then disabled them quickly, not the best but hey....
     
    CloudyVR likes this.
  3. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    141
    Hmm, scrub the idea about enable/disable, I did some work my side to only issue them when the GO is active, and I'm still getting lots of random assertion failures on console.

    Problem is, I cant actually see if they are causing a real error/problem or not. Maybe its just a bug running in the editor, and it will be fine in game?

    Would be nice to get a conformation from the devs or a fix?
     
  4. tyomklz

    tyomklz

    Joined:
    Jul 31, 2015
    Posts:
    48
    It is fine in game, the problem is the logging to the console. I ended up getting rid off IgnoreCollision function completely and switched to using the collision matrix just because of this console problem, smh.
     
    CloudyVR likes this.
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    I've not had a bug report and I looked quickly at 862687 and 865898; both are closed as unqualified. I'll check with the QA to see what's going on there.

    As a side note, please try to post in the correct forum as you're then more likely to get attention from the correct developers, in this case me. If you had posted this in the physics forum I would've seen it immediately.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    Both cases were closed as not being able to reproduce in Jan this year with no reply.

    Are you saying you're still able to reproduce this?
     
  7. aangelov

    aangelov

    Joined:
    Dec 13, 2016
    Posts:
    5
    Hey guys,

    It's happening randomly in our project too, but it's on a different API call:

    Assertion failed: Assertion failed on expression: 'm_InstanceID != InstanceID_None'
    UnityEngine.Networking.DownloadHandlerTexture:GetContent(UnityWebRequest)
     
    CloudyVR likes this.
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    There are a bunch of asserts in the engine that use this and given your call, likely coming from the base object (where it checks that an object isn't already assigned an InstanceID) so could be anything.

    Certainly not related to the issue posted on this thread. You should post a bug report so someone could look at it.
     
  9. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    There were fixes for this issue, but it is still possible.
    Basically, if it is possible that you switch the scene while request is still running, don't use DownloadHandlerTexture. Instead just download the bytes and create texture manually. DownloadHandlerTexture creates a texture in background for the current scene, this texture gets destroyed automatically when scene is changed, so there is a race condition. This assert will be hit if scene change happens right between texture creation and script update where that texture is returned to your code.
     
  10. aangelov

    aangelov

    Joined:
    Dec 13, 2016
    Posts:
    5
  11. tyomklz

    tyomklz

    Joined:
    Jul 31, 2015
    Posts:
    48
    As I said in OP, it starts happening when when you call Physics2D.IgnoreCollision() too often in every scene or every few seconds from different scripts. The problem still exists in the latest Unity version and patches. Double foreach loop has been used over there to go through many colliders of both objects, but that's not the case, I think.

    It's causing problems to Editor only (because of enormous amount of messages in the console, it freezes for a second or more, depends on the amount of messages and they multiply as you go).

    P. S. @Moderator, please, move it to the right forum.
     
    Last edited: Oct 17, 2017
  12. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    Now in Unity 2019.1.0f2 I am getting this error almost continuously in editor when I call:

    AssetDatabase.Refresh ();

    ---or---
    ModelImporter.SaveAndReimport ();


    Error:
    Assertion failed on expression: 'm_InstanceID != InstanceID_None'
    UnityEditor.AssetDatabase:Refresh()

    ---or---
    Assertion failed on expression: 'm_InstanceID != InstanceID_None'
    UnityEngine.GUIUtility: ProcessEvent(Int32, IntPtr)


    PC Specs: here
    OS: Windows 10 64

    -------------------

    [Edit]
    I managed to isolate what was causing those errors in my code.

    Below is a snippet of how I am attempting to automate some humanoid assetbundle with an AssetPostprocessor. Notice I need a reference to the Animator component, then iterate some of the child bone transforms.

    Well when I tried to grab a reference to the Animator like this it always caused the error right after the import finished:
    Code (csharp):
    1. assetPath = "Is the path to the asset from the OnPostprocessAllAssets importedAssets var";
    2.  
    3. GameObject modelAsset = AssetDatabase.LoadAssetAtPath<GameObject> (assetPath);
    4. var animator = modelAsset.GetComponent<Animator> ();
    5.  
    6. var aramatureRoot = animator.GetBoneTransform (HumanBodyBones.Hips).parent;
    7. var children = aramatureRoot.GetComponentsInChildren<Transform> ();

    However when I instead used InstantiatePrefab to get a reference to a clone Animator it does not cause any errors after the import.
    Code (csharp):
    1. assetPath = "Is the path to the asset from the OnPostprocessAllAssets importedAssets var";
    2. GameObject modelAsset = AssetDatabase.LoadAssetAtPath<GameObject> (assetPath);
    3. GameObject model = (GameObject)PrefabUtility.InstantiatePrefab(modelAsset);//Use this clone object instead!!
    4. try {
    5.      var animator = model.GetComponent<Animator> ();
    6.  
    7.      var aramatureRoot = animator.GetBoneTransform (HumanBodyBones.Hips).parent;
    8.      var children = aramatureRoot.GetComponentsInChildren<Transform> ();
    9.      
    10.      //Work on the HumanDescription skeleton
    11.  
    12. } finally {
    13.     GameObject.DestroyImmediate (model); //Finally ensuring to destroy the clone after finished:
    14. }

    And no more mess :D
     
    Last edited: Apr 29, 2019