SlideShare a Scribd company logo
1 of 22
Download to read offline
The Road to 60 FPS
Jason Sendros
Why care?
Android Frame Rendering Deep Dive
What happens on the UI thread?
VSync
Input
Animation
Draw
Frame 1 Frame 2 Frame 3
Get used to this guy
60FPS is inaccurate
Galaxy Core 2
33fps
Nexus 5
60fps
55fps
Nexus 4
60fps
49fps
How do you measure a skipped frame?
Choreographer
▪  FrameCallback
▪  Delivered during the next
frame’s animation callback
▪  Measure the difference
between two inputs
VSync
Input
Animation
Draw
17ms 17ms17ms
Choreographer
VSync
Input
Animation
Draw
17ms 33ms17ms
draw draw drawdrop draw
17ms
public	
  interface	
  FrameCallback	
  {	
  
	
  	
  	
  	
  /**	
  
	
  	
  	
  	
  	
  *	
  @param	
  frameTimeNanos	
  The	
  time	
  in	
  nanoseconds	
  when	
  the	
  frame	
  started	
  being	
  rendered	
  
	
  	
  	
  	
  	
  */	
  
	
  	
  	
  	
  void	
  doFrame(long	
  frameTimeNanos);	
  
}	
  
mFPSMeasuringCallback	
  =	
  new	
  Choreographer.FrameCallback()	
  {	
  
	
  	
  @Override	
  
	
  	
  public	
  void	
  doFrame(long	
  frameTimeNanos)	
  {	
  
	
  	
  	
  	
  	
  long	
  frameTimeMs	
  =	
  nsToMs(frameTimeNanos);
	
  	
  	
  	
  if	
  (mLastFrameTimeMs	
  ==	
  FIRST_FRAME)	
  {	
  
	
  	
  	
  	
  	
  	
  mLastFrameTimeMs	
  =	
  frameTimeMs;	
  
	
  	
  	
  	
  	
  	
  mChoreographer.postFrameCallback(mFPSMeasuringCallback);	
  
	
  	
  	
  	
  	
  	
  return;	
  
	
  	
  	
  	
  }
	
  	
  	
  	
  long	
  milliSecondDelay	
  =	
  frameTimeMs	
  -­‐	
  mLastFrameTimeMs;	
  
	
  	
  	
  	
  mLastFrameTimeMs	
  =	
  frameTimeMs;	
  
	
  	
  	
  	
  onFrameRendered(milliSecondDelay);	
  
	
  
	
  	
  	
  	
  mChoreographer.postFrameCallback(mFPSMeasuringCallback);	
  
	
  	
  }	
  
};
First frame!
Report time between frames
Always post the callback
An FPS measuring API
public	
  void	
  enable()	
  {	
  
	
  	
  	
  	
  mLastFrameTimeMs	
  =	
  FIRST_FRAME;	
  
	
  	
  	
  	
  mChoreographer.postFrameCallback(mFPSMeasuringCallback);	
  
}	
  
public	
  void	
  disable()	
  {	
  
	
  	
  	
  	
  mChoreographer.removeFrameCallback(mFPSMeasuringCallback);	
  
	
  	
  	
  	
  report();	
  
}	
  
A Reasonable Metric
Percent time spent dropping 2+ frames*
VSync
Input
Animation
Draw
0
<2 dropped frames = 6/11 = 55%
2+ dropped frames = 5/11 = 45%
4 dropped* 1 dropped 0 0 0
*rendered on the 5th frame
*…reasonable?
How does Facebook blame jank?
AutoBlame
▪  Must be lightweight
▪  High level
▪  Will not blame every slow frame
▪  Not perfect
VSync
Input
Animation
Draw
Expensive Work Marker
AutoBlame*
Year Class Slow time GC getView notifyDSC
2012 16% 6% 50% 16%
2014 22% 12% 44% 12%
*surprisingly accurate
AutoProfiler
VSync
Input
Animation
Draw
Expensive Work
AutoProfiler*
Method Time
com/android/widget/RecyclerView.onScrolled 16%
> com/facebook/logging/FeedLogger.onScroll 10%
> com/facebook/feed/NewsFeedFragment.maybeFetch 3.3%
>> com/facebook/feed/NewsFeedRecyclerView.notifyDataSetChange 3%
>> com/facebook/feed/FetchController.shouldFetch .3%
> com/facebook/prefetch/ImagePrefetcher.onScroll 2.7%
*totally made up shit
AutoProfiler
for	
  i	
  in	
  range(20):	
  
	
  	
  	
  	
  time.sleep(1)	
  
	
  	
  	
  	
  device.drag((start_x,	
  start_y),	
  (stop_x,	
  stop_y),	
  0.1,	
  15)	
  
