Advanced Graphics and Animations for ios Apps



Similar documents
Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Optimizing AAA Games for Mobile Platforms

GPU Architecture. Michael Doggett ATI

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Developer Tools. Tim Purcell NVIDIA

Performance Optimization and Debug Tools for mobile games with PlayCanvas

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

How To Develop An App For Ios (Windows)

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Low power GPUs a view from the industry. Edvard Sørgård

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

The Future Of Animation Is Games

Introduction to Imagery and Raster Data in ArcGIS

Objective C and iphone App

OpenGL Performance Tuning

INTRODUCTION TO RENDERING TECHNIQUES

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

ios Technology Overview

Graphic Design. Background: The part of an artwork that appears to be farthest from the viewer, or in the distance of the scene.

Comp 410/510. Computer Graphics Spring Introduction to Graphics Systems

ios Application Development &

GPU Profiling with AMD CodeXL

Developing Applications for ios

Improving Your App with Instruments

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

BCC Multi Stripe Wipe

Chapter 1. Introduction to ios Development. Objectives: Touch on the history of ios and the devices that support this operating system.

ACE: After Effects CC

Overview Motivation and applications Challenges. Dynamic Volume Computation and Visualization on the GPU. GPU feature requests Conclusions

How To Teach Computer Graphics

How To Develop For A Powergen 2.2 (Tegra) With Nsight) And Gbd (Gbd) On A Quadriplegic (Powergen) Powergen Powergen 3

ANDROID DEVELOPER TOOLS TRAINING GTC Sébastien Dominé, NVIDIA

Getting Started with CodeXL

Water Flow in. Alex Vlachos, Valve July 28, 2010

RADEON 9700 SERIES. User s Guide. Copyright 2002, ATI Technologies Inc. All rights reserved.

Client Requirement. Master Data Management App. Case Study -

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

Finding Performance and Power Issues on Android Systems. By Eric W Moore

Continuous Integration with Xcode 6

Radeon GPU Architecture and the Radeon 4800 series. Michael Doggett Graphics Architecture Group June 27, 2008

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

TakeMySelfie ios App Documentation

Optimizing Unity Games for Mobile Platforms. Angelo Theodorou Software Engineer Unite 2013, 28 th -30 th August

Finger Paint: Cross-platform Augmented Reality

QNX Software Development Platform 6.6. Screen Graphics Subsystem Developer's Guide

Modern Graphics Engine Design. Sim Dietrich NVIDIA Corporation

Create a Poster Using Publisher

Billings Pro ios User Guide (Last updated: Feb 15th, 2016)

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

Graphical displays are generally of two types: vector displays and raster displays. Vector displays

Mobile Application Development L06: ios Drawing and Animation

Using Safari to Deliver and Debug a Responsive Web Design

Dynamic Resolution Rendering

NVPRO-PIPELINE A RESEARCH RENDERING PIPELINE MARKUS TAVENRATH MATAVENRATH@NVIDIA.COM SENIOR DEVELOPER TECHNOLOGY ENGINEER, NVIDIA

Golfshot : Golf GPS User Guide

Android Architecture. Alexandra Harrison & Jake Saxton

The Dennis Technique for SketchUp Models in Photoshop

How To Understand The Power Of Unity 3D (Pro) And The Power Behind It (Pro/Pro)

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

genie app and genie mobile app

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

Lecture Notes, CEng 477

Visualizing Data: Scalable Interactivity

IV3Dm provides global settings which can be set prior to launching the application and are available through the device settings menu.

JavaFX Session Agenda

ACE: After Effects CS6

Sprite Kit Programming Guide

Beginning Android 4. Games Development. Mario Zechner. Robert Green

Touchstone -A Fresh Approach to Multimedia for the PC

Gauge Drawing Tool Slider Drawing Tool Toggle Button Drawing Tool One-Way List Drawing Tool... 8

Advanced Rendering for Engineering & Styling

Getting Started: Creating the Backdrop

News. Ad Specifications July 2016

OpenEXR Image Viewing Software

