Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity Editor crashes on script recompilation while playing #17

Open
felixfaire opened this issue Jun 29, 2020 · 3 comments
Open

Unity Editor crashes on script recompilation while playing #17

felixfaire opened this issue Jun 29, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@felixfaire
Copy link

Hi Keijiro.

It seems that changing any user script while the player is running will cause the Unity editor to crash or hang until the kinect device is disconnected. I think this is something to do with the disposal and rejoining of the kinect driver thread, probably as it is still accessing a native plugin? Unfortunately my c# threading / GC knowledge is fairly limited so I cant immediately see what is wrong with the current code / method.

To reproduce crash:

  • make a new empty c# script / monobehaviour
  • run the app
  • make a minor change to the script file and return to the editor.
  • Editor crashes or hangs until the azure kinect is disconnected from the computer.

This happens regardless of the user settings for player behaviour on script changes.

unity 2019.3.14f1

@felixfaire
Copy link
Author

joining the thread and releasing resources on OnDisable() seems to avoid the crash but then extra null checking is required on Update().

@felixfaire felixfaire changed the title Crashes Unity Editor on recompile from script change. Unity Editor crashes on recompile from script change. Jun 29, 2020
@keijiro keijiro self-assigned this Jun 29, 2020
@keijiro keijiro added the question Further information is requested label Jun 29, 2020
@keijiro
Copy link
Owner

keijiro commented Jun 29, 2020

I always avoid recompiling scripts while playing, so I couldn't find this problem.

At the moment, as a workaround, I'd recommend avoiding recompilation in the play mode.

@felixfaire
Copy link
Author

I try to avoid it too but sometimes forget. The crash still happens if you disable script recompilation while running (and select stop play first, or recompile after stop) which seems odd.

My implementation with OnEnable and OnDisable seems to get around the issue for now but I wish there were more places to read about what unity does when a script file changes or how to properly / safely integrate external API's like the Azure Kinect.Sensor

Thanks

@keijiro keijiro changed the title Unity Editor crashes on recompile from script change. Unity Editor crashes on script recompilation while playing Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants