Runtime added animation stops at frame 1

// Code inside the Update() method of some spawner:
GameObject obstacleGameObject = new("Obstacle");

// <snip: add SpriteRenderer and such here>

// Use an Animator.
Animator animator = obstacleGameObject.AddComponent<Animator>();
animator.runtimeAnimatorController = obstacleData.AnimatorController; // Get AnimatorController from ScriptableObject called: obstacleData.
animator.speed = 1f; // shouldnt be required.
animator.updateMode = AnimatorUpdateMode.Normal; // shouldnt be required.

After it spawned, it plays only 1 frame of the animation and then stops. If I duplicate the newly spawned gameobject in the scene-view then the duplicated version works but the original one doesn’t… I don’t get it?

Must I refresh the Animator component or something?

UPDATE: Nevermind, shortly after posting this I finally found the problem. A coroutine was setting the animation speed to 0…