CLOUD GAMING WITH NVIDIA GRID TECHNOLOGIES Franck DIARD, Ph.D., SW Chief Software Architect GDC 2014

Design Your Own Photo Card Add a personal touch to your holiday greetings

Remote Desktop Protocol Performance

2. About iphone ios 5 Development Essentials. 5. Joining the Apple ios Developer Program

Game Center Programming Guide

Xcode Application note

MA-WA1920: Enterprise iphone and ipad Programming

Computer Graphics Hardware An Overview

Outline. srgb DX9, DX10, XBox 360. Tone Mapping. Motion Blur

Image Synthesis. Transparency. computer graphics & visualization

Graphics Cards and Graphics Processing Units. Ben Johnstone Russ Martin November 15, 2011

ipad, a revolutionary device - Apple

Beginner level: Modules 1 to 18. Advanced level: Quick review of modules 1 to 18, then following to module A Simple ios Application

Plug-in Software Developer Kit (SDK)

ios App for Mobile Website! Documentation!

PowerPoint 2007 Basics Website:

Mobile Phones Operating Systems

Operating Systems Introduction

Mobile App Design and Development

ios 9 Accessibility Switch Control - The Missing User Guide Updated 09/15/15

WEB, HYBRID, NATIVE EXPLAINED CRAIG ISAKSON. June 2013 MOBILE ENGINEERING LEAD / SOFTWARE ENGINEER

L20: GPU Architecture and Models

Transcription:

Tools #WWDC14 Advanced Graphics and Animations for ios Apps Session 419 Axel Wefers ios Software Engineer Michael Ingrassia ios Software Engineer 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

What You Will Learn Core Animation pipeline Rendering concepts UIBlurEffect UIVibrancyEffect Profiling tools Case studies

Technology Framework UIKit Core Animation OpenGL ES Core Graphics Graphics Hardware

Core Animation Pipeline Axel Wefers ios Software Engineer

Core Animation Pipeline Application

Core Animation Pipeline Application Core Animation

Core Animation Pipeline Application Core Animation Render Server

Core Animation Pipeline Application Core Animation Render Server Core Animation

Core Animation Pipeline Application Core Animation Render Server Core Animation GPU

Core Animation Pipeline Application Core Animation Render Server Core Animation GPU Display

Core Animation Pipeline Application Core Animation Render Server Core Animation GPU Display 16.67 ms

Core Animation Pipeline Application Core Animation Handle Events Render Server Core Animation GPU Display 16.67 ms

Core Animation Pipeline Application Core Animation Commit Transaction Render Server Core Animation GPU Display 16.67 ms

Core Animation Pipeline Application Core Animation Commit Transaction Render Server Core Animation Decode GPU Display 16.67 ms

Core Animation Pipeline Application Core Animation Commit Transaction Render Server Core Animation Decode Draw Calls GPU Display 16.67 ms

Core Animation Pipeline Application Core Animation Commit Transaction Render Server Core Animation Decode Draw Calls GPU Render Display 16.67 ms

Core Animation Pipeline Application Core Animation Commit Transaction Render Server Core Animation Decode Draw Calls GPU Render Display Display 16.67 ms

Core Animation Pipeline Application Core Animation Render Server Core Animation GPU Display 16.67 ms

Core Animation Pipeline Application Core Animation Commit Transaction Render Server Core Animation GPU Display 16.67 ms

Commit Transaction

Commit Transaction Layout Set up the views

Commit Transaction Layout Display Set up the views Draw the views

Commit Transaction Layout Display Prepare Set up the views Draw the views Additional Core Animation work

Commit Transaction Layout Display Prepare Commit Set up the views Draw the views Additional Core Animation work Package up layers and send them to render server

Commit Transaction Layout Display Prepare Commit

Layout Layout Display Prepare Commit layoutsubviews overrides are invoked View creation, addsubview: Populate content, database lookups Usually CPU bound or I/O bound

Display Layout Display Prepare Commit Draw contents via drawrect: if it is overridden String drawing Usually CPU or memory bound

Prepare Commit Layout Display Prepare Commit Image decoding Image conversion

