question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WaitForBackgroundThread crash some methods on Unity

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
AJ92commented, Apr 28, 2020

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.

3reactions
AJ92commented, Apr 28, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found