Search Issue Tracker
Fixed
Votes
7
Found in
2018.4
2018.4.22f1
2019.4
2020.3
2021.1
2021.2
Issue ID
1253963
Regression
No
Assets are referenced by ManagedStaticReferenced when Scene is unloaded using SceneManager.UnloadSceneAsync
How to reproduce:
1. Open the attached 'UiMaskBug.zip' project
2. Open 'Empty Scene' Scene
3. Enter Play Mode
4. Press 'Load' button in the Game View
5. Press the 'Unload' button in the Game View
6. Open Window > Analysis > Profiler
7. Select Memory module
8. Switch from Simple to Detailed view
9. Select Take Sample Playmode to capture detailed memory usage
10. Expand Assets and Texture 2D dropdowns
Expected result: 'bg' texture is not referenced by ManagedStaticReference and loaded in memory
Actual result: 'bg' is referenced by ManagedStaticReference and loaded in memory
Reproducible with: 2018.4.36f1, 2019.4.29f1, 2020.3.14f1, 2021.1.15f1, 2021.2.0b4
Not reproducible with: 2022.1.0a3
Notes:
- Video of reproduction attached in Edit
- Using UnloadSceneOptions.UnloadAllEmbeddedSceneObjects does not solve the issue
-
Eldirfar
Jul 14, 2020 10:14
Current fix for this is adding this script to every GameObject with UiMask
public class UiMaskReferenceFix : MonoBehaviour
{
private void OnDestroy()
{
var image = GetComponent<Image>();
if (image != null)
{
image.sprite = null;
}
}
}
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
- The Context Menu items are ordered incorrectly
- Audio Mixer does not change volume when lowering volume on an Audio Mixer loaded from AssetBundles
- Error “Value cannot be null. Parameter name: key UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)” thrown and Addressables build fails when "Include in Build" is disabled and using Addressables For Android package
- “error CS0433: The type 'CodeBinaryOperatorType' exists in both 'System.CodeDom and 'System" compilation errors are thrown when opening a specific project
- Metal Vertex Shader warning is being thrown when creating a VR Template Project
Resolution Note:
Not reproducible since 2021.1.10f1, seems to be fixed by unknown PR, which has also been backported and is present in both 2019.4 and 2020.3