Commit Layout Display Prepare Commit Package up layers and send to render server Recursive Expensive if layer tree is complex

Animation Three-stage process Application Render Server

Animation Three-stage process Application Render Server 1. Create animation and update view hierarchy (animatewithduration:animations:)

Animation Three-stage process Application Render Server 2. Prepare and commit animation (layoutsubviews, drawrect:) 1. Create animation and update view hierarchy (animatewithduration:animations:)

Animation Three-stage process Application Render Server 2. Prepare and commit animation (layoutsubviews, drawrect:) Layout Display Prepare Commit 1. Create animation and update view hierarchy (animatewithduration:animations:)

Animation Three-stage process Application Render Server 3. Render each frame 2. Prepare and commit animation (layoutsubviews, drawrect:) Layout Display Prepare Commit 1. Create animation and update view hierarchy (animatewithduration:animations:)

Rendering Concepts Axel Wefers ios Software Engineer

Rendering Concepts Tile based rendering Render passes Example masking

Tile Based Rendering Screen is split into tiles of NxN pixels Each tile fits into the SoC cache Geometry is split in tile buckets Rasterization can begin after all geometry is submitted

Tile Based Rendering Screen is split into tiles of NxN pixels Each tile fits into the SoC cache Geometry is split in tile buckets Rasterization can begin after all geometry is submitted

Tile Based Rendering Screen is split into tiles of NxN pixels Each tile fits into the SoC cache Geometry is split in tile buckets Rasterization can begin after all geometry is submitted

Tile Based Rendering Screen is split into tiles of NxN pixels Each tile fits into the SoC cache Geometry is split in tile buckets Rasterization can begin after all geometry is submitted

Tile Based Rendering Screen is split into tiles of NxN pixels Each tile fits into the SoC cache Geometry is split in tile buckets Rasterization can begin after all geometry is submitted

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL GPU

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL GPU Command Buffer

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL GPU Command Buffer Vertex Processing Vertex Shader

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL GPU Command Buffer Vertex Processing Vertex Shader Tiling

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL Tiler GPU Command Buffer Vertex Processing Vertex Shader Tiling

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL Tiler GPU Command Buffer Vertex Processing Vertex Shader Tiling Parameter Buffer

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL Tiler GPU Command Buffer Vertex Processing Vertex Shader Tiling Parameter Buffer Pixel Processing Pixel Shader

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL Tiler GPU Command Buffer Vertex Processing Vertex Shader Renderer Tiling Parameter Buffer Pixel Processing Pixel Shader

Tile Based Rendering Rendering pass Render Server Core Animation Application Core Animation OpenGL Tiler GPU Command Buffer Vertex Processing Vertex Shader Renderer Tiling Parameter Buffer Pixel Processing Pixel Shader Render Buffer

Masking Rendering passes Render Server Core Animation OpenGL Application Core Animation GPU Command Buffer

Masking Rendering passes Render Server Application Core Animation Core Animation OpenGL Command Buffer Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Mask Texture GPU Pass 1 Render layer mask to texture

Masking Rendering passes Render Server Application Core Animation Core Animation OpenGL Command Buffer Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Mask Texture GPU Pass 1 Render layer mask to texture Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Layer Texture Pass 2 Render layer content to texture

Masking Rendering passes Render Server Application Core Animation Core Animation OpenGL Command Buffer Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Mask Texture GPU Pass 1 Render layer mask to texture Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Layer Texture Pass 2 Render layer content to texture Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Frame Buffer Compositing pass Apply mask to content texture

UIBlurEffect Axel Wefers ios Software Engineer

UIVisualEffectView with UIBlurEffect UIBlurEffect styles No effect Extra light Light Dark

UIVisualEffectView with UIBlurEffect Rendering passes (best case) Command Buffer GPU

UIVisualEffectView with UIBlurEffect Rendering passes (best case) Tiler Tiling Parameter Buffer Pixel Processing Pixel Shader Content GPU Pass 1 Vertex Processing Command Buffer Vertex Shader Renderer Render content

UIVisualEffectView with UIBlurEffect Rendering passes (best case) Command Buffer Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Content GPU Pass 1 Render content Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Downscaled Content Pass 2 Capture content

