Search Unity

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

Discussion in 'Windows' started by mr_zog, Jan 27, 2017.

  1. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    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
     
    iso likes this.
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    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.
     
  3. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Thanks, I'll look into it right away ...
     
  4. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    WP8.1:
    Native Only:
    About every Frame:
    Code (csharp):
    1. Exception thrown at 0x711F8F0F (qcdx9um8960.dll) in Sniper Ops 3D.exe: 0xC0000005: Access violation reading location 0x103D803C.
    2. Unhandled exception at 0x711F8F0F (qcdx9um8960.dll) in Sniper Ops 3D.exe: 0xC0000005: Access violation reading location 0x103D803C.
    Side noted that issue before here btw:
    https://forum.unity3d.com/threads/w...pgrading-from-5-3-7-custom-to-5-5-0p3.450865/


    Managed Only:
    I only get this:
    Code (csharp):
    1. Load Level Async progress:0,9
    2. Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
    3. (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:
    Code (csharp):
    1.  
    2. Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
    3. (Filename: C:\buildslave\unity\build\Runtime/BaseClasses/BaseObject.h Line: 873)
    4.  
    5. Resulting Callstack:
    6. >   UnityPlayer.dll!PPtr<Avatar>::operator Avatar *() Line 206   C++
    7.    UnityPlayer.dll!Animator::IsHuman() Line 2436   C++
    8.    UnityPlayer.dll!Animator::SetupPlayableConstant() Line 1239   C++
    9.    UnityPlayer.dll!Animator::PostProcessTopologyChangeMultithreaded(const FrameData & frameData, Playable * root, int outputPort) Line 3801   C++
    10.    UnityPlayer.dll!DirectorManager::PrepareFrameFunc(DirectorJob * jobs, unsigned int index) Line 232   C++
    11.    UnityPlayer.dll!JobQueue::ExecuteJobFunc(JobInfo * info) Line 357   C++
    12.    UnityPlayer.dll!JobQueue::Exec(JobInfo * info, int tag, int count) Line 393   C++
    13.    UnityPlayer.dll!JobQueue::ExecuteJobFromHighPriorityStack() Line 702   C++
    14.    UnityPlayer.dll!JobQueue::ProcessJobs(void * profInfo) Line 805   C++
    15.    UnityPlayer.dll!JobQueue::WorkLoop(void * data) Line 879   C++
    16.    UnityPlayer.dll!Thread::RunThreadWrapper(void * ptr) Line 35   C++
    17.    UnityPlayer.dll!win32::CreateThread::__l2::<lambda>(Windows::Foundation::IAsyncAction ^ __formal) Line 276   C++
    18.  
    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!
     
  5. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    If I continue often enough, the scene eventually loads ...
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    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.
     
  7. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    @qualcomm 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:
    http://stackoverflow.com/questions/18659060/how-to-interpret-this-stack-trace
    And of course, the PDB is missing ...
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    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.
     
  9. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    I'll put it on my list for next week!
     
  10. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    @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.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Got the case number?
     
  12. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Sorry, I missed that one: (Case 875860) Access violation in qcdx9um8960.dll
     
  13. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    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.
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Do you have a callstack for that?
     
  15. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    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?

     
    Last edited: Aug 22, 2017
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    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.
     
  17. DziDAI

    DziDAI

    Joined:
    Dec 6, 2012
    Posts:
    68
    Hello,

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

    This is call stack
    Code (CSharp):
    1. Assertion failed: Assertion failed on expression: 'Thread::CurrentThreadIsMainThread()'
    2. 0x00000001411B000B (Unity) StackWalker::GetCurrentCallstack
    3. 0x00000001411B288F (Unity) StackWalker::ShowCallstack
    4. 0x000000014108CA30 (Unity) GetStacktrace
    5. 0x0000000140596DA3 (Unity) DebugStringToFile
    6. 0x0000000140597581 (Unity) DebugStringToFile
    7. 0x00000001415F8D3F (Unity) AnimationClip::BuildMecanimDataMainThread
    8. 0x00000001415F9E03 (Unity) AnimationClip::Transfer<StreamedBinaryRead<0> >
    9. 0x00000001416007ED (Unity) AnimationClip::VirtualRedirectTransfer
    10. 0x00000001409A7B38 (Unity) SerializedFile::ReadObject
    11. 0x000000014098DE9F (Unity) PersistentManager::ReadAndActivateObjectThreaded
    12. 0x000000014098FEDA (Unity) PersistentManager::LoadObjectsThreaded
    13. 0x00000001406B876E (Unity) LoadOperation::Perform
    14. 0x00000001406B8A90 (Unity) PreloadManager::ProcessSingleOperation
    15. 0x00000001406B8BFD (Unity) PreloadManager::Run
    16. 0x00000001406B9867 (Unity) PreloadManager::Run
    17. 0x00000001407B4138 (Unity) Thread::RunThreadWrapper
    18. 0x00007FF9D2B82774 (KERNEL32) BaseThreadInitThunk
    19. 0x00007FF9D5540D51 (ntdll) RtlUserThreadStart
     
  18. wgamestom

    wgamestom

    Joined:
    May 25, 2017
    Posts:
    3
    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?
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    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