Assertion failed on expression: 'm_InstanceID != InstanceID_None'

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:

Assertion failed on expression: 'm_InstanceID != InstanceID_None'
0x000000014151A29B (Unity) StackWalker::GetCurrentCallstack
0x000000014151BF4E (Unity) StackWalker::ShowCallstack
0x00000001414EC6D3 (Unity) GetStacktrace
0x00000001411EB65A (Unity) DebugStringToFile
0x00000001411EBACC (Unity) DebugStringToFile
0x0000000140DA646C (Unity) Collider2D::ColliderPairHashFunctor::operator()
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
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> >
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
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[]
0x0000000140E06B90 (Unity) Physics2DManager::IgnoreCollision
0x0000000025FFF87C (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Physics2D:IgnoreCollision (UnityEngine.Collider2D,UnityEngine.Collider2D,bool)
0x0000000025FFF6A1 (Mono JIT Code) [Physics2DBindings.gen.cs:262] UnityEngine.Physics2D:IgnoreCollision (UnityEngine.Collider2D,UnityEngine.Collider2D)
0x00000000274FDB80 (Mono JIT Code) [Breakable.cs:83] Breakable:Start ()
0x000000001F576C42 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFEF67554B3 (mono) [mini.c:4937] mono_jit_runtime_invoke
0x00007FFEF66A83ED (mono) [object.c:2623] mono_runtime_invoke
0x000000014120855F (Unity) scripting_method_invoke
0x0000000140E38585 (Unity) ScriptingInvocation::Invoke
0x000000014120D3A1 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
0x000000014120D4B2 (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked
0x000000014120E347 (Unity) MonoBehaviour::Start
0x000000014120E8D9 (Unity) MonoBehaviour::smile:elayedStartCall
0x000000014094BD15 (Unity) DelayedCallManager::Update
0x0000000140BC29D2 (Unity) PlayerLoop
0x000000014148C442 (Unity) Application::UpdateScene
0x000000014148DA0F (Unity) Application::UpdateSceneIfNeeded
0x00000001414962D4 (Unity) Application::TickTimer
0x000000014155959E (Unity) FindMonoBinaryToUse
0x000000014155ABC1 (Unity) WinMain
0x00000001418762B8 (Unity) strnlen
0x00007FFF24ED2774 (KERNEL32) BaseThreadInitThunk
0x00007FFF25390D61 (ntdll) RtlUserThreadStart

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. (Unity - Scripting API: Physics.IgnoreCollision)

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…

1 Like

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?

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.

1 Like

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.

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?

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)

1 Like

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.

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.

Thanks Aurimas-Cernius, we’ll have that edge case in mind.

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.

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:

assetPath = "Is the path to the asset from the OnPostprocessAllAssets importedAssets var";

GameObject modelAsset = AssetDatabase.LoadAssetAtPath<GameObject> (assetPath);
var animator = modelAsset.GetComponent<Animator> ();

var aramatureRoot = animator.GetBoneTransform (HumanBodyBones.Hips).parent;
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.

assetPath = "Is the path to the asset from the OnPostprocessAllAssets importedAssets var";
GameObject modelAsset = AssetDatabase.LoadAssetAtPath<GameObject> (assetPath);
GameObject model = (GameObject)PrefabUtility.InstantiatePrefab(modelAsset);//Use this clone object instead!!
try {
     var animator = model.GetComponent<Animator> ();

     var aramatureRoot = animator.GetBoneTransform (HumanBodyBones.Hips).parent;
     var children = aramatureRoot.GetComponentsInChildren<Transform> ();
     
     //Work on the HumanDescription skeleton

} finally {
    GameObject.DestroyImmediate (model); //Finally ensuring to destroy the clone after finished:
}

And no more mess :smile: