Coroutine Freeze on WaitForSeconds but resumes after alt-tab in runtime build

Hi! As the title suggests, I have a freeze problem in my build.

It just a simple code.

void Start()
{
        StartCoroutine("TurnOnRoutine");
}

IEnumerator TurnOnRoutine()
{
        Debug.LogError("Start Coroutine");
  
        yield return new WaitForSeconds(1f);
  
        Debug.LogError("Test Log 1");
}

I didn’t capture screen, but the log shows “Start Coroutine,” and the game freezes.

However, if I [Alt + Tab] to switch focus to another window and then return to the program, the subsequent code starts working continue.

Clearly, There seems to be no problem with that simple code. Even nowhere to modified TimeScale.
Maybe something wrong in build settings or is it just a bug?

I tried…

  • yield return null → It working.
  • Dotween WaitForCompletion → not working
  • TimeScale Set 1 → not working

Based on your description, I suspect it’s some other script which happens after the first frame (“yield return null” works).

Validate this theory by putting this script into an empty scene. It should be fine. Then start trawling through your other scripts that you changed / added recently.