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
- Depth of Field doesn't apply correctly to Canvas UI when it is set to World Space Render Mode
- Crash on GetElementMapKey when "None" is assigned to a field with binding path "m_GameObject"
- Stereoscopic skybox renders as monoscopic when using Multi-pass render mode in XR plugin while using URP
- Parameterized Tests with ValueSource fail when supplied parameter is an System.Object
- Error Message "Broken text PPtr in file" is not informative enough to locate the problematic asset
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