Wednesday, November 23, 2011

[Gd] Making Android Games that Play Nice

| More

Android Developers Blog: Making Android Games that Play Nice

[This post is by Ian Ni-Lewis, a Developer Advocate who devotes most of his time to making Android games more awesome. — Tim Bray]

Making a game on Android is easy. Making a great game for a mobile, multitasking, often multi-core, multi-purpose system like Android is trickier. Even the best developers frequently make mistakes in the way they interact with the Android system and with other applications — mistakes that don’t affect the quality of gameplay, but which affect the quality of the user’s experience in other ways.

A truly great Android game knows how to play nice: how to fit seamlessly into the system of apps, services, and UI features that run on Android devices. In this multi-part series of posts, Android Developer Relations engineers who specialize in games explain what it takes to make your game play nice.

I: The Audio Lifecycle (or, why is there music coming from my pants?)

One of the most awesome things about Android is that it can do so much stuff in the background. But when apps aren’t careful about their background behaviors, it can get annoying. Take my own personal pet peeve: game audio that doesn’t know when to quit.

The problem

I’m on the bus to work, passing the time with a great Android game. I’m completely entranced by whatever combination of birds, ropes, and ninjas is popular this week. Suddenly I panic: I’ve almost missed my stop! I leap up, quickly locking my phone as I shove it into a pocket.

I arrive breathless at my first meeting of the day. The boss, perhaps sensing my vulnerability, asks me a tough question. Not tough enough to stump me, though — I’ve got the answer to that right here on my Android phone! I whip out my phone and press the unlock button... and the room dissolves in laughter as a certain well-known game ditty blares out from the device.

The initial embarrassment is bad enough, but what’s this? I can’t even mute the thing! The phone is showing the lock screen and the volume buttons are inactive. My stress level is climbing and it takes me three tries to successfully type in my unlock code. Finally I get the thing unlocked, jam my finger on the home button and breathe a sigh of relief as the music stops. But the damage is done — my boss is glowering and for the rest of the week my co-workers make video game noises whenever they pass my desk.

What went wrong?

It’s a common mistake: the developer of the game assumed that if the game received an onResume() message, it was safe to resume audio. The problem is that onResume() doesn’t necessarily mean your app is visible — only that it’s active. In the case of a locked phone, onResume() is sent as soon as the screen turns on, even though the phone’s display is on the lock screen and the volume buttons aren’t enabled.

Fixing this is trickier than it sounds. Some games wait for onWindowFocusChanged() instead of onResume(), which works pretty well on Gingerbread. But on Honeycomb and higher, onWindowFocusChanged() is sent when certain foreground windows — like, ironically, the volume control display window — take focus. The result is that when the user changes the volume, all of the sound is muted. Not the developer’s original intent!

Waiting for onResume() and onFocusChanged() seems like a possible fix, and it works pretty well in a large number of cases. But even this approach has its Achilles’ heel. If the device falls asleep on its own, or if the user locks the phone and then immediately unlocks it, your app may not receive any focus changed messages at all.

What to do about it

Here’s the easy two-step way to avoid user embarrassment:

  1. Pause the game (and all sound effects) whenever you receive an onPause() message. When gameplay is interrupted — whether because the phone is locked, or the user received a call, or for some other reason — the game should be paused.

  2. After the game is paused, require user input to continue. The biggest mistake most game developers make is to automatically restart gameplay and audio as soon as the user returns to the game. This isn’t just a question of solving the “music over lock screen” issue. Users like to come back to a paused game. It’s no fun to switch back to a game, only to realize you’re about to die because gameplay has resumed before you expected it.

Some game designers don’t like the idea of pausing the background music when the game is paused. If you absolutely must resume music as soon as your game regains focus, then you should do the following:

  1. Pause playback when you receive onPause().

  2. When you receive onResume():

    1. If you have previously received an onFocusChanged(false) message, wait for an onFocusChanged(true) message to arrive before resuming playback.

    2. If you have not previously received an onFocusChanged(false) message, then resume audio immediately.

  3. Test thoroughly!

Fixing audio embarrassments is almost always a quick and easy process. Take the time to do it right, and your users will thank you.


[Gd] Beta Channel Update for Chromebooks

| More

Chrome Releases: Beta Channel Update for Chromebooks

The Google Chrome team is happy to announce the release of Chrome 16 on the Beta Channel for Chromebooks (Acer AC700, Samsung Series 5, and Cr-48).

Chrome version 16.0.912.44 (Platform version: 1193.65.0)

Release highlights:
  • Update Pepper Flash
  • New 3-part version numbering format for Chrome OS. As always, please include the Chrome version as well as the Chrome OS version in any issues you file.
  • Cisco L2TP over IPSec is now supported
  • The Entd Enterprise extension is no longer used
  • Numerous stability & security fixes
