Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'

I cannot verify if the error only occurs when debugging, as I have no console when testing in release mode and random crashes in general seem to be “normal” on Windows Store.

Can anyone tell me if this error is something to be concerned about:

It happens around our level loading code, which loads a level asyc, if that matters …
Is this coming from the engine itself, or e.g. parts of our code which use a lot of “runOnApp/UIThread”, “isRunningOnApp/UIThread” (we sort of rely on those functions, can’t remove them quickly)?

Thanks!

PS: Using 5.5.0p3 (64-bit), Windows Store = 8.1 Phone/Desktop and UWP

1 Like

This is a definite bug in our code. You can’t see it in release mode because it’s an assert, and asserts are only enabled on debug builds. That’s also why you probably can’t see it on any other platform: we don’t really ship debug players on platforms other than Windows Store and Xbox One (for instance, development standalone player is equivalent to windows store release config).

Do you have a callstack for this assertion? If you switch to mixed mode debugging, debugger should break when it hits and you’ll get the callstack. You’ll also be able to continue in that case.

Thanks, I’ll look into it right away …

WP8.1:
Native Only:
About every Frame:

Exception thrown at 0x711F8F0F (qcdx9um8960.dll) in Sniper Ops 3D.exe: 0xC0000005: Access violation reading location 0x103D803C.
Unhandled exception at 0x711F8F0F (qcdx9um8960.dll) in Sniper Ops 3D.exe: 0xC0000005: Access violation reading location 0x103D803C.

Side noted that issue before here btw:

Managed Only:
I only get this:

Load Level Async progress:0,9
Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
(Filename: C:\buildslave\unity\build\Runtime/BaseClasses/BaseObject.h Line: 873)

Background Info:
We 1) Load a level asyc, this seems to work.
Then 2) Onto that level, we load an additional level asyc.
I cannot yet say if the level loading code is related to that or anything else.

Mixed: Didn’t get that to work.
Popup says either Native or Managed.
Can you debug both at the same time?

Win10 Mobile:

Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
(Filename: C:\buildslave\unity\build\Runtime/BaseClasses/BaseObject.h Line: 873)

Resulting Callstack:
>   UnityPlayer.dll!PPtr<Avatar>::operator Avatar *() Line 206   C++
   UnityPlayer.dll!Animator::IsHuman() Line 2436   C++
   UnityPlayer.dll!Animator::SetupPlayableConstant() Line 1239   C++
   UnityPlayer.dll!Animator::PostProcessTopologyChangeMultithreaded(const FrameData & frameData, Playable * root, int outputPort) Line 3801   C++
   UnityPlayer.dll!DirectorManager::PrepareFrameFunc(DirectorJob * jobs, unsigned int index) Line 232   C++
   UnityPlayer.dll!JobQueue::ExecuteJobFunc(JobInfo * info) Line 357   C++
   UnityPlayer.dll!JobQueue::Exec(JobInfo * info, int tag, int count) Line 393   C++
   UnityPlayer.dll!JobQueue::ExecuteJobFromHighPriorityStack() Line 702   C++
   UnityPlayer.dll!JobQueue::ProcessJobs(void * profInfo) Line 805   C++
   UnityPlayer.dll!JobQueue::WorkLoop(void * data) Line 879   C++
   UnityPlayer.dll!Thread::RunThreadWrapper(void * ptr) Line 35   C++
   UnityPlayer.dll!win32::CreateThread::__l2::<lambda>(Windows::Foundation::IAsyncAction ^ __formal) Line 276   C++

Is that of help?
Should I look further?

The second scene we load contains character spawn logic, which then spawns human characters which use the Animator …

A followup question would be: What big issue is it, if the assert fails?
Will this exit/crash the app or will it go on and work?

Thanks!

If I continue often enough, the scene eventually loads …

Yes, this is a huge help! It pinpoints exactly where it’s happening. I’ll ask our animation team whether they’re aware of it and the plans to fix it.

If you switch to release configuration, these shouldn’t bother you anymore. Even when debugging.

That crash from qualcomm DLLs seem unrelated though - do you have callstack for those?

And you’re right, you cannot use mixed mode debugging on phones. Only on x86/x64 targets.

@anon_84956993 issue: Unfortunately, no callstack possible.

As it occurs only in “Debug Native Only” on WP81, I guess it’s not worth further investigating.
Only thing I found was this:

And of course, the PDB is missing …

Missing PDB file will never cause an access violation. That just makes no sense - PDB files are used by debuggers to show you native function names. They aren’t ever deployed to a device or involved in execution.

Do you think you could fill a bug report on that assert? We could probably do a blind fix, but with a repro project we’d be certain that it fixes it on your project.

I’ll put it on my list for next week!

@Tautvydas-Zilys I submitted the bugreport.
It should help you reproduce both bugs in this thread:

  1. The animator issue.
  2. The Qualcomm issue.

Curious if you can find anything in 2) … left me rather clueless.

Got the case number?

Sorry, I missed that one: (Case 875860) Access violation in qcdx9um8960.dll

FYI ran into this today with the Windows Store port of my app (Unity 5.6.2)
Occurs immediately after a bundle would finish downloading.

Do you have a callstack for that?

Sadly no. I haven’t quite figured out what the magic dance between Unity and Visual Studio is, but it refuses to use the debugger that it’s already connected to for some reason. Any attempts to detach like it says basically hang. Any ideas?

In the project properties debug tab, you should be able to set the debugger type to “mixed”. That should allow it to catch the exception.

Hello,

I have a similar bug when load prefab with animation from bundle

This is call stack

Assertion failed: Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
0x00000001411B000B (Unity) StackWalker::GetCurrentCallstack
0x00000001411B288F (Unity) StackWalker::ShowCallstack
0x000000014108CA30 (Unity) GetStacktrace
0x0000000140596DA3 (Unity) DebugStringToFile
0x0000000140597581 (Unity) DebugStringToFile
0x00000001415F8D3F (Unity) AnimationClip::BuildMecanimDataMainThread
0x00000001415F9E03 (Unity) AnimationClip::Transfer<StreamedBinaryRead<0> >
0x00000001416007ED (Unity) AnimationClip::VirtualRedirectTransfer
0x00000001409A7B38 (Unity) SerializedFile::ReadObject
0x000000014098DE9F (Unity) PersistentManager::ReadAndActivateObjectThreaded
0x000000014098FEDA (Unity) PersistentManager::LoadObjectsThreaded
0x00000001406B876E (Unity) LoadOperation::Perform
0x00000001406B8A90 (Unity) PreloadManager::ProcessSingleOperation
0x00000001406B8BFD (Unity) PreloadManager::Run
0x00000001406B9867 (Unity) PreloadManager::Run
0x00000001407B4138 (Unity) Thread::RunThreadWrapper
0x00007FF9D2B82774 (KERNEL32) BaseThreadInitThunk
0x00007FF9D5540D51 (ntdll) RtlUserThreadStart

Hey guys,

I’m having a very similar issue with loading multiple asset bundles at once. There’s no call stack either. I had trouble finding the project properties debug tab to change the debugger type to “mixed”. Can you elaborate?

Can we get a bug report on this?

Right here, where it says Application Process: https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/images/debug-remote-machine-config.png