UIVisualEffectView with UIBlurEffect Rendering passes (best case) Command Buffer Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Content GPU Pass 1 Render content Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Downscaled Content Pass 2 Capture content Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Blur X Pass 3 Horizontal blur Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Blur Y Pass 4 Vertical blur

UIVisualEffectView with UIBlurEffect Rendering passes (best case) Command Buffer Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Content GPU Pass 1 Render content Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Downscaled Content Pass 2 Capture content Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Blur X Pass 3 Horizontal blur Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Blur Y Pass 4 Vertical blur Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Frame Buffer Compositing pass Upscale and tint

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2 Pass 3

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2 Pass 3 Pass 4

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2 Pass 3 Pass 4 Pass 5

UIVisualEffectView with UIBlurEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms

UIVisualEffectView with UIBlurEffect Fullscreen performance ipad (3rd generation) ipad Air UIBlurEffectStyleExtraLight 4.59 10.03 18.15 UIBlurEffectStyleLight 4.59 6.88 14.69 UIBlurEffectStyleDark 4.59 7.02 14.41 0.00 4.17 8.34 12.50 16.67 GPU time in milliseconds (smaller is better)

UIVisualEffectView with UIBlurEffect Fullscreen performance ipad (3rd generation) ipad Air UIBlurEffectStyleExtraLight 4.59 10.03 UIBlurEffectStyleLight 4.59 6.88 UIBlurEffectStyleDark 4.59 7.02 0.00 4.17 8.34 12.50 16.67 GPU time in milliseconds (smaller is better)

UIVisualEffectView with UIBlurEffect UIBlurEffect support Device Blur Tint ipad 2 ipad (3rd generation) ipad (4th generation) ipad Air ipad mini ipad mini Retina display All iphones ipod touch

UIVisualEffectView with UIBlurEffect Performance considerations UIBlurEffect adds multiple offscreen passes depending on style Only dirty regions are redrawn Effect is very costly UI can easily be GPU bound Keep bounds of view as small as possible Make sure to budget for effect

UIVibrancyEffect Axel Wefers ios Software Engineer

UIVisualEffectView with UIVibrancyEffect UIVibrancyEffect styles Extra light Light Dark

UIVisualEffectView with UIVibrancyEffect UIVibrancyEffect styles Extra light Light Dark

UIVisualEffectView with UIVibrancyEffect UIVibrancyEffect styles Extra light Light Dark

UIVisualEffectView with UIVibrancyEffect Rendering passes Render Server Core Animation Application Core Animation OpenGL GPU Command Buffer

UIVisualEffectView with UIVibrancyEffect Rendering passes Render Server Core Animation Application Core Animation OpenGL Command Buffer Blur Effect GPU Pass 1 to 5 Render blur effect

UIVisualEffectView with UIVibrancyEffect Rendering passes Render Server Core Animation Application Core Animation OpenGL Command Buffer Blur Effect GPU Pass 1 to 5 Render blur effect Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Layer Texture Pass 6 Render layer content to texture

UIVisualEffectView with UIVibrancyEffect Rendering passes Render Server Core Animation Application Core Animation OpenGL Command Buffer Blur Effect GPU Pass 1 to 5 Render blur effect Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Layer Texture Pass 6 Render layer content to texture Tiler Vertex Processing Vertex Shader Tiling Parameter Buffer Renderer Pixel Processing Pixel Shader Frame Buffer Compositing pass Apply filter to content texture

UIVisualEffectView with UIVibrancyEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Pass 6 Pass 7

UIVisualEffectView with UIVibrancyEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Pass 6 Pass 7

UIVisualEffectView with UIVibrancyEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Pass 6 Pass 7

UIVisualEffectView with UIVibrancyEffect GPU utilization, fullscreen, ipad Air Tiler Vertex processing Renderer Pixel processing 16.67 ms VBlank interrupt Every 16.67 ms

