Loading...
Home
  • Tech Blogs
  • Videos
  • Conferences
    • Droidcon News
    • Upcoming Conferences
    • Become a Partner
    • Past Events
    • Keep Me Informed
    • Diversity Scholarships
  • Community
    • droidcon Team
    • How to Hold a Droidcon
  • Android Careers
Sign In

Global CSS

 

A Battle towards Performance- Understanding Systrace and Overdraw (Part -2)

 

 
Niharika Arora
A passionate Android Geek who loves to play with code. Do reach me out here: www.linkedin.com/in/niharika-arora-4874967a
Published: August 24, 2020
Tweet
Share
 

GPU overdraw

 

In the last article, I showed off my love for fashion which lead me to correlate it with the topic at hand i.e, how UI is created and what will be the impact of view lifecycle methods in the context of various layouts. In this blog, I will be discussing various tools I used to measure performance-

  • GPU overdraw
  • Systrace

But before going into performance metrics, one should know the 16 ms/frame logic.

 

Human eyes and 16 ms per refresh

The human brain receives and processes visual information continuously. This allows us some cool tricks. For example, when still images are displayed to follow each other fast enough, we perceive them as motion. A flipbook is a good example that’s just at the edge of perception.

 

Image for post

Flip Book

 

Flip books are just at the edge of what humans perceive as motion.

  • At about 10–12 pages per second, there is clearly motion, but you also retain awareness of individual pages.
  • 24 pages per second allow the human eye to see fluid motion, thanks to technologies such as motion blurring, which help you perceive motion when you should just see each individual frame of the animation. 24 images per second is a sweet spot for the film industry since it’s fast enough to show motion but cheap enough to produce films on a budget.
  • 30 pages per second is sufficient, but not life-like. It is enough for movies, but without fancy cinematic effects, it’s not convincing.
  • 60 pages per second is ideal, as most people see this as high-quality, smooth motion.

 

GPU Overdraw

Overdraw as the name suggests is a term used to describe how many times a pixel on the screen has been redrawn in a single frame. Imagine painting a room and re-painting it all over again; this results in wasting time and energy to paint the room the first time. With overdraw in Android, we waste GPU time by coloring the pixels on the screen that end up being colored again by something else later.

Fortunately, we can detect re-painting in android by selecting “Show overdraw areas” in “Debug GPU overdraw” under “Developer options” in phone settings.

 

Image for post

GPU Overdraw

 

The colors are hinting at the amount of overdraw on your screen for each pixel, as follows:

  • True colour: No overdraw
  • Blue: Overdrawn once
  • Green: Overdrawn twice
  • Pink: Overdrawn thrice
  • Red: Overdrawn four or more times

We can prevent this re-painting by keeping the following things in mind -

  • If you are using unnecessary background(transparent/white/Common background), remove that immediately.
  • Flatten the hierarchy as much as possible

 

Systrace

Systrace(Android System Trace) captures and displays the execution time of your app’s processes and other Android system processes, which helps you analyze the performance of your app. The tool combines data from the Android kernel such as the CPU scheduler, disk activity, and app threads. The tool uses this data to generate an HTML report that shows an overall picture of an Android-powered device’s system processes for a given period of time.

 

Image for post

Systrace Output(trace.html)

 

What you should do

  • Find the Frames section in the Systrace output and get more information about specific frames.
  • Examine the alerts, which show potential performance issues with your code.

 

Running Systrace through Command Line

I always prefer the command line(terminal) over UI frameworks as terminal always gives you more power than a UI framework possesses.

To generate the HTML report for the app, you need to run systrace from the command line using the following syntax:

 

python systrace.py [options] [categories]

 

Capturing a System Trace on Device

For Android 9 or higher, we already have the System Tracing app which works exactly the same way command-line utility works.

Developer Options -> Debugging -> System Tracing ->Record trace -> Do some Actions in your app -> Stop Trace -> Share Trace (.perfetto-trace)-> Open on Perfetto UI

 

Image for post

 

