Google I/O 2013 - Android Graphics Performance

Google for Developers · 82K views · 2013 · 39:36

Open on YouTube

Software performance & optimizationSoftware architecture & designSoftware (other)talkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering Android UI jank, animation, alpha and rendering performance questions, often citing specific advice from Chet Haase.

Recommended by 3 people across 3 different months, 2012 to 2016.

What it is

A Google I/O 2013 session in which Android UI graphics engineers Chet Haase and Romain Guy share tips, tools and techniques for getting smooth UI performance in Android apps. It covers rendering behavior, garbage collection, and details like how alpha and view layers affect drawing cost.

What people said

Strong rec Alex Lockwood · 2013-08 · Stack Overflow · on “Android fragment transition - avoiding GC during animation”

You are asking the wrong question... if the problem is that your animations are janky, then you should be asking " How can I take a deeper look into what is actually going on? " A few GC_FOR_ALLOC logs in your logcat is not enough information to analyze this issue. And if your app is suffering from performance at times, it is not because you forgot to call System.gc() , trust me. :) Obviously the best way to avoid garbage collection is to reduce the amount of object allocations in your application... that's a given. You can use the "Allocation Tracker" provided in DDMS to further analyze these issues if these problems are not immediately obvious. I would also recommend watching these videos.

Recommends Morrison Chang · 2012-06 · Stack Overflow · on “FPS testing in android application”

As mention by Guykun and kcoppock, if you are only using the View widgets or Canvas you normally don't look for FPS to determine visual performance. As you don't mention what you are doing other than 'not a game' you may want to review how Android does drawing. [LINK] Most of the performance issues come from doing stuff on the UI thread. Use Strict Mode for finding problems. [LINK] Also use the tools to find performance hot spots: [LINK] [LINK] [LINK] And if you want more details of what's going on under the hood see the Google IO session on what they did for Hardware Accelerated Rendering Google I/O 2011: Accelerated Android Rendering [LINK] Google has done additional work on UI performance

Recommends azizbekian · 2015-10 · Stack Overflow · on “Difference between setAlpha and setImageAlpha”

Chet Haase clarifies what @BladeCoder pointed out in Google I/O 2013 - Android Graphics Performance video [this video]

Cites Raghunandan · 2013-06 · Stack Overflow · on “Does single thread application utilize multi core in android?”

Yes. Android 3.0 is the first version of the platform designed to run on either single or multicore processor architectures. Even a single-threaded application can benefit from parallel processing on different cores . For example, if your application uses a media server, then the media processing and your UI rendering application logic can run on different cores at the same time. Also, the garbage collector can run on a different core . Say your using graphics. To render the same your app can use multi cores. You can check the same at the link below. [this video] (Graphics and performance) [LINK] Check this pdf. Scroll down to slide 22. Might be useful [LINK]

Cites EGHDK · 2013-11 · Stack Overflow · on “Android Custom View doesn't handle transparency/alpha the right way”

I'm drawing a custom view. In this view I use two different paint and path objects to paint to the canvas. I'm basically drawing two shapes that overlap. After I add alpha, the part of the view that is overlapped is darker than the rest of the image. This is undesired, but I'm not sure how to fix it. This is a clipping of my code to show how I'm using alpha in my NewButtonView.java Paint paint = new Paint(); int color = 0x33ffffff; int borderColor = 0xFF000000; paint.setColor(color); paint.setAntiAlias(true); paint.setStrokeWidth(strokeWidth); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); paint.setStyle(Paint.Style.FILL); About 31 minutes into this Google I/O vi

Cites jeff · 2015-01 · Stack Overflow · on “How to animate ImageAlpha of ImageView”

Since API16 ImageView.setImageAlpha(int) should be used instead of View.setAlpha(float) for better performance. But how can I animate that value? I tried ValueAnimator without success. ObjectAnimator.ofInt(imageView, "imageAlpha", 0).start(); I mean what Chet Haase is talking about here [this video]

Cites Morrison Chang · 2015-03 · Stack Overflow · on “Android Development: App is lagging when ontouch listener is inactive”

Just making sure you are aware of the Google IO sessions on Project Butter: [LINK] and Graphics Performance: [this video] Without code no one can tell what is going on. You might want to look at one of the earliest Android sample apps which did air hockey over bluetooth - not sure if it works anymore but the source is there: [LINK]

Cites Ali Kazi · 2016-06 · Stack Overflow · on “How to grey out a button?”

All given answers work fine, but I remember learning that using setAlpha can be a bad idea [this video] performance wise (more info here [LINK] ). So creating a StateListDrawable [LINK] is a better idea to manage disabled state of buttons. Here's how: Create a XML btn_blue.xml in res/drawable folder: <selector xmlns:android=" [LINK] "> <!-- Disable background --> <item android:state_enabled="false" android:color="@color/md_blue_200"/> <!-- Enabled background --> <item android:color="@color/md_blue_500"/> </selector> Create a button style in res/values/styles.xml <style name="BlueButton" parent="ThemeOverlay.AppCompat"> <item name="colorButtonNormal">@drawable/btn_blue</item> <item name="android:t