UIVisualEffectView with UIVibrancyEffect Fullscreen performance ipad (3rd generation) ipad Air UIBlurEffectStyleExtraLight 4.59 10.03 UIBlurEffectStyleLight 4.59 6.88 UIBlurEffectStyleDark 4.59 7.02 0.00 8.34 16.67 25.01 33.34 GPU time in milliseconds (smaller is better)

UIVisualEffectView with UIVibrancyEffect Fullscreen performance ipad (3rd generation) ipad Air UIBlurEffectStyleExtraLight 4.59 10.03 17.48 27.03 UIBlurEffectStyleLight 4.59 6.88 14.35 27.03 UIBlurEffectStyleDark 4.59 7.02 14.06 26.32 0.00 8.34 16.67 25.01 33.34 GPU time in milliseconds (smaller is better)

UIVisualEffectView with UIVibrancyEffect Performance considerations UIVibrancyEffect adds two offscreen passes UIVibrancyEffect uses expensive compositing filter for content Use UIVibrancyEffect on small regions Only dirty regions are redrawn UIVibrancyEffect is very costly on all devices UI can easily be GPU bound Keep bounds of view as small as possible Make sure to budget for effects

Rasterization Performance considerations Use to composite to image once with GPU Enable with shouldrasterize property on CALayer Extra offscreen passes when updating content Do not overuse, cache size is limited to 2.5x of screen size Rasterized images evicted from cache if unused for more than 100ms

Rasterization Typical use cases Avoid redrawing expensive effects for static content Avoid redrawing of complex view hierarchies

Group Opacity Performance considerations Disable with allowsgroupopacity property on CALayer Will introduce offscreen passes: If layer is not opaque (opacity = 1.0) And if layer has nontrivial content (child layers or background image) Sub view hierarchy needs to be composited before being blended Always turn it off if not needed

Tools Michael Ingrassia ios Software Engineer

Performance Investigation Mindset

Performance Investigation Mindset What is the frame rate? Goal is always 60 frames per second

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Goal is always 60 frames per second Lower utilization is desired and saves battery

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Goal is always 60 frames per second Lower utilization is desired and saves battery GPU is desirable but know when CPU makes sense

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Too many offscreen passes? Goal is always 60 frames per second Lower utilization is desired and saves battery GPU is desirable but know when CPU makes sense Fewer is better

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Too many offscreen passes? Too much blending? Goal is always 60 frames per second Lower utilization is desired and saves battery GPU is desirable but know when CPU makes sense Fewer is better Less is better

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Too many offscreen passes? Too much blending? Any strange image formats or sizes? Goal is always 60 frames per second Lower utilization is desired and saves battery GPU is desirable but know when CPU makes sense Fewer is better Less is better Avoid on-the-fly conversions or resizing

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Too many offscreen passes? Too much blending? Any strange image formats or sizes? Any expensive views or effects? Goal is always 60 frames per second Lower utilization is desired and saves battery GPU is desirable but know when CPU makes sense Fewer is better Less is better Avoid on-the-fly conversions or resizing Understand the cost of what is in use

Performance Investigation Mindset What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Too many offscreen passes? Too much blending? Any strange image formats or sizes? Any expensive views or effects? Anything unexpected in hierarchy? Goal is always 60 frames per second Lower utilization is desired and saves battery GPU is desirable but know when CPU makes sense Fewer is better Less is better Avoid on-the-fly conversions or resizing Understand the cost of what is in use Know the actual view hierarchy

Tools Instruments Core Animation instrument OpenGL ES Driver instrument Simulator Color debug options Xcode View debugging

Instruments Core Animation template

Instruments Core Animation template

Core Animation Instrument Measuring frame rate

Core Animation Instrument Measuring frame rate

Core Animation Instrument Measuring frame rate

Core Animation Instrument Measuring frame rate

Time Profiler Instrument CPU utilization

Time Profiler Instrument CPU utilization

Time Profiler Instrument CPU utilization

Core Animation Instrument Color debug options

Core Animation Instrument Color debug options

Core Animation Instrument Color debug options

Core Animation Instrument Color blended layers

Core Animation Instrument Color hits green and misses red

Core Animation Instrument Color copied images

Core Animation Instrument Color misaligned images