The image displays a part of the Systrace output. The numbers have the following meanings:

  1. Section for each process
  2. Frames section
  3. Frame indicator for a frame that rendered successfully
  4. Frame indicator for a frame that did not completely render
  5. Method calls for rendering selected frame

Let me explain some of the key points -

  1. In the Frames line, on the graph to the right, you should see circles that are either green or red and are labelled with the letter F for Frame. You may need to zoom in (w on the keyboard) and pan right (d on the keyboard) to see individual, labelled circles.
  2. Select a green circle. This frame is green because it completed rendering in the allotted time slot of 16 milliseconds per frame.
  3. Select a red circle. This frame is red because it did not complete rendering within 16 milliseconds.
  4. On the left-hand pane, scroll down if necessary until you find Render Thread. On devices running Android 5.0 (API level 21) or higher, this work is split between the UI Thread and RenderThread. On prior versions, all work for creating a frame is done on the UI thread. If you do not see Render Thread, select UI Thread instead.
  5. Click on the black triangle to the right of Render Thread to expand the graph. This expands the bars that show you how much time was spent in each system action involved in rendering this frame.
  6. Open the Alerts tab on the right edge of the trace window. Click on an Alert type to see a list of all alerts in the bottom pane. Click an alert to see details, a description of what may be the problem, and links to further resources.

To get into more detail on how systrace works, Please go through this link.

Originally published here.

In the next blog, I will be sharing the results I got after testing similar screens with different layouts.

Please feel free to share your views and feedback in the comments section below.

 

If you liked this blog, hit the 👏 . Stay tuned for the next one!

 

 

 

Tags: Android, Performance, Android Layout, Constraintlayout, Layout

 

View original article at: 


 

Originally published: November 18, 2019

Android News
Our Engineering Roadmap
Our Engineering Roadmap

By Mark Ng

We just completed our engineering road map for our Android apps at Australia Post. Each year we get together and try to decide on what we are going to do from an engineering perspective for the next 12 months. Each team gets to decide on what should be done now, what they want to complete by the end of the year and whats on the horizon for next year.

By ProAndroidDev -
Android News
Android Activity Lifecycle considered harmful
Android Activity Lifecycle considered harmful

By Eric Silverberg

The Android activity lifecycle is one of the first architectural concepts learned by a new Android developer. Ask any Android dev and they’ll likely all have seen this handy diagram from Google: 

By ProAndroidDev -
Android News
Our Safe Approach to Android Jetpack Navigation in a Multi-Modular App
Our Safe Approach to Android Jetpack Navigation in a Multi-Modular App

By Alejandro Weichandt

It has been a year since we started working on the Android version of the mobile app at Sync. During that year, we faced more than once that moment when we had to choose which path to follow on an Architectural decision. This story is about Navigation.

By ProAndroidDev -
Android News
Custom KotlinX Serializers
Custom KotlinX Serializers

By Jobin Lawrance

Let’s say we have a third-party class that we are using as a type in one of our data class that we want to be serialized, then we have to write a custom serializable for @Serializable to work.

 

By ProAndroidDev -
droidcon News

Tech Showcases,

Developer Resources &

Partners

/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/home-details/EmployerBrandingHeader
EmployerBrandingHeader
https://jobs.droidcon.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/jobs-droidcon/jobs.droidcon.com
jobs.droidcon.com

Latest Android Jobs

http://www.kotlinweekly.net/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/kotlin-weekly/Kotlin Weekly
Kotlin Weekly

Your weekly dose of Kotlin

https://proandroiddev.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/pad/ProAndroidDev
ProAndroidDev

Android Tech Blogs, Case Studies and Step-by-Step Coding

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
Zalando

Meet one of Berlin's top employers

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
Academy for App Success

Google Play resources tailored for the global droidcon community

Follow us

Team droidcon

Get in touch with us

Write us an Email

 

 

Quicklinks

> Code of Conduct

> Terms and Conditions

> How to hold a conference

> FAQs

> Imprint

Droidcon is a registered trademark of Mobile Seasons GmbH Copyright © 2020. All rights reserved.

powered by Breakpoint One