Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Putting 'StartCoroutine(xxx());' inside of the same coroutine causes Unity2018.1.0f2 to go crazy

Discussion in 'Scripting' started by TheGoopyPixel, Aug 12, 2018 at 8:54 PM.

  1. TheGoopyPixel

    TheGoopyPixel

    Joined:
    Apr 29, 2017
    Posts:
    111
    (the xxx is just an example name and not the actual coroutine name, fyi)

    I was making a simple coroutine that just counts down a variable over time and then ends the coroutine after the variable is 0 by running 'StopCoroutine(xxx());'

    But it wasn't like this at first, It auto-completed to StartCoroutine and I didn't notice until I tested my game. Basically when the line was ran in the coroutine the game froze for a few seconds and then started getting mass spammed by "Assertion failed: TLS Allocator ALLOC_TEMP_THREAD, underlying allocator ALLOC_TEMP_THREAD has unfreed allocations, size 390" Fixing the line or even totally deleting the coroutine didn't fix it, it would just keep spamming the console with that error. Closing and restarting Unity seems to have fixed it, although I'm a bit worried I might've broken my project, there isn't as issues popping up at the moment, however.

    Has this bug been fixed in new versions of Unity? If not then perhaps you could add an error in the console saying "you can't start the same coroutine inside of the coroutine" or something.
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    1,571
    Your project is fine. You just created infinite recursion which blew up the stack, and I guess corrupted something internally in Unity, so restarting is fine.

    There's nothing wrong with calling a coroutine from within itself, you just can't do it infinitely as you had.
     
    Kiwasi likes this.