Known issues:
  • 22372 - Renderer crash
  • 19788 - Sync is disabled after any crash
  • 20511 - Two finger scrolling does not always work smoothly (all Chromebook platforms)
  • 22263 - Copy & Paste creates file with different permissions than regular download flow
  • 22268 - May encounter connection error on first sign-in with 2-factor sign-in enabled
  • 23147 - Signing in with custom encryption password may request password several times. Workaround: Go to the Settings menu by going to chrome://settings/syncSetup
If you find new issues, please let us know by visiting our help site or filing a bug. Interested in switching channels? Find out how. You can submit feedback using ‘Report an issue’ under the wrench menu.

Danielle Drew
Google Chrome

Tuesday, November 22, 2011

[Gd] Dev Channel Update for Chromebooks

| More

Chrome Releases: Dev Channel Update for Chromebooks

The Dev channel has been updated to 17.0.942.0 (Platform version: 1324.0.0) for Chromebooks (Acer AC700, Samsung Series 5, and Cr-48).

Known issues:
  • Issue 22949Repositioning of bookmarks results is in bookmark duplicate
  • Issue 22950Chrome crashes when uploading picture to picasa album

If you find new issues, please let us know by visiting our help site or filing a bug. You can also submit feedback using "Report an issue" under the wrench icon. Interested in switching to the Dev channel? Find out how.

Orit Mazor
Google Chrome

[Gd] More flexibility for promotions

| More

Custom Search Engine: More flexibility for promotions

Custom Search promotions enable you to put relevant information at the top of your search results for specific queries.


Today, we’re announcing several new features to give you more flexibility on how and when to trigger them.

Regular expressions:  Use regular expressions instead of verbatim query matches to make it easier to display your promotions for all relevant user queries.

Promotion URL and titles based on the user’s query:  Instead of manually adding and maintaining a long list of similarly structured URLs and promotion titles, now you can use the $q variable in your promotion URL or title to replace it with the user’s query.

Enable/disable individual promotions:  Manually enable or disable each promotion without affecting the others.

Promotions for Custom Search engines created in AdSense:  Promotions now work for these CSEs (though they are still managed via the CSE’s control panel on the Google Custom Search site).

We hope these new features make it easier for you to use promotions on your site.  For more details and instructions, please visit our help center.  Let us know what you think in our discussion forum.

Posted by: Weiyu Zhu, Software Engineer


[Gd] Say hello to your new one-stop shop for ads developer news

| More

AdWords API Blog: Say hello to your new one-stop shop for ads developer news

When we originally launched this blog in 2005, we sought to provide you with the most up-to-date information on the AdWords API, as well as useful resources to help with API development. Recently, we’ve realized that the content we produce can be shared between multiple Ads API developer communities and for this reason we have decided to create one central blog. With this in mind, we'll now be posting on the new Google Ads Developer blog. There, you'll also find information on our AdSense API, DoubleClick for Publishers API, DoubleClick for Advertisers API, and Google AdMob SDK products.

If you’re a subscriber of this blog, your feed will automatically be redirected, so you won't have to do a thing to keep getting the latest news. If you decide you'd like to subscribe to a particular label on the new blog (for example, only receive those posts labeled as "adwords_api"), you can choose to do that as well. Also, the old content of this blog is not going anywhere and will continue to be available, even after we switch to the new blog.

The Ads Developer blog will continue to be run by the same team, bringing you all the information you need as an ads developer. We look forward to seeing you over at

Posted by the AdWords API Team

[Gd] A game changer for interactive performance.

| More

Chromium Blog: A game changer for interactive performance.

Today we are announcing the release of Chrome’s new incremental garbage collector (GC) which dramatically improves interactive performance of web apps and HTML5 games.

The V8 project has made huge progress improving peak performance of web apps. With the advent of technologies like WebGL we’re seeing the emergence of highly interactive and graphically intensive apps, such as the new version of Google Maps, new games and demos. But with these new uses comes a need for better interactive performance in JavaScript.

Avoiding pauses is vital to achieving good interactive performance. Previously, garbage collection pause times depended on the amount of memory used. Therefore, large interactive apps were impacted by pauses that caused hiccuping. V8’s new GC reduces pause times dramatically while maintaining great peak performance and memory use.

To evaluate the new GC, we took the most memory intensive peak performance test from the V8 Benchmark Suite and used it to make a stress test for interactive performance. In our testing the maximum time to render a frame including pause time is reduced from 272ms to 50ms.

The new GC in Chrome improves interactive performance and opens up new possibilities for the interactive web. If you are developing highly interactive web apps or games, please try it out and share your experiences. It is available now on the dev channel.

Posted by Vyacheslav Egorov and Erik Corry, Software Engineers