If I’ not mistaken this issue, marked as “Fixed” means, that beginning with 5.3.6 Coroutines won’t create any garbage anymore (I guess with IL2CPP as backend though). This is huge!
Why not just not yield any value types to get boxed.
Yielding bool,int,etc effectively does the same thing as yielding ‘null’… so why yield any of those things? Garbage avoided.
I’m also unclear as to how it’s fixed. Unless as you suggested it possibly being with IL2CPP, in which case it only effects those builds. As for non-IL2CPP builds though, there’s no avoiding the garbage… the IEnumerator object that is generated for enumerating the coroutine returns values as ‘object’, value types must get boxed.
Why are you assuming only with IL2CPP backend?
Edit: I mean, the obvious way to fix this is to patch the mono implementation so the coroutine doesn’t generate garbage.
But how?
They’d have to do that at compile time. The garbage is getting created in the user code, not in the unity code.
And to do it then is to what? Replace any yielded values with null?
To clarify, this fix involves memory being allocated by the Unity Coroutine infrastructure being avoided. Previously, every iteration resulted in a small allocation in Unity internals.
Now, coroutines memory cost is a) the initial allocation for the enumerator object b) any allocations made in user code either via returning new reference types or boxing of returned value types
Ok, so there wasn’t just the boxing going on, there was something else going on as well behind the scene.
So this doesn’t resolve the boxing issue (which I wouldn’t expect it to).
I was confused because the wording on the bug was:
Which yeah, it would cause an allocation.