Fans of Apple’s mobile devices such as the iPhone, iPod touch and iPad often wonder why can’t scrolling on Android phones and tablets be jerk-free as on iOS devices. It’s been something of a mystery, especially taking into account how the original iPhone had nailed smoothness more than four years ago and on sub-par hardware which was substantially slower than the beefy chips powering today’s Android super phones.

Growing tired of misinformation about how graphics rendering works on Android, engineer Dianne Hackborn set the record straight today on Google+. Android has always used some hardware accelerated drawing, she began. “Since before 1.0 all window compositing to the display has been done with hardware”, Hackborn said.

Apple’s user interface has been hardware-accelerated thoroughly from day one, cynics might say. Truth be told, Apple designs the hardware, the chips and the operating system, allowing them to target iOS specifically for a specific CPU and GPU, a luxury Android does not have. Let’s not forget that Android does true multitasking and background processes execution, unlike iOS, which adds to the overhead. Also adding to the overhead: Native iOS apps are binaries pre-compiled for their own hardware while Android uses the Dalvik virtual machine with just-in-time compilation to run Dalvik dex-code (Dalvik Executable), which is usually translated from Java bytecode.

To be perfectly honest here, Google should be credited for treating each platform update as an opportunity to perfect the hardware acceleration features. For example, they just enabled smoother graphics in all Ice Cream Sandwich apps that rely on the new APIs.

In case you’ve been wondering, menus being shown, sliding the notification shade, transitions between activities, pop-ups and dialogs showing and hiding – Android does offload all those bells’n’whistles to the GPU. The speed of the GPU and the memory bus bandwidth directly impact the smoothness of the interface, Hackborn explained:

As device screen resolution goes up, achieving a 60fps UI is closely related to GPU speed and especially the GPU’s memory bus bandwidth. In fact, if you want to get an idea of the performance of a piece of hardware, always pay close attention to the memory bus bandwidth. There are plenty of times where the CPU (especially with those wonderful NEON instructions) can go a lot faster than the memory bus.

But the GPU “is not a magical silver bullet to butter-smooth UI”, she argues. The new Galaxy Nexus smartphone (9to5Google will be reviewing it shortly) uses a number of tricks to achieve smooth scrolling of lists, web pages and other content in apps, including turning off OpenGL hardware acceleration in parts of the interface that would otherwise cost 8MB of RAM and take away from other things, such as background process and multitasking. Provided the phone’s CPU is fast enough, it can draw graphics without the overhead of the GPU. And in the case of the Nexus S:

Nexus S has no trouble doing 60fps rendering of all the normal stuff you see in the Android UI like scrolling lists on its 800×480 screen. The original Droid however struggled with a similar screen resolution.

Summing up, hardware acceleration is not a be-all-end-all solution to the smooth user interface simply because there’s only that much a smartphone GPU can do. For example, Nvidia’s Tegra 2 GPU found in some Android smartphones can do every pixel of a 1280-by-800 screen about 2.5 times at 60 frames per second, leaving little room for complex, layered animations:

Now consider the Android 3.0 tablet home screen where you are switching to the all apps list: you need to draw the background (1x all pixels), then the layer of shortcuts and widgets (let’s be nice and say this is .5x all pixels), then the black background of all apps (1x all pixels), and the icons and labels of all apps (.5x all pixels). We’ve already blown our per-pixel budget, and we haven’t even composited the separate windows to the final display yet. To get 60fps animation, Android 3.0 and later use a number of tricks. A big one is that it tries to put all windows into overlays instead of having to copy them to the framebuffer with the GPU. In the case here even with that we are still over-budget, but we have another trick: because the wallpaper on Android is in a separate window, we can make this window larger than the screen to hold the entire bitmap. Now, as you scroll, the movement of the background doesn’t require any drawing, just moving its window… and because this window is in an overlay, it doesn’t even need to be composited to the screen with the GPU.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

