Search Issue Tracker
By Design
By Design in 2.2.X
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
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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Redoing creation of Sub Scenes and Cube GameObjects in Hierarchy throws “Assertion failed on expression: 'targetScene != nullptr’” error in Console window
- Selecting “New Sub Scene” after assigning “New Scene” in Sub Scene Script Component throws “Destroying GameObjects immediately is not permitted” in the Console window
- Shader Graph "Zoom Step Size" can be set to 0 even though the zoom still works
- Enabling/Disabling the Deprecated Nodes doesn't apply to the opened Shader Graph unless any Variable is added to the Blackboard
- Group Selection title text size is smaller in renaming than the actual font size
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.
Resolution Note (2.2.X):
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.