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
- The search icon in the "Searches" sections is blurry and inconsistent
- "RenderingCommandBuffer" error is thrown when switching to the tvOS platform
- Left side cog menu button is obstructed by the maximum Y value of the graph when editing a curve in the Particle System Curves
- "Property exceeds previous array size (64 vs 32)." warnings are thrown when switching from tvOS platform to a Standalone platform after restarting the Editor
- NavMeshAgent "breaks" when approaching a non-carved NavMeshObstacle
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.