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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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