Vulkan UseTexture() and CreateResource() crashes

It seems we are getting multiple crashes related to Vulkan.

Are these known errors? I have no idea what is causing them as it happens at different times, after playing for a while.

We don’t get any crashes on GL ES, but consistent crashes on Vulkan. We would really like to use Vulkan though for the performance benefits.

Native StackTrace:

Thread 0 (crashed)
0   libunity.so                        0x00000070f6e0954c vk::Texture::UseTexture(vk::CommandBuffer*, unsigned int, VkSampler_T*) const
1   libunity.so                        0x00000070f6e16430 vk::smile:escriptorState::BindTexture(vk::Texture*, unsigned int, vk::CommandBuffer*)
2   libunity.so                        0x00000070f6e3f0d8 VKImmediateContext::SetTextures(int, GfxTextureParam const*, vk::ImageManager&, vk::CommandBuffer*)
3   libunity.so                        0x00000070f6f4c090 GpuProgram::ApplyTextureParameters(unsigned char const*, GfxDevice&, ShaderType)
4   libunity.so                        0x00000070f6de82a0 VKGpuProgram::ApplyGpuProgram(GpuProgramParameters const&, vk::ConstantBufferState&, unsigned char const*, vk::PreTransform)
5   libunity.so                        0x00000070f6e3ef4c VKImmediateContext::SetShaders(vk::FrameNumbers const&, VKGpuProgram*, GpuProgramParameters const*, unsigned char const*)
6   libunity.so                        0x00000070f6c4d244 ShaderLab::ShaderState::ApplyShaderState(unsigned int, ShaderPropertySheet const*, ShaderPassContext const&, ShaderKeywordSet const&, Shader*, ShaderLab::Pass*, bool*, ShaderLab::SubPrograms*, DeviceRenderStateBlock const*, int, int) const
7   libunity.so                        0x00000070f6c4d058 ShaderLab::Pass::ApplyPass(unsigned int, ShaderPropertySheet const*, ShaderPassContext&, Shader*, int, int, bool*, ShaderLab::GrabPasses const*, ShaderLab::SubPrograms*, DeviceRenderStateBlock const*)
8   libunity.so                        0x00000070f6c20cd8 ApplyMaterialPassWithCache(SharedMaterialData const&, ShaderPassContext&, Shader*, ShaderLab::Pass*, int, int, bool, ShaderLab::GrabPasses const*, ShaderLab::SubPrograms*, DeviceRenderStateBlock const*)
9   libunity.so                        0x00000070f6c20d7c ApplyMaterialPassAndKeywordsWithCache(SharedMaterialData const&, ShaderPassContext&, Shader*, ShaderLab::Pass*, int, int, bool, ShaderLab::GrabPasses const*, ShaderLab::SubPrograms*, DeviceRenderStateBlock const*)
10  libunity.so                        0x00000070f6eccc98 BatchRenderer::ApplyShaderPass(ShaderPassContext&, SharedMaterialData const*, Shader*, BatchRenderer::PassInfo&, BatchingFlags, bool, bool, ShaderLab::GrabPasses const*, DeviceRenderStateBlock const*)
11  libunity.so                        0x00000070f6ed1120 ForwardShaderRenderLoop::StartRenderJobs(JobFence&, bool, bool, ShaderPassContext&)
12  libunity.so                        0x00000070f6dfa5b8 GfxDeviceVKBase::ExecuteAsyncSetup(GfxDeviceAsyncCommand*)
13  libunity.so                        0x00000070f6befc14 JobQueue::Exec(JobInfo*, long long, int, bool)
14  libunity.so                        0x00000070f6beff14 JobQueue::ExecuteJobFromHighPriorityStack(bool)
15  libunity.so                        0x00000070f6bf00f8 JobQueue::ProcessJobs(JobQueue::ThreadInfo*, void*)
16  libunity.so                        0x00000070f6bef660 JobQueue::WorkLoop(void*)
17  libunity.so                        0x00000070f6c85644 Thread::RunThreadWrapper(void*)
18  libc.so                            0x00000071ebe797b8 <symbols missing for uuid: 2499da84be20422da3f6f4b7cdc59990>
19  libc.so                            0x00000071ebe19050 <symbols missing for uuid: 2499da84be20422da3f6f4b7cdc59990>
Native StackTrace:

Thread 0 (crashed)
0   libunity.so                        0x00000077cbb67e84 vk::smile:ataBuffer::CreateResource()
1   libunity.so                        0x00000077cbb68640 vk::smile:ataBuffer::Update(void const*, vk::CommandBuffer*, vk::ScratchBuffer*, vk::FrameNumbers const&, unsigned long, unsigned long)
2   libunity.so                        0x00000077cc0e9994 GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)
3   libunity.so                        0x00000077cc0ed694 GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)
4   libunity.so                        0x00000077cc0e53cc GfxDeviceWorker::RunGfxDeviceWorker(void*)
5   libunity.so                        0x00000077cb9b7644 Thread::RunThreadWrapper(void*)
6   libc.so                            0x0000007b53ef2e94 <symbols missing for uuid: 0f39fc790debeef5bc191987ab30a3f5>
7   libc.so                            0x0000007b53e8f4b0 <symbols missing for uuid: 0f39fc790debeef5bc191987ab30a3f5>

What Unity version?
If you are on the latest available 2020 or 2021 lts make a big report for the crash

2020.3.36. This is the only report we get (from the Unity Dashboard).

If it’s 1 user it might just be bad drivers or a random crash

I wish that were the case, but it happens from multiple people on different devices, and I really doubt it is bad drivers. Probably just a buggy unity implementation. It’s a pretty new flagship device. Snapdragon 865+

I can’t remember seeing a crash in UseTexture. You could try to disable GraphicsJobs.

Crashes in DataBuffer::CreateResource were fairly common but mainly in Editor and in general when running low on GPU memory.
Probably not exactly what you have.

Just wanted to follow up and say that did appear to fix the issue, thanks!

I meet the same crash 2020.3.40

If you can reproduce make a bug report

I might have the same crash with unclear error log in 2021.2 and 21.3. But graphics jobs don’t help. I simply switch from DX11 to Vulkan and my editor crashes at start 100% of the time in a large scene. Works in a tiny scene though.
It looks like Vulkan doubles my RAM and VRAM usage compared to DX11 so this might be the cause. I submitted a report but couldn’t attach my 100GB project.

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

0x00007FF7B164B684 (Unity) vk::smile:ataBuffer::CreateResource
0x00007FF7B164D423 (Unity) vk::smile:ataBuffer::Initialize
0x00007FF7B161503A (Unity) GfxDeviceVK::InitializeBufferInternal
0x00007FF7B2B0B0E3 (Unity) GfxDeviceWorker::RunCommand
0x00007FF7B2B0E0BD (Unity) GfxDeviceWorker::RunExt
0x00007FF7B2B0E1D8 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
0x00007FF7B1222EC7 (Unity) Thread::RunThreadWrapper
0x00007FFBC85A7034 (KERNEL32) BaseThreadInitThunk
0x00007FFBC9BC26A1 (ntdll) RtlUserThreadStart

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

I was told that this is the bug but the fix is only available in 2022.2 beta.

same issue at 2022.3.8f

How to deal with low GPU memory issue.
Any way to get the current usage and limit at runtime.