WaitForBackgroundThread crash some methods on Unity
See original GitHub issueHi, i am migrating my project to version 13.0. I think this addition is generating some errors in unity, in functions that need the Main Thread.
WebSocket.cs, method Receive
await new WaitForBackgroundThread();
I got the error:
get_isPlaying can only be called from the main thread
and
UnityException: get_gameObject can only be called from the main thread.
after removing the line the errors simply stopped.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
WaitForBackgroundThread crash some methods on Unity
Hi, i am migrating my project to version 13.0. I think this addition is generating some errors in unity, in functions that need...
Read more >Bug - Crash while attempting to LoadAssetsAsync.
This caused the above crash to happen 100%. I took some time to manually perform some duplicate asset hygiene and it seems to...
Read more >Async method with parameters crash C# - Stack Overflow
I'm using C# on Unity and Firebase for this project, but I'm not sure that this is a framework problem, more like async-approach-trouble....
Read more >Debugging Async/ await methods in Unity crashes the editor
The reason is a bit strange, I'm sure this will be fixed at some point. I will say that my usage of an...
Read more >Debugging Unity Crashes & Errors - The Easy Way - YouTube
Try Backtrace FREE - https://backtrace.io/create/?utm_campaign=Free%20Trial%20Signup&utm_source=Jason%20Weimann Learn how to catch and fix ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hehe, the last sentence is probably the most important here 😃 i guess there are messages queued, that are processed after the client left the room. should be easy to fix 👍 could take a look at it tomorrow or so.
The Receive() Task runs in the background thread and invokes onClose which calls unity functions and those should not be called from other threads. Maybe it is better to put the whole Receive function into a Thread and then just return the error code to invoke the onClose function, after the thread finished.
I might raise a PR tomorrow.