Core Animation Instrument Color offscreen-rendered yellow

Core Animation Instrument Color OpenGL fast path blue

Core Animation Instrument Flash updated regions

Performance Investigation Mindset Core Animation instrument summary What is the frame rate? Goal is always 60 frames per second Any unnecessary CPU rendering? GPU is desirable but know when CPU makes sense Too many offscreen passes? Fewer is better Too much blending? Less is better Any strange image formats or sizes? Avoid on-the-fly conversions or resizing

ios Simulator Coloring Options

Instruments OpenGL ES Driver template

Instruments OpenGL ES Driver template

OpenGL ES Driver Instrument Selecting statistics to list

OpenGL ES Driver Instrument Selecting statistics to list

OpenGL ES Driver Instrument Selecting statistics to list

OpenGL ES Driver Instrument GPU utilization

OpenGL ES Driver Instrument GPU utilization

OpenGL ES Driver Instrument GPU utilization

Time Profiler Instrument CPU utilization

Time Profiler Instrument CPU utilization

Time Profiler Instrument CPU utilization

Performance Investigation Mindset OpenGL ES Driver instrument summary What is the frame rate? Goal is always 60 frames per second CPU or GPU bound? Lower utilization is desired and saves battery Any unnecessary CPU rendering? GPU is desirable but know when CPU make sense

Xcode View debugging

Xcode View debugging

Xcode View debugging

Xcode View debugging

Performance Investigation Mindset Xcode view debugging summary Any expensive views or effects? Understand the cost of what is in use Anything unexpected in hierarchy? Know the actual view hierarchy

Case Studies Michael Ingrassia ios Software Engineer

Case Studies Explore several scenarios Measure performance on different devices Keep the same appearance with better performance

Fictitious Photo Application Case study Simple table view Each cell shows a photo thumbnail and some text Each photo has a small shadow

Measure Frame Rate on iphone 5s OpenGL ES Driver instrument

Measure Frame Rate on iphone 5s OpenGL ES Driver instrument

Awesome Ship it?

Fictitious Photo Application ipod touch scrolling performance What about the performance on other devices?

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Analyzing View Hierarchy on ipod touch Xcode view debugging

Analyzing View Hierarchy on ipod touch Xcode view debugging

Color Offscreen-Rendered Yellow Core Animation instrument

How Are We Setting up the Shadow?

How Are We Setting up the Shadow? We are asking Core Animation to generate the shadow CALayer *imageviewlayer = cell.imageview.layer; imageviewlayer.shadowcolor = [UIColor blackcolor].cgcolor; imageviewlayer.shadowopacity = 1.0; imageviewlayer.shadowradius = 2.0; imageviewlayer.shadowoffset = CGSizeMake(1.0, 1.0);

How Are We Setting up the Shadow? We are asking Core Animation to generate the shadow CALayer *imageviewlayer = cell.imageview.layer; imageviewlayer.shadowcolor = [UIColor blackcolor].cgcolor; imageviewlayer.shadowopacity = 1.0; imageviewlayer.shadowradius = 2.0; imageviewlayer.shadowoffset = CGSizeMake(1.0, 1.0); Perhaps there is a more efficient way imageviewlayer.shadowpath = CGPathCreateWithRect(imageRect, NULL);

Color Offscreen-Rendered Yellow Core Animation instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Awesome Can we ship it now?

Measure Frame Rate on iphone 4s OpenGL ES Driver instrument

Measure Frame Rate on iphone 4s OpenGL ES Driver instrument

Measure Frame Rate on iphone 4s OpenGL ES Driver instrument

Fictitious Photo Application Performance across devices CA Shadow 45 55 60 iphone 5s iphone 5 iphone 4s ipod touch 33 60 shadowpath 60 60 15 30 45 60 Frame Rate (target is 60 fps) 60

Awesome Ship it

Fictitious Photo Application Summary Offscreen passes are expensive Use Core Animation instrument to find them Know what you can do to avoid them Measure performance across different devices Use OpenGL ES Driver instrument for GPU time Use Time Profiler instrument for CPU time Know your view hierarchy and any hidden costs This is especially true for table cells and scrolling

