Coroutines icon indicating copy to clipboard operation
Coroutines copied to clipboard

Found A Bug but also a Fix.

Open shmellyorc opened this issue 2 years ago • 0 comments

Hello! First off I want to say I enjoy your coroutine runner. I have tried others and they are too complicated and thanks for sharing this awesome library.

I do game development with Monogame and converted your coroutine to an UpdatableGameComponent that runs it thru Monogame Deltatime. I dont know if its is only a monogame issue but I found a bug that happens when an coroutine gets removed, the loop still uses that current index or goes above the maximum array index which causes out of bounds error.

Probably didnt see this error because only doing a few coroutines it wont show this error. It will show this error if you got hundreds of coroutines. I have one scene of snow falling. I use a coroutine so I can re-use the snow array index instead of creating a new snow. Pretty much stop the GC from going crazy.

Anyways this is what I did to fix it, it may look slightly different as your method because its thru monogame update: image

shmellyorc avatar Mar 16 '22 05:03 shmellyorc