DownloadHandlerSseBase: Switch to Unity main thread before processing#4
Conversation
|
Thanks for raising this! I don't understand how it could happen frankly. Custom download scripts implementing Maybe the culprit is elsewhere. The |
|
Hey @xavier-ateo , do you have a stack trace or a log of the crash? Or at least a reproductible scenario? |
|
I agree. I was also under the impression that this should not happen. However, after I deployed this change, my editor stopped crashing. It’s a bit of a difficult scenario to debug, because I can’t capture the crash in the debugger, and the stack trace doesn’t provide many details. I also haven’t had the time to do a deeper investigation yet. When I find some time, I’ll try to create a reproducible scenario and test it on different machines and different Unity versions. If you want, you can close this issue for now, and I’ll get back to you once I have more information. |
|
I'll keep this PR open as a reminder (mainly for myself 😅). Does the crash happen in a build or just in the editor? |
This code executed outside of the Unity main thread context in my project, which caused certain realtime subscription callbacks to crash the editor. The fix captures Unity's main thread SynchronizationContext and uses it to send all OnNewLineReceived callbacks back to the main thread.
I am not certain if this is the only place where code executes outside of the main thread context, or if there are other places in the codebase that need to be synchronized.