Traceview sample based profiling
MonkeyRunner Script
Left as an exercise to the developer Post-process Traceview file
Systrace
▪  Add your own markers
▪  Sample base profiling
VSync
Input
Animation
Draw
Expensive Work
Marker
How can I quickly improve performance?
▪  Ideal Profiling Device
▪  Nexus 4
▪  KitKat
▪  Systrace
▪  Custom markers for problem areas
▪  Sample based profiling
▪  Find an interaction or event which consistently causes lag or jitter
and profile it
Questions?
jsendros

More Related Content

Viewers also liked

Ультразвуковой идентификатор
Ультразвуковой идентификаторУльтразвуковой идентификатор
Ультразвуковой идентификаторkulibin
 
Grafico diario del dax perfomance index para el 08 03-2012
Grafico diario del dax perfomance index para el 08 03-2012Grafico diario del dax perfomance index para el 08 03-2012
Grafico diario del dax perfomance index para el 08 03-2012Experiencia Trading
 
Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...
Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...
Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...France Stratégie
 
Dailymotion
DailymotionDailymotion
DailymotionWDPM
 
Megan Scherer Resume
Megan Scherer ResumeMegan Scherer Resume
Megan Scherer ResumeMegan Scherer
 
Entrepreneurial ldrshp(risk-return-apetite)
Entrepreneurial ldrshp(risk-return-apetite)Entrepreneurial ldrshp(risk-return-apetite)
Entrepreneurial ldrshp(risk-return-apetite)Bill Asbi
 
Os novos desafios para a implantação de programas de gestão arquivística de d...
Os novos desafios para a implantação de programas de gestão arquivística de d...Os novos desafios para a implantação de programas de gestão arquivística de d...
Os novos desafios para a implantação de programas de gestão arquivística de d...Daniel Flores
 
Celebrity plastic surgery before and after
Celebrity plastic surgery before and afterCelebrity plastic surgery before and after
Celebrity plastic surgery before and afterThebooth fairy
 
Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...
Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...
Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...Birgit Pauli-Haack
 

Viewers also liked (12)

Ультразвуковой идентификатор
Ультразвуковой идентификаторУльтразвуковой идентификатор
Ультразвуковой идентификатор
 
Grafico diario del dax perfomance index para el 08 03-2012
Grafico diario del dax perfomance index para el 08 03-2012Grafico diario del dax perfomance index para el 08 03-2012
Grafico diario del dax perfomance index para el 08 03-2012
 
Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...
Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...
Avis du Haut conseil pour l’avenir de l’assurance maladie - Innovations et sy...
 
Hari kantin
Hari kantinHari kantin
Hari kantin
 
Dailymotion
DailymotionDailymotion
Dailymotion
 
JetFuel
JetFuelJetFuel
JetFuel
 
Megan Scherer Resume
Megan Scherer ResumeMegan Scherer Resume
Megan Scherer Resume
 
Entrepreneurial ldrshp(risk-return-apetite)
Entrepreneurial ldrshp(risk-return-apetite)Entrepreneurial ldrshp(risk-return-apetite)
Entrepreneurial ldrshp(risk-return-apetite)
 
