How to debug the error "Assertion failed on expression: 'm_BufferData.capacity() >= m_WriteOffset + bytesWritten'"?
Asked Answered
J

2

0

Apologies for the long post, this is my first stackoverflow post and I’m not sure how to fix this assertion error, so I’ve provided as much detail as I can.

I’m using LTS 2021.3.26f1 (the footage attached is from version LTS 2021.3.25f, but the issues still appear in the version I’m using now with no difference).

There are no script-specific stack traces tied to this error - this is an example of what is displayed with full stack traces enabled:

0x00007ff770d44ccd (Unity) StackWalker::GetCurrentCallstack
0x00007ff770d4b889 (Unity) StackWalker::ShowCallstack
0x00007ff771ccd693 (Unity) GetStacktrace
0x00007ff77237dd0d (Unity) DebugStringToFile
0x00007ff77237da32 (Unity) AssertImplementation
0x00007ff770e7fb51 (Unity) GfxDeviceGLES::EndBufferWrite
0x00007ff770b835af (Unity) GeometryJobTasks::PutGeometryJobTaskInternal
0x00007ff770b83551 (Unity) GeometryJobTasks::PutGeometryJobTask
0x00007ff770b82191 (Unity) GeometryJobTasks::EndFrame
0x00007ff772403e9f (Unity) GfxDeviceWorker::RunCommand
0x00007ff77240e43b (Unity) GfxDeviceWorker::RunExt
0x00007ff77240e558 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
0x00007ff770acd867 (Unity) Thread::RunThreadWrapper
0x00007ff9eea47614 (KERNEL32) BaseThreadInitThunk
0x00007ff9f0a226f1 (ntdll) RtlUserThreadStart

I’m using the A* Pathfinding Project by Aron Granberg if that helps. There are no exceptions in my code and the A* pathfinding package is functioning properly. The game is using URP. This issue has only begun about 2 or 3 weeks ago when I added code that drew a lineRenderer based off an array of positions from a calculated path using the A* Pathfinding Project.

It seems to affect LineRenderers, TrailRenderers, and UI. Past incidences where it has appeared while I still had LineRenderers display within the game with code that drew the line based off of a Vector3 list of positions have caused the LineRenderer to expand and flash rapidly, like this and deform in weird ways like this.

Sometimes attempting to add further TrailRenderers or LineRenderers with no code attached to them causes the assertion failure, especially if the project has been open for longer than around 10 to 20 minutes. Even creating new files (like adding a .png file to the Assets folder) and opening and editing prefabs seem to be a good way to cause the assertion failure.

Editing any prefab seems to cause this assertion failure - it doesn’t matter what kind of components it has, how many children the prefab gameObject has, etc., editing any prefab causes the UI to blink and jitter.

When I use the Profiler to look at what’s being called, I notice GUIView.RepaintAll.PlayerLoopController spikes in the GPU and something related to that in the CPU profiler. I will update this part with more detail when I work on the project again and get the assertion failure, because I didn’t get a screenshot of the Profiler when the assertion failure occured.

Furthermore using the search function in the hierarchy makes the assertion failure occur again once it’s happened while editing a prefab. At a certain point it causes the editor to crash. This is the outputted stack trace from the most recent crash:

    ========== OUTPUTTING STACK TRACE ==================

0x00007FF770E72978 (Unity) BufferGLES::EnsureBuffer
0x00007FF770E7FB6B (Unity) GfxDeviceGLES::EndBufferWrite
0x00007FF770B83596 (Unity) GeometryJobTasks::PutGeometryJobTaskInternal
0x00007FF770B83551 (Unity) GeometryJobTasks::PutGeometryJobTask
0x00007FF770B82191 (Unity) GeometryJobTasks::EndFrame
0x00007FF772403E9F (Unity) GfxDeviceWorker::RunCommand
0x00007FF77240E43B (Unity) GfxDeviceWorker::RunExt
0x00007FF77240E558 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
0x00007FF770ACD867 (Unity) Thread::RunThreadWrapper
0x00007FF9EEA47614 (KERNEL32) BaseThreadInitThunk
0x00007FF9F0A226F1 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

Restarting Unity always fixes the problem and I can do things like add TrailRenderers and edit prefabs with no issues, but it ends up coming back after 10 to 20 minutes of editing the scene.

At first I believed this was a shader error however there are already objects with TrailRenderers in the game that are not affected by whatever’s causing the assertion failure, and they use the same shaders as LineRenderers and TrailRenderers that are affected by this error, so I ruled that out as one of the potential causes.

I have tried re-importing the files by deleting the Library folder and upgrading from 2021.2.8f1 to LTS 2021.3.25f and then 2021.3.26f1 to fix the issue but to no avail. I have also tried completely reinstalling Unity and the Unity Hub and resetting my project cache.

I want to be sure that this assertion failure never occurs, so I would like some guidance as to what this assertion failure truly means and how I can make my debugging efforts more specific and effective, because right now most of my efforts is just guesswork.

There aren’t any recent Google results about this specific error and hardly any information so please help I’m at my wits end trying to figure out what’s going on haha.


Johnsson answered 23/6, 2023 at 7:23 Comment(1)

Giving a lot of details about the issue is a sign of diligence and proves you are serious about this. Everyone knowledgeable appreciates that and keeps in high regard.

Boyt
B
0

OpenGL ES is crashing…

… when CPU is pushing data to the GPU.

This is not your fault and other people seem to have found this bug already:

https://forum.unity.com/threads/crash-on-unity-android-after-updating-to-unity-2021-3-26-with-unity-advertising.1442821/

If you have a fully reproducible case of this then consider submitting a bug report

Boyt answered 23/6, 2023 at 17:19 Comment(2)

Thank you so much for providing a potential cause! I want to ask if this applies to both the assertion error AND the crash from editor to desktop? I'll consider submitting a bug report when I find a way to consistently trigger the assertion error. Others on that forum post seem to have fixed it by reverting back to 2021.3.23, but the assertion failure behavior occurred in 2021.2.8f1 which is what I was originally at before upgrading to LTS versions.

Johnsson

Assertions are simply if( will_crash ) throw exception_now; so program state or it's data is not corrupted in more damaging ways. I have no further tips on this topic other than maybe to make a backup copy and experiment with different rendering backends, different Unity editor versions or simply (temporarily) getting rid of the source of this crash - LineRenderer component.

Boyt
J
0

Going off of @Boyt’s answer, removing OpenGLCore from my graphics API list and switching it to either Vulkan or DirectX fixed the problem. Hopefully I can eventually switch back to OpenGL, but this will do for now.

Johnsson answered 2/7, 2023 at 8:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.