Search Issue Tracker
Third Party Issue
Votes
0
Found in
2021.2
2021.2.0b1
Issue ID
1345549
Regression
No
Deserialization of object is very costly in RestoreBackups -> RebuildManagedInstance during Domain Reload
Reproduction steps:
1. Open attached project "bug_report.zip" and scene "TemplateScene"
2. In Preferences window, enable Diagnostics -> Core -> EnableDomainReloadTimings
3. In Hierarchy window, select "Player" GameObject
4. In Inspector window, open PlayerController.cs component
5. In script editor, make some small change to the script
6. In Profiler window or Editor.log Performance entries, observe the time taken by RestoreBackups -> RebuildManagedInstance
Expected result: The time taken by RebuildManagedInstance is small (<100ms)
Actual result: The time taken by RebuildManagedInstance is significant (>150-1000ms)
Reproducible with: 2021.2.0b3
Could not test with: 2019.4.29f1, 2020.3.14f1, 2021.1.14f1 (no RebuildManagedInstance in Profiler Hierarchy), 2022.1.0a2 (project crashes while opening)
Workaround:
Moving parameters to a separate ScriptableObject fixes the issue, more context here - https://forum.unity.com/threads/any-update-regarding-increased-script-assembly-reload-time.1117138/#post-7236887
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
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- Crash with “Fatal Error! The file ‘MemoryStream’ is corrupted!” when adding a large number in Font Character Rects Size field
Resolution Note (2022.1.X):
Based on the Diagnostic output the performance cost appears to come from the initialization of static XmlSerializer inside PlayerParameters, each time PlayerController is recreated. When that variable is left as null the RebuildManagedInstance cost disappears. That library is part of .net and not Unity, so we cannot directly speed it up, but perhaps it would be possible to improve domain reload speed by making the initialization on-demand rather than happening each time the assembly is reloaded.