Search Issue Tracker

By Design

Votes

0

Found in [Package]

1.22.2

2.2.2

Issue ID

ADDR-3787

Regression

No

Error "Releasing render texture that is set as Camera.targetTexture!" when releasing Prefab that has Camera and is loaded with Addressable

Package: Addressables

-

Reproduction steps:
1. Open the attached project "ReproProj"
2. Build and Run “Scenes/SampleScene”
3. Observe the Player

Expected result: No Errors exist
Actual result: Error “Releasing render texture that is set as Camera.targetTexture!” appears

Reproducible with: 1.22.2 (2021.3.44f1), 2.2.2 (2022.3.49f1, 6000.0.22f1)

Reproducible on:
Windows Standalone Player

Not reproducible on:
Play Mode

Testing environment: Windows 10 Enterprise 21H2
Not reproducible on: No other environment tested

Notes:
- If the RenderTexture was also made addressable, the Error could have been avoided
- If TargetTexture is None, the previous Error does not occur.
- Users experiencing same issue: [https://issuetracker.unity3d.com/issues/android-releasing-render-texture-that-is-set-as-camera-dot-targettexture-error-when-calling-resources-dot-unloadunusedassets]

Workaround:
1. Open Window > Asset Management > Addressables > Groups in the Unity menu.
2. Drag And Drop the Assets\Resources_moved\RenderTexture to Packed Assets.
3. Build > New Build > Default Build Script
4. Build And Run

  1. Resolution Note:

    The underlying bug has been resolved, but I wanted to just put in a quick note. In the original implementation the rendertexture is implicitly included in the same asset bundle as the prefab. When the prefab is unloaded we do not unload the texture first because it's not an addressable dependency. This uses the default engine behavior to unload the object, which led to the non-deterministic behavior that was observed and fixed.

    This workaround works because the render texture becomes a dependency of the prefab in a separate bundle. When the prefab is destroyed, before destroying it all its dependencies are unload and destroyed first. This makes sure the texture is always unloaded before the camera in the prefab solving the problem.

    So it is a valid workaround and should give you deterministic behavior.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.