Os novos desafios para a implantação de programas de gestão arquivística de d...
Os novos desafios para a implantação de programas de gestão arquivística de d...Os novos desafios para a implantação de programas de gestão arquivística de d...
Os novos desafios para a implantação de programas de gestão arquivística de d...
 
Pei uts (2012)
Pei   uts  (2012)Pei   uts  (2012)
Pei uts (2012)
 
Celebrity plastic surgery before and after
Celebrity plastic surgery before and afterCelebrity plastic surgery before and after
Celebrity plastic surgery before and after
 
Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...
Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...
Google Analytics - Tool to Track and Analyze the Performanece of Your Inbound...
 

Similar to The Road to 60 FPS: A Guide to Android Frame Rendering and Performance Measurement

What is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionWhat is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionIgalia
 
Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Unity Technologies
 
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016Rami Sayar
 
WebGL visualization of a shipping terminal
WebGL visualization of a shipping terminalWebGL visualization of a shipping terminal
WebGL visualization of a shipping terminalJosh Staples
 
Flex 4 Component Lifecycle
Flex 4 Component LifecycleFlex 4 Component Lifecycle
Flex 4 Component LifecycleMrinal Wadhwa
 
Academy PRO: React native - publish
Academy PRO: React native - publishAcademy PRO: React native - publish
Academy PRO: React native - publishBinary Studio
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Controlbhochhi
 
OpenMP for beginners
OpenMP for beginnersOpenMP for beginners
OpenMP for beginnersWoohyunKim16
 
Augmented Reality in JavaScript
Augmented Reality in JavaScriptAugmented Reality in JavaScript
Augmented Reality in JavaScriptZeno Rocha
 
Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Michał Kłoś
 
Breathing the life into the canvas
Breathing the life into the canvasBreathing the life into the canvas
Breathing the life into the canvasTomislav Homan
 
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSocketsBuilding Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSocketsBen Limmer
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 
Custom Components In Flex 4
Custom Components In Flex 4Custom Components In Flex 4
Custom Components In Flex 4Mrinal Wadhwa
 
Running HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fpsRunning HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fpsApoorv Saxena
 
Explaining the decisions of image/video classifiers
Explaining the decisions of image/video classifiersExplaining the decisions of image/video classifiers
Explaining the decisions of image/video classifiersVasileiosMezaris
 

Similar to The Road to 60 FPS: A Guide to Android Frame Rendering and Performance Measurement (20)

What is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 editionWhat is new with JavaScript in Gnome: The 2021 edition
What is new with JavaScript in Gnome: The 2021 edition
 
Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019
 
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
 
WebGL visualization of a shipping terminal
WebGL visualization of a shipping terminalWebGL visualization of a shipping terminal
WebGL visualization of a shipping terminal
 
Flex 4 Component Lifecycle
Flex 4 Component LifecycleFlex 4 Component Lifecycle
Flex 4 Component Lifecycle
 
Academy PRO: React native - publish
Academy PRO: React native - publishAcademy PRO: React native - publish
Academy PRO: React native - publish
 
Beyond 60fps
Beyond 60fpsBeyond 60fps
Beyond 60fps
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Control
 
OpenMP for beginners
OpenMP for beginnersOpenMP for beginners
OpenMP for beginners
 
Augmented Reality in JavaScript
Augmented Reality in JavaScriptAugmented Reality in JavaScript
Augmented Reality in JavaScript
 
Flex Monkey
Flex MonkeyFlex Monkey
Flex Monkey
 
Developing Async Sense
Developing Async SenseDeveloping Async Sense
Developing Async Sense
 
Ping to Pong
Ping to PongPing to Pong
Ping to Pong
 
Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4
 
Breathing the life into the canvas
Breathing the life into the canvasBreathing the life into the canvas
Breathing the life into the canvas
 
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSocketsBuilding Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSockets
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
Custom Components In Flex 4
Custom Components In Flex 4Custom Components In Flex 4
Custom Components In Flex 4
 
Running HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fpsRunning HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fps
 
Explaining the decisions of image/video classifiers
Explaining the decisions of image/video classifiersExplaining the decisions of image/video classifiers
Explaining the decisions of image/video classifiers
 

