Unity 2022.3.2f1 URP - Render Texture from Camera is crashing the application

Hey,

We’re busy developing a VR application for the Meta Quest 2.
So we recently upgraded a project of ours to Unity 2022.3.2f1 URP + Android from Unity 2021.3 URP + Android.

We have a scene that passed QA a while back and had no issues in Unity 2021.
But after we upgraded this specific scene started crashing out of the blue.
After disabling game objects, we’ve narrowed it down exactly to the Camera that is outputting to a Render Texture, and confirmed it by only disabling that Camera and then no crashes occur.

As soon as we enable the Camera it continues playing for about 20 seconds and then the application crashes.
Looking at the performance logs of the Quest 2, the FPS drops from 72FPS down to 42FPS.
The CPU usually running at 60%-70% is not maxing out at 100% just before it crashes.

The headset then throws a “Not enough memory to run application” error.

I get the feeling that there’s a memory leak on the Camera output to the render texture, but I have no idea how to address it.
There is no code involved.
It’s just placing the camera in scene, and connecting the render texture as output.
The Render Texture is then used on a URP/Unlit material.

The Camera:
I’ve also tried setting the culling mask to a layer only containing the 2 meshes that it would ever be able to see.
1x 2D Unity Plane (512 texture)
1x 80Poly Sphere (2048 texture)
There is no Skybox, so I’ve also tried setting that to be a solid color.

The Render Texture:
I’ve tried setting Depth Stencil Format to None as well.
It didn’t make a difference.
Also tried dropping the resolution down to 128 x 128, also didn’t make a difference.

The Material:

This was working fine in Unity 2021.3.x URP.
We haven’t made any changes to this scene.

I will test in a empty blank Unity scene, and upload the results here as well.

EDIT 1:
Tested in a blank Unity Scene with only the XR Rig.
The application still crashes after about 20 seconds, same settings as above.

EDIT 2:
Replicated the issue in a brand new Unity 2022.3.2f1 URP + Android application.
Install Oculus Integration and applied recommended settings.
Added a Camera and Render Texture to the scene, built, and got the exact same issue.

2 Likes

Hi! I encoutered the same bug but no solution yet with Unity 2022.3.3f1. It seems to be an acknowledged bug : Unity Issue Tracker - A memory leak occurs in the Player when Two Cameras are used and one of them has an "Output Texture" set

Very frustrating because it is something that I use in all my projects

1 Like

Hey! We are aware of some memory leak issues caused by RTHandles in 22 LTS and we are working on a fix, if you can report a bug with a simple repro case then we can make sure that is the same issue and verify the fix

Thanks!

3 Likes

Hey! Just released a bug report (IN-45663). It is very similar to the one I linked earlier, might be a duplicate.
Very simple to reproduce in Unity 2022.3.3f1: in a fresh URP 3D project, create a second camera that outputs to a render texture, create a cube that uses the render texture as albedo, build this as a Developpment Build and monitor it with Unity Standalone Profiler to see the memory leak. Hope it helps !

2 Likes

Quick update, my bug report got checked and reviewed. It is indeed a duplicate of the previous bug.

1 Like

Hello! Is there any news or workaround for this bug?
I see that the first bug report has also been identified as a duplicate of an older one. This “root” bug is dated from November 2022, so it has been almost 9 months since it was first reported. I understand that bugs can be hard to track down, but it is a major issue for my project and I need to know if it will still be there for another 6 months or not.
If you have any tips, I take them,
Thanks

Hello also following up as I seem to be getting this issue now too after I updated to Unity 2022.3.1f1 (tested up to 3.4 and still the same issue).

Is there a fix in the works, is there any workaround? This is a bit of a showstopper currently, and it would be great to get some insight from Unity.

1 Like

Same issue here in 2022.3.4f1 and 2022.3.5f1 using URP.

1 Like

Hey, I just want to give an update on the fix.

We have prepared the code changes. I am addressing couple last issues and working on land the fix to trunk soon(also added test to prevent future regression like this). My estimate is the trunk change will land by EOW.
I will backport the relevant fix to 22.3/staging once it lands.

Thanks

9 Likes

@ThomasZeng can not stress how much I appreciate this update.

I understand that software dev is complex and bugs like this occur. That said, I also think it’s extremely helpful and important to keep us devs in the loop, so we plan and work around these issues.

Looking forward to the fix, and thanks for the hard work on getting this rolled out ASAP.

Yes, this is quite the relief knowing this is finally being addressed! Thank you for the update!

@ThomasZeng Thank you so much for tackling this issue quickly.

We were worried about the timeline for a fix, and started developing a work around.
Glad to see that we don’t need to spend more time on finding a solution though.

@ThomasZeng just curious if you have an update on when the fix will be out.

Thanks in advance!

Sorry to be a pest but I’m really hoping for an ETA on the fix. This bug is a show stopper for us and I’m trying to decide if we should work on a more permanent workaround.

Thanks in advance!

Hi, same problem for me @ThomasZeng or @ManueleB , do you have any update on the bug ? Thanks

1 Like

Want to once again follow up on this issue, in order to assess if it’s gotten pushed to the wayside.

As far as the bug ticket goes, it still says “Active”, and not “In Progress”. @ThomasZeng did say that the code changes were prepared, though, so I’m trying to assess if the ticket status is out of date or if there were issues with the fix.

I (and I believe others) would really appreciate a status update on this, as this bug report looks to be one of the highest voted Active bug reports currently.

If there is anything I can do to help move this issue forward, please let me know. At this juncture, I’m just looking for some clarity, though.

Thank you in advance!

1 Like

Hi, I will continue upping this thread. Does anybody has any news or found any workaround ? @ThomasZeng @ManueleB
Deadlines are coming for me so I really need answers …
Also I don’t understand how it is possible to not be able to use 2 cameras in Unity URP for so long, it has been there for almost 10 months … Isn’t it a big enough bug?
Thanks,

Hello there @ThomasZeng @ManueleB

Any update? I have been waiting for a few months for the correction and I have my project to send ASAP.

Thanks
I look forward to your reply
Jérémy

2 Likes

I have this bug on the PC build. I have a minimap that is updated when a player does some actions. Some players report crashes. They get this in the logs:

D3D11: Failed to create RenderTexture (2560 x 1600 fmt 27 aa 1), error 0x887a0005

And then a crash.

Any news on the fix?

1 Like

I am experiencing the bug on 2022.3.8f1, but not on 2022.3.4f1. I tried some workarounds but the issue seems to be embedded deep in the RenderTexture code. I think it’s a problem specifically with RenderTextures and not with the Camera, but I haven’t scoured the DirectX code (and I’m not very skilled) so maybe I’m wrong.

If your project uses URP with RenderTextures then I don’t see any reason to use future Unity versions until this bug has been resolved. I’m very surprised this made it past Unity’s unit tests.

1 Like