Search Issue Tracker
By Design
Votes
0
Found in
2018.4.0f1
2019.2.0a1
2019.2.0f1
2019.3.0a1
2020.1.0a1
Issue ID
1185356
Regression
No
Hash128.Parse throws an Exception when running in a thread other than the main thread in Unity Editor
To reproduce:
1. Download attached "Repro_Hash128_Parse.zip" project and open in Unity
2. Open "SampleScene"
3. Select "Hash128" gameObject in Hierarchy
4. In Inspector press "Parse in main thread" button
5. Observe that everything works as Expected
6. Press "Parse in thread pool" button
Expected results: As before everything works as Expected - Hash is printed and no Errors are logged
Actual results: Inspector throws an Exception:
"UnityEngine.UnityException: Parse can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at (wrapper managed-to-native) UnityEngine.Hash128.Parse_Injected(string,UnityEngine.Hash128&)
at UnityEngine.Hash128.Parse (System.String hashString) [0x00000] in <15966b0e0b01470ab47c749d344008bb>:0
at Hash128ParserEditor.ParseHash () [0x00013] in /Users/jonas/Downloads/case_1185356-Repro_Hash128_Parse/Assets/Editor/Hash128ParserEditor.cs:38
UnityEngine.Debug:Log(Object)
Hash128ParserEditor:ParseHash() (at Assets/Editor/Hash128ParserEditor.cs:43)
Hash128ParserEditor:<OnInspectorGUI>b__2_0(Object) (at Assets/Editor/Hash128ParserEditor.cs:27)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()"
Notes:
- This issue happens on both Windows and macOS
- Could not check on older Unity versions than 2018.3 because of old C# version
Reproduced on Unity 2018.4.10f1, 2019.2.7f2, 2019.3.0b5 and 2020.1.0a5
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
- Placeholder asset is not loaded with Advertisement Legacy sample when using the latest version of the package
- Addressables content build fails but the Player build is successful when building a development build
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
Resolution Note (2020.1.X):
This API is meant to work only on the main thread since Unity API is not thread safe.