Coroutines (likely) running far too slow on Android, what's the issue?

Windows build is lightning fast but the android version is unacceptably slow. Something that was near instantaneous takes around 5 seconds on Android. Searching the interwebs on this topic, using FixedUpdate was brought up, but since I’ve more than 30 coroutines all over and coroutines should work fine on Android, and this would be taxing to convert all coroutines over, I thought I’d appeal to you all first. I’ve coroutines all over for various tasks, but here’s an example fade piece:

public void BeginFade()

    IEnumerator FadeIt_Image()
        yield return new WaitForSeconds(delay);

            for (int i = 0; i < fadetovalue; i++)
                subject.GetComponent<Image>().color = new Color32(System.Convert.ToByte(subject.GetComponent<Image>().color.r * 255), System.Convert.ToByte(subject.GetComponent<Image>().color.g * 255), System.Convert.ToByte(subject.GetComponent<Image>().color.b * 255), System.Convert.ToByte(i));
                //yield return new WaitForSeconds(.001f);
                yield return null;
                i = i + speed;

This is just a slimmed down simple one, but there’s coroutines that move and fade and change menu values and they all uniformly take something like 5 seconds to perform. Here’s some of the additional details that may get brought up:

  • No coroutines are kicked off with Update functions, but the opening flourish does kick one off with a Start function. The rest are action based like with button activation. The idea to try FixedUpdate (which if we can’t solve this I’ll be forced to try) came from here: c# - My coroutine is running slower on Unity android aplication - Stack Overflow

  • I tried various yield times and all are the same 5 second slug (you can see what is active in the code above is yield return null, but waitforseconds is commented out which failed and I tried waitforrealtime which also failed as was referenced here:Reddit - Dive into anything

  • Test phone is OnePlus 6T and runs other Unity apps fine. Buddy is running a Galaxy s22 who also reported a slow move time so “the phone is slow” isn’t the problem.

  • I took out all images and objects and ran with just Unity code and it still does this so no bloat objects are being used that would slow this down.

  • Only one Coroutine is running at a time throughout most of the time. I verified through debugs that none of them are stuck, they just take the previously mentioned 5~ seconds to complete

Thank you for any suggestions you all may have.

I can’t say anything about the speed of the code, but a Coroutine will depend on framerate. It will run until the next yield every frame. So in your example if speed is 1 you will increase fadetovalue by 1 every frame, meaning that if the framerate is 10 instead of 60 it will take 6 times as long. The normal thing to do is to base it on time instead - increase fadetovalue by Time.deltaTime*speedoffade. I don’t like coroutines and do my things directly in Update, and this is one of the reasons.

I have concluded that coroutines universally are just not appropriate for accurate timed actions on Android. As was recommended before, Fixed Update will have to be used. Stack Overflow example below for performing similar tasks, and therefore will start the process of gutting all coroutines from my code.