12 Responses to “Google explains why Android animation speed is only now catching iOS”

  1. Har says:

    I blame Java.

  2. Scott says:

    Last weekend I spent £520 on a Galaxy Nexus, and I feel so stupid for doing so. I have been rooting for Android since the beginning, and have spent a small fortune on SIM free Android handsets. This will definitely be the last time even that I will be a pioneer and part with my hard earned cash for handsets that, quite frankly, feel 'second class'.

  3. The_Omega_Man says:

    Android does true multitasking and background processes execution, unlike iOS. This does not say that there in NO multi-tasking within iOS, just that it does not do true-multi-tasking like the Android OS does.

    • Sree says:

      Frankly, I believe iOS multitasking paradigm is much more advanced than android's. Android does brute-force multi tasking, there is no intelligence built-in on how to do it efficiently considering the fact that it is running on mobiles. It basically does the same thing on mobiles, what used to happen on desktops. iOS on the other hand has fine-tuned multi-tasking to an extent where it is efficient for the mobile world, the largest gain being in the battery life.

      • NagPer says:

        Indeed iOS does clever multitasking but there is a couple of things it simply cannot do. You can only use the background services their API offers; nothing else.

  4. Bea says:

    IOS does multitasking! I can't believe they wrote that it cannot.

  5. Ryan says:

    @Amber Android is on different devices from different manufacturers. Being open has it's benefits but also it's disadvantages. Since the iPhone hardware and software are controlled by Apple the experience can be tweaked to optimum performance. Since Android is so spread out, it's taking Google a bit longer to get it right.

    • Julian says:

      I don't think that's the reason. The problem, to me, is how Android was designed from the start, how they took shortcuts (in my laymen thinking) to quickly adapt to the touch interaction paradigm, and how that is now coming back to bite them in the rear.

      They put the UI processing in the main thread with normal priority, AFAIK. I believe that was a decision made back in the Android 1.0 days, for all the obvious reasons regarding the smartphone paradigm.

      When the touch input became standard, they took the easy road: instead of changing the core (not sure if that was even needed), they kept it the way it was, and hoped that the hardware would evolve quickly as to dismiss this nuisance.

      However, as we all know, the hw evolved, but the needs evolved too. Clearly it has been 3 years and the hardware didn't evolve quickly enough to mask this (see Galaxy Nexus early reports), and then MS saw the obvious and redesigned WP from scratch, leaving Android as the last big OS that is doing stuff "the old way". Not accounting that WP7 is "embarrassingly smooth" with much slower hardware.

      Here says an Android user with a Nexus S (i love it, by the way…) that came from a 3GS. And no, I wouldn't change because of that, but if the Android experience could be improved, I'd be all for it. Android is vastly more powerful (in what it can do) compared to all those others OSes. When I saw it from inside and experienced some of the complex apps in the Market, that became my opinion. Besides, it's open source and the development freedom they give you is second to none.

      In my laymen mind, I hope they can figure it out, if that is even possible under the current stack. My question is: back in the days when we were transitioning from 1.0 to 1.5, shouldn't they had took a little more time and do it thinking about the future? For example, I give props to Samsung for scratching the latest Galaxy Tab so they could build and beat (hw-wise) the iPad. No wonder the Tab is the Tab, and the Xoom is a dissapointment if it were not for being a "Nexus" tablet (see the latest Xooms and how they flopped).

  6. Amber says:

    Dont tell me why Android cant do it. Just Do IT! If Android is supposed to be so much more amazing than iOS with so much more powerful phones and they cant even match the glitch free scrolling then something major is wrong. I'm going to switch to Android soon to try it out and if it cant even handle basic graphic scrolling then the phone and OS are a joke. I expect Android and the Nexus to be a lot of steps ahead of the iphone 3gs I now have. If not then I will have to laugh in Androids face and be very disappointed. This article sounded like a lot of excuses.