Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Releasing render texture that is set to be Camera.targetTexture! since 5.3.4

Discussion in '5.4 Beta' started by spraycanmansam, May 8, 2016.

  1. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Posting this here as not getting much response in the support forum.
    ---

    Hi,

    After upgrading to Unity 5.3.4 we're seeing the error "Releasing render texture that is set to be Camera.targetTexture!" whenever we change anything screen related (resolution, vsync, alt+tab, etc).
    There's no stack or useful information whatsoever but it's obviously obliterating our RenderTextures. This has not happened prior to 5.3.4. So far we've worked around it by disabling and screen changes in-game but this is not ideal and does not stop the problem occuring when alt+tabbing.

    Could anyone shed some further light or solutions to this problem?
    It's quite frustrating for us and our users.

    --
    Cheers,
    Sam
     
  2. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I ran into something similar, but it was when I first went to 5.0.1. The problem seems to be that you "can" legitimately lose the render texture if you do certain things, but it's not always consistent. In my case, it was happening when I set V-Sync on or off. I may just have gotten lucky before 5.x.

    On this page:
    http://docs.unity3d.com/ScriptReference/RenderTexture.html

    It says:

    What I ended up doing was this in an Update():
    Code (csharp):
    1.  
    2.         // If we lose the render texture, recreate it.  Can happen when we set V-sync, full screen, etc.
    3.         if (!ShipComputer.Instance.RenderTex.IsCreated())
    4.         {
    5.             ShipComputer.Instance.RenderTex.Create();
    6.             _uiCamera.targetTexture = ShipComputer.Instance.RenderTex;
    7.         }
    In this case, ShipComputer.Instance.RenderTex is the render texture.

    I had posted a question a while back about whether or not it's a good idea to do that check on every frame, but didn't get a response. It hasn't seemed to have any adverse effects and did fix the issue.
     
  3. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Yeah I've seen this in the documentation but it's curious how it has been working flawlessly prior to 5.3.4.
    We can manage our own render textures fine, but it's a rather large pain to try and manage other assets that use render textures... What's more frustrating is the lack of any information accompanying the error.

    There's a few people experiencing this issue and it doesn't seem like anyone's getting a response from Unity...
     
  4. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Have you run into other assets that don't handle render textures correctly? Kind of curious which ones those are. I haven't run into that myself.

    Since the documentation states that it's expected behavior, I wouldn't hold your breath on a response from Unity.
     
  5. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Just wanted to pop back in and say that this issue seems to have been addressed in the 5.3.5p1 patch notes.
     
  6. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Wow. That's unexpected. It's a little bit confusing though, as the docs imply it's expected behavior. It sure would be nice to get clarification on that. I'd be a bit nervous to remove my check for the render texture getting lost.

    Here's the item from the patch notes:

    "Graphics: Fixed some cases of incorrectly "Releasing Render Texture that is set as Camera.targetTexture", resulting in losing Camera.targetTexture - e.g. in case of device resume after sleep on iOS/Android, context-loss on DirectX or changing Emulation Layer in the Editor."
     
  7. spraycanmansam

    spraycanmansam

    Joined:
    Nov 22, 2012
    Posts:
    254
    Yeah it's a bit confusing. We made sure we had everything in order on our end, checking our rendertextures, but we were still losing them at random on some context-losses (alt+tab, etc). The checks are definitely still necessary, but before the fix it was dropping them unexpectedly even with the checks. Seems to be fixed now!
     
  8. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Ah, I see. I'm still on 5.3.2f1, so maybe I never ran into that particular bug.