27

The Instruments User Guide has this to say:

  • Color Copied Images. Puts a cyan overlay over images that were copied by Core Animation.

But that doesn't explain why an image got copied. There doesn't seem to be an obvious pattern from one copied image to another, although it is regular and reproducible.

The docs currently don't even mention Color Hits Green and Misses Red, but I'm thinking it might have something to do with CALayer’s shouldRasterize property.

Any ideas?

Wilbur Vandrsmith
  • 5,040
  • 31
  • 32

3 Answers3

15

For "Color Copied Images," this was talked about nicely in Session 419 WWDC 2014:

"If an image is in a color format that the GPU can not directly work with, it will be converted in the CPU."

Example: Imagine getting images from an online source where you don't control the format. JPEG supports 24-bit color images (8 bits per color). TIFF format can store colors in 48-bit color images (16 bits per color). Depending on what iOS wants, these differences might have to be converted.

The solution would be to covert them in the background to the right color format to prevent a performance problem of doing these conversions on the main thread.

For "Color Hits Green and Misses Red," OP is correct, it's to check whether you are using the "shouldRasterize" property correctly. Green means good, you re-used the cache you created from the "shouldRasterize" property. Red means bad, you needed to write to the cache (causes an offscreen pass), and then draw.

kgaidis
  • 14,259
  • 4
  • 79
  • 93
3

Images can be copied if they are backed by a custom data provider or can’t be mapped into another process for some other reason.

Ben Stiglitz
  • 3,994
  • 27
  • 24
  • Why would the OS map app-specific graphics into another process? – Wilbur Vandrsmith Jan 07 '12 at 04:23
  • 2
    The SpringBoard (until iOS 5) / BackBoard (iOS 6 +) process handles all the rendering of an iOS app. See session 238 of WWDC 2012, they explain the rendering steps 3 minutes in. – ndfred Nov 08 '12 at 13:14
1

iOS debug rendering with Core Animation Instruments

[iOS CALayer]

Good practice is to have:

  • 60 FPS(frames per second) Real device -> Profile -> Core Animation FPS
  • test release package because of some compile optimizations

Core Animation Instruments

Simulator -> Debug:

  • Color Blended Layers(overdraw, color mixing) [Green, Red]

The same pixel is drawn more than once in a single frame of rendering

If Red - color blending is applied. It is not simple task to calculate a correct result pixel color when there are pixels with alpha channel under it.

[iOS alpha vs opacity vs opaque]

Use cases:

  1. UIView.layer.cornerRadius the color blending is applied. It means that extra layer with alpha applied

To fix this issue you can:

-use mask(Color Off-screen Rendered will be applied)
-add extra layer with rounded corners

  1. UILableView - backgroundColor is transparent
  2. UIImage with alpha channel (which can be used in UIImageView)

To preven color blending: -flat view hierarchy
-reduce tranceparency

  • Color Copied Images [Blue, default]

If Blue - image is copied from GPU to CPU, because GPU does not support this color format. For example you can create a large imageview and set .pdf image

imageView.image = UIImage(named: "ring")
  • Color Misaligned Images [Yellow, default]

Image size doesn't equal to imageView size. Since it requires extra work to compress the image

  • Color Off-screen Rendered [Yellow, default]

If Yellow - layer was rendered offscreen. For example mask, shadow **without** path, cornerRadius, something custom with CGContext, drawRect

Real device additionally has:

Xcode(13.3.1) -> Debug -> View Debugging -> Rendering

  • Color Hits Green and Misses Red [Green, Red, default]

Shows that shouldRasterize = true has a negative impact. Green - cached successfully, Red - cache is regenerated. Only frequent regeneration has performance impact.

[iOS shouldRasterize]

  • Color Layer Formats(Color Non-Standard Surface Formats) not documented
  • Color Immediately

By default Core Animation Instruments updates debug coloured layed every 10 ms. This setting set it to update every frame which has some impact on performance and accuracy.

  • Color Compositing Fast-Path Blue(Color OpenGL Fast Path Blue) [Blue, Red, default]

Highlight(blue) layer which is drawn directly to screen with OpenGL which is the best practice. If you work with OpenGL and dont see blue it means that you make extra work

  • Flash Updated Regions [Yellow, default]

Yellow is a region which is updated(redrawn). The simplest scenario it's finding unnecessary effects

yoAlex5
  • 29,217
  • 8
  • 193
  • 205