Search Unity

Bug UpdateNavMeshDataAsync: JobTempAlloc Lifespan of 4 frames / ScheduleJobForEach<BuildNavMeshInfo>

Discussion in 'Navigation' started by WBonX, Jan 12, 2023.

  1. WBonX

    WBonX

    Joined:
    Aug 7, 2018
    Posts:
    61
    Hello, here on Unity 2022.2.1f, navigation package installed 1.1.1.

    Recently I started getting this error, seems it doesn't affect the editor (even if the error/warning is in the log) but in the Windows Build blocks the navmesh from being updated.

    The line of code itself is just an UpdateNavMeshDataAsync, worked perfectly until recently and has not been changed in the past 6 months.
    NavMeshBuilder.UpdateNavMeshDataAsync(...);

    This is the error, I turned on some diagnostic to debug the leak.

    Code (CSharp):
    1. Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 9)
    2. Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak
    3. To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
    4. Allocation of 512 bytes at 4056c880 in block 1 (frameIndex=8, lifetime=4, age=4, state=OK)
    5. 0x00007ff79c5da422 (Unity) ujob_schedule_parallel_for_internal
    6. 0x00007ff79c5da2cc (Unity) ujob_schedule_parallel_for
    7. 0x00007ff79c5d7919 (Unity) JobQueue::ScheduleJobsForEach
    8. 0x00007ff79c5d632d (Unity) ScheduleJobForEachInternal
    9. 0x00007ff79cc8f208 (Unity) ScheduleJobForEach<BuildNavMeshInfo>
    10. 0x00007ff79cc93f1d (Unity) ClassifyTilesAndComputeMeshJob
    11. 0x00007ff79cc8e847 (Unity) AggregateJobCombineFunc<BuildNavMeshInfo>
    12. 0x00007ff79c5d99a8 (Unity) ujob_execute_job
    13. 0x00007ff79c5d9007 (Unity) lane_guts
    14. 0x00007ff79c5daeb4 (Unity) worker_thread_routine
    15. 0x00007ff79c7f2ff7 (Unity) Thread::RunThreadWrapper
    16. 0x00007ffa6c1e74b4 (KERNEL32) BaseThreadInitThunk
    17. 0x00007ffa6dda26a1 (ntdll) RtlUserThreadStart
    18. 01 00 00 00 07 00 00 00 02 00 00 00 00 00 00 00  ................
    19. c0 c8 56 40 a4 02 00 00 a1 26 da 6d fa 7f 00 00  ..V@.....&.m....
    20. 00 00 00 00 00 00 00 00 00 00 00 00 43 22 fd 3f  ............C".?
    21. 46 5f 2c bf e7 d5 12 bf 00 00 00 00 06 3f b1 3f  F_,..........?.?
    22. 02 00 00 00 02 00 00 00 09 00 00 00 00 00 00 00  ................
    23. 00 c9 56 40 a4 02 00 00 c8 d2 ad 3f 00 00 00 00  ..V@.......?....
    24. 00 00 00 00 00 00 00 00 00 00 00 00 43 22 fd 3f  ............C".?
    25. 46 5f 2c bf e7 d5 12 bf 00 00 00 00 06 3f b1 3f  F_,..........?.?
    26. Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 11)
    27. Processing queue in navmesh left are : 2 blockall is: False
    28. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    29. UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
    30. UnityEngine.Logger:Log (UnityEngine.LogType,object)
    31. UnityEngine.Debug:Log (object)
    32. LocalNavMeshBuilder:Done (UnityEngine.AsyncOperation) (at Assets/LocalNavMeshBuilder.cs:177)
    33. LocalNavMeshBuilder:Update_AsynchMode (System.ValueTuple`2<UnityEngine.Bounds, NavMesh_Target>) (at Assets/LocalNavMeshBuilder.cs:169)
     
    mmcveigh33, OndrejP and Mikael-H like this.
  2. WBonX

    WBonX

    Joined:
    Aug 7, 2018
    Posts:
    61
    Wondering if this is also related to:
    UnityEngine.StackTraceUtility:ExtractStackTrace ()

    But also:
    0x00007ff79cc8e847 (Unity) AggregateJobCombineFunc<BuildNavMeshInfo>
     
  3. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Did you find a fix for this?
     
  4. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    is there a bug report for this BTW?
     
  5. WBonX

    WBonX

    Joined:
    Aug 7, 2018
    Posts:
    61
    Hi, sorry for the late answer, at the end the error wasn't really affecting the navmesh.
    I guess it is something internal related to the job system / internal task checks.. but since no one from unity is replying I stopped paying attention to it.

    My project seems to be unaffected at the moment.
     
  6. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    304
    There are two problems with this:
    1. It's spamming into log file
    2. If other similar issue appears, we won't know about it
      (we will think it's NavMesh, until we run the game with leak detection)
    So could we please fix this somehow?
    I'd be okay with per-project setting: FrameCount when JobTempAlloc is considered leak, I'd just put something like 20 and it would be resolved.
     
  7. OliverTheLove

    OliverTheLove

    Joined:
    Jun 26, 2016
    Posts:
    24
    I seem to be having this issue as well, and I can confirm that it happens when I call an update on the navmesh surface. It only seems to be happening on some specific scenes, and I haven't figured out why yet. But is 100% in one of the scenes.

    myNavmeshSurface = GetComponent<NavMeshSurface>();
    ...
    myNavmeshSurface.UpdateNavMesh(myNavmeshSurface.navMeshData);


    I have not yet updated to the never navmesh system. Could that be the reason?
    Using Unity 2022.3.0f1 - AI Navigation 1.1.3.
     
  8. Liakos89

    Liakos89

    Joined:
    Nov 27, 2016
    Posts:
    17
    Also have same exact issue with UpdateNavMeshDataAsync
    I basicly took it from one of the unity git with nav components examples project

    AI Navigation package version 1.1.4
    Capture23.PNG
     
    Last edited: Jun 28, 2023
  9. Rodakai

    Rodakai

    Joined:
    Apr 3, 2014
    Posts:
    9
    I have the same issue, would be great if anyone has a solution for this.
     
  10. Liakos89

    Liakos89

    Joined:
    Nov 27, 2016
    Posts:
    17
    For the 1.1.4 I guess it is handled by the garbage collector, so its not breaking when compiled but its creating garbage most possibly

    Until someone from Unity replies, I would consider a custom solution, because at least if it bugs somewhere I could intervene and fix it. With the unity package I cant do anything.

    Btw the AI Navigation has a version of 2.0 in Unity 2023, but I havent tried it
     
  11. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    Did anyone file a bug report about this? If so can you share the bug ID with me?
     
    Liakos89 likes this.
  12. Liakos89

    Liakos89

    Joined:
    Nov 27, 2016
    Posts:
    17
    Thanks for coming in, I havent made a bug report.

    I think you can dublicate it 100% from the git sample project of AI Navigation, at the example with the Mesh Deformation, where it uses the async baking.

    Could you see over it or a bug report is needed aswell?
     
  13. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    I think I reproduced it - without a repro from you I can't guarantee that what I've seen is your issue exactly, but I think it's likely. A fix is already en route to 2022.3.8, 2023.1.9, 2023.2.0b5, and 2023.3.0a1.
     
    Last edited: Aug 8, 2023
    Liakos89 likes this.