Recently uploaded

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 

Recently uploaded (20)

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 

The Road to 60 FPS: A Guide to Android Frame Rendering and Performance Measurement

  • 1. The Road to 60 FPS Jason Sendros
  • 4. What happens on the UI thread? VSync Input Animation Draw Frame 1 Frame 2 Frame 3 Get used to this guy
  • 5. 60FPS is inaccurate Galaxy Core 2 33fps Nexus 5 60fps 55fps Nexus 4 60fps 49fps
  • 6. How do you measure a skipped frame?
  • 7. Choreographer ▪  FrameCallback ▪  Delivered during the next frame’s animation callback ▪  Measure the difference between two inputs VSync Input Animation Draw 17ms 17ms17ms
  • 9. public  interface  FrameCallback  {          /**            *  @param  frameTimeNanos  The  time  in  nanoseconds  when  the  frame  started  being  rendered            */          void  doFrame(long  frameTimeNanos);   }  
  • 10. mFPSMeasuringCallback  =  new  Choreographer.FrameCallback()  {      @Override      public  void  doFrame(long  frameTimeNanos)  {            long  frameTimeMs  =  nsToMs(frameTimeNanos);        if  (mLastFrameTimeMs  ==  FIRST_FRAME)  {              mLastFrameTimeMs  =  frameTimeMs;              mChoreographer.postFrameCallback(mFPSMeasuringCallback);              return;          }        long  milliSecondDelay  =  frameTimeMs  -­‐  mLastFrameTimeMs;          mLastFrameTimeMs  =  frameTimeMs;          onFrameRendered(milliSecondDelay);            mChoreographer.postFrameCallback(mFPSMeasuringCallback);      }   }; First frame! Report time between frames Always post the callback
  • 11. An FPS measuring API public  void  enable()  {          mLastFrameTimeMs  =  FIRST_FRAME;          mChoreographer.postFrameCallback(mFPSMeasuringCallback);   }   public  void  disable()  {          mChoreographer.removeFrameCallback(mFPSMeasuringCallback);          report();   }  
  • 13. Percent time spent dropping 2+ frames* VSync Input Animation Draw 0 <2 dropped frames = 6/11 = 55% 2+ dropped frames = 5/11 = 45% 4 dropped* 1 dropped 0 0 0 *rendered on the 5th frame *…reasonable?
  • 14. How does Facebook blame jank?
  • 15. AutoBlame ▪  Must be lightweight ▪  High level ▪  Will not blame every slow frame ▪  Not perfect VSync Input Animation Draw Expensive Work Marker
  • 16. AutoBlame* Year Class Slow time GC getView notifyDSC 2012 16% 6% 50% 16% 2014 22% 12% 44% 12% *surprisingly accurate
  • 18. AutoProfiler* Method Time com/android/widget/RecyclerView.onScrolled 16% > com/facebook/logging/FeedLogger.onScroll 10% > com/facebook/feed/NewsFeedFragment.maybeFetch 3.3% >> com/facebook/feed/NewsFeedRecyclerView.notifyDataSetChange 3% >> com/facebook/feed/FetchController.shouldFetch .3% > com/facebook/prefetch/ImagePrefetcher.onScroll 2.7% *totally made up shit
  • 19. AutoProfiler for  i  in  range(20):          time.sleep(1)          device.drag((start_x,  start_y),  (stop_x,  stop_y),  0.1,  15)   Traceview sample based profiling MonkeyRunner Script Left as an exercise to the developer Post-process Traceview file
  • 20. Systrace ▪  Add your own markers ▪  Sample base profiling VSync Input Animation Draw Expensive Work Marker
  • 21. How can I quickly improve performance? ▪  Ideal Profiling Device ▪  Nexus 4 ▪  KitKat ▪  Systrace ▪  Custom markers for problem areas ▪  Sample based profiling ▪  Find an interaction or event which consistently causes lag or jitter and profile it