Fictitious Contacts Application Case study Simple table view Each cell shows a round thumbnail and some text

Fictitious Contacts Application Performance across devices 60 iphone 5s iphone 5 iphone 4s ipod touch 60 55 46 15 30 45 60 Frame Rate (target is 60 fps)

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Color Offscreen-Rendered Yellow Core Animation instrument

How Are We Achieving Round Thumbnails?

How Are We Achieving Round Thumbnails? We are asking Core Animation to mask the image CALayer *imageviewlayer = cell.imageview.layer; imageviewlayer.cornerradius = imageheight / 2.0; imageviewlayer.maskstobounds = YES;

How Are We Achieving Round Thumbnails? We are asking Core Animation to mask the image CALayer *imageviewlayer = cell.imageview.layer; imageviewlayer.cornerradius = imageheight / 2.0; imageviewlayer.maskstobounds = YES; Perhaps there is a more efficient way Don t mask on the fly, pre-generate thumbnails as round, or

How Are We Achieving Round Thumbnails? We are asking Core Animation to mask the image CALayer *imageviewlayer = cell.imageview.layer; imageviewlayer.cornerradius = imageheight / 2.0; imageviewlayer.maskstobounds = YES; Perhaps there is a more efficient way Don t mask on the fly, pre-generate thumbnails as round, or If that is not possible, fake it - Table background is solid white - Render a white inverted circle on top of square thumbnail asset - Reducing offscreen passes but increasing blending, still a net performance win

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Measure Frame Rate on ipod touch OpenGL ES Driver instrument

Fictitious Contacts Application Performance across devices before 55 60 60 iphone 5s iphone 5 iphone 4s ipod touch 46 60 after 60 60 60 15 30 45 60 Frame Rate (target is 60 fps)

Fictitious Contacts Application Summary Offscreen passes are expensive Use Core Animation instrument to find them Know what you can do to avoid them Measure performance across different devices Use OpenGL ES Driver instrument for GPU time Use Time Profiler instrument for CPU time Know your view hierarchy and any hidden costs This is especially true for table cells and scrolling

Performance Investigation Mindset Summary What is the frame rate? CPU or GPU bound? Any unnecessary CPU rendering? Too many offscreen passes? Too much blending? Any strange image formats or sizes? Any expensive views or effects? Anything unexpected in hierarchy? Core Animation or OpenGL ES Driver instrument OpenGL ES Driver and Time Profiler instrument Time Profiler instrument Core Animation instrument Core Animation instrument Core Animation instrument Xcode View Debugger Xcode View Debugger

Summary Core Animation pipeline Rendering concepts UIBlurEffect UIVibrancyEffect Profiling tools Case studies

More Information Jake Behrens App Frameworks Evangelist behrens@apple.com Dave DeLong Developer Tools Evangelist delong@apple.com Documentation Core Animation http://developer.apple.com/library/ios/documentation/cocoa/conceptual/ CoreAnimation_guide/Introduction/Introduction.html Apple Developer Forums http://devforums.apple.com

Related Sessions Improving Your App with Instruments Marina Tuesday 4:30PM Debugging in Xcode 6 Marina Wednesday 10:15AM Writing Energy Efficient Code, Part 1 Russian Hill Wednesday 10:15AM Writing Energy Efficient Code, Part 2 Russian Hill Wednesday 11:30AM Creating Custom ios User Interfaces Marina Wednesday 3:15PM Building Interruptible and Responsive Interactions Presidio Friday 11:30AM

Labs Core Animation and Quartz 2D Lab Graphics and Games Lab A Tuesday 2:00PM Interface Builder and Live Views Lab Tools Lab C Wednesday 9:00AM Power and Performance Lab Core OS Lab B Wednesday 2:00PM Dynamics, View Animations, and Core Animation Lab Frameworks Lab A Thursday 9:00AM Power and Performance Lab Core OS Lab A Thursday 3:15PM Visual Effects and Appearance Customization Lab Frameworks Lab A Friday 9:00AM