You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In spite of the fact that this issue is, I believe, one of the most infamous issues plaguing GDScript at the current time, I couldn't find an existing ticket that references the issue explicitly.
Here's the core of it: If you await a signal that has a longer lifetime than the object containing the coroutine itself, and then free the object before resuming the coroutine, you get a memory leak if the signal is never emitted, and an error if it is. There are a number of ways to interpret why this happens, but the core of it seems to be that freeing an object does not appear to disconnect any GDFunctionState instances that depend on the object itself. I experimented with a release build, and while it doesn't appear to cause a crash, I think it's fair to say that ignoring an error that arguably shouldn't exist is not a graceful solution. There may also be other side effects I'm not actually aware of.
There are ways of working around this, but they're all fickle, and the quintessential coroutine example of:
awaitget_tree().process_frame
is one of the fastest ways to trip over the problem.
Godot version
v4.0.beta17.official [c400205]
System information
Windows 10
Issue description
In spite of the fact that this issue is, I believe, one of the most infamous issues plaguing GDScript at the current time, I couldn't find an existing ticket that references the issue explicitly.
Here's the core of it: If you await a signal that has a longer lifetime than the object containing the coroutine itself, and then free the object before resuming the coroutine, you get a memory leak if the signal is never emitted, and an error if it is. There are a number of ways to interpret why this happens, but the core of it seems to be that freeing an object does not appear to disconnect any
GDFunctionState
instances that depend on the object itself. I experimented with a release build, and while it doesn't appear to cause a crash, I think it's fair to say that ignoring an error that arguably shouldn't exist is not a graceful solution. There may also be other side effects I'm not actually aware of.There are ways of working around this, but they're all fickle, and the quintessential coroutine example of:
is one of the fastest ways to trip over the problem.
Steps to reproduce
Stick the following in your node of choice:
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: