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
Comments (1)
-
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
- Shader Graph Create Node window cannot be resized or moved after maximizing and reopening it
- [Usability] Cannot toggle Scene checkboxes using TAB/Enter in Build Profiles’ > Open Scene List
- Installing HDRP package throws Shader Graph validation warning about Exposure node when installed in Universal 3D Template
- ShaderGraph “Create Node” menu’s resize icon overlaps with the menu's scrollbar
- ShaderGraph “Create Node” menu’s Search bar's typing cursor is barely visible since it's black on a dark background
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