Changing text color causes a dramatic performance loss

I’m using this little coroutine to fade away some UI text:

 IEnumerator Fade() {     
      float a = Message.color.a;
      float d = a/4f;
      float t;
      while(a>0) {
         yield return null;
         t                          = Time.deltaTime;
         Message.color              = new Color(1f,1f,1f,a);
         a                         -= d*t;
         Y                         += 15f*t;
         RectTrans.anchoredPosition = new Vector2(0f,Y);
      }
      Obj.SetActive(false);
   }

but I notice a severe performance drop on the profiler caused by this function, when only one text element is affected you can barely notice it, but with 6 or 7 elements fading away at the same time, this is what I see:

However if the color remains unchanged, performance remains quite stable, please, notice the fact that I’m also moving the text upwards a little bit, so (theoretically) the rendering algorithm has to recalculate the same amount of pixels on every frame, whether I change the text color or not.

… But!, to ensure the RectTransform is updated at a similar rate than Text, I modified the script assuming deltaTime would remain stable at a rate of 0.02, to increase Y by 1 on every frame.

IEnumerator Fade() {     
      float a = Message.color.a;
      float d = a/4f;
      float t;
      while(a>0) {
         yield return null;
         t                          = Time.deltaTime;
        // Message.color              = new Color(1f,1f,1f,a);
         a                         -= d*t;
         Y                         += 50f*t;
         RectTrans.anchoredPosition = new Vector2(0f,Y);
      }
      Obj.SetActive(false);
   }

I also resized the game window to occupy the maximum height posible (for some reason “Maximize on play” prevents the profiler from recording), to translate every increase of Y into the maximum amount of pixels, but the impact on performance is barely noticeable as you can see below:

You should drill down into the performance spikes and show what exactly is the time consuming part of this code.
Use “Deep profile” and then you can drill down in-depth into all method calls to see where it’s running slow.
(Please post the results)

Definitely I need to do something about those spikes, however they have nothing to do with the problem I’m exposing, if you compare the two graphics, you will see they are the same in both images, however on the first graphic there’s bump which last for about 5 seconds (the time the coroutine takes to complete), that cannot be considered just a “spike”, that is a major problem and the responsable for that is: Message.color = new Color(1f,1f,1f,a);

I tried reproducing this but i can’t … is there any way you can share the specific scene that is demonstrating this issue ?

Unfortunately I don’t have a quick and easy way to share the scene right now, but one thing I forgot to mention is that this belongs to a Canvas which is in world space… haven’t tested in screen space yet… I’m going to have to work a little bit before I can share the scene.