Google I/O 2008 – Dalvik Virtual Machine Internals
I’m gonna try this link again…
Yesterday, I posted this picture from the Snake game on my G1 phone:
I received this comment from Alex:
Snake with open/close is a memory leak . As a weather has nothing to do with Android just bad app.
Here is how I duplicate the bug:
Just repeat steps 2-3 a few times until it crashes, it usually takes a few tries. Is this a memory leak, as Alex suggests?
As you can see, this is an ArrayIndexOutOfBoundsException, not a memory leak. Here is the complete stack trace:
java.lang.ArrayIndexOutOfBoundsException
at com.example.android.snake.TileView.setTile(TileView.java:150)
at com.example.android.snake.SnakeView.updateApples(SnakeView.java:434)
at com.example.android.snake.SnakeView.update(SnakeView.java:405)
at com.example.android.snake.SnakeView.setMode(SnakeView.java:336)
at com.example.android.snake.SnakeView.onKeyDown(SnakeView.java:279)
at android.view.KeyEvent.dispatch(KeyEvent.java:718)
at android.view.View.dispatchKeyEvent(View.java:3154)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:734)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:734)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:734)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1589)
at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1084)
at android.app.Activity.dispatchKeyEvent(Activity.java:1856)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1560)
at android.view.ViewRoot.deliverKeyEvent(ViewRoot.java:1616)
at android.view.ViewRoot.deliverTrackballEvent(ViewRoot.java:1508)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1201)
at android.os.Handler.dispatchMessage(Handler.java:88)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3739)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
at dalvik.system.NativeStart.main(Native Method)
I find that most Android bugs occur when Activities pause and resume. Changing screen orientation is a great way to crash many applications. That’s because orientation changes trigger lifecycle events. These events will occur at inopportune moments, such as when you receive phone calls or the user hits the Home button.
Applications that do not properly react to onPause(), onResume(), and other such methods will eventually fail.
You can use the UI/Application Exerciser Monkey to stress test your application. In the emulator, you can simulate incoming phone calls, which will pause the current Activity. You should also open and close the keyboard — repeatedly — while your application is performing tasks.
In summary, you need to brutalize your applications. Try really, really hard to break them. Android is a challenging environment because you must carefully manage threads, react to a complex series of lifecycle events, and deal with limited resources.
A few minutes ago I tried to take a picture with my G1 phone. My phone failed:
So I grabbed my Canon PowerShot SD1100 camera and snapped the picture shown above. My Canon camera never shows a “Force Close” error. It just works. I expect the same user experience from my phone. Is that an unreasonable expectation?
Here is the Weather Channel Android application, one of the most popular apps in the Android Market. It Force Closes becomes unresponsive from time to time. To get this picture, I simply tapped the tabs quickly:
Next I opened the Snake game. I opened and closed the phone a few times and…well, you know what’s coming next:
This is not good enough.
I generally don’t pay attention to who follows me on Twitter. In fact, I have GMail automatically archive Twitter email notifications whenever someone new follows me. That bucket currently has 700+ unread messages. (I just checked so I could put a number in that sentence.)
This offends some people. They believe that by following you, you should in turn follow them back. You scratch my back, I’ll scratch yours. Twitter is weird like that.
So how do I decide who to follow? I generally follow these groups of people:
More and more, that last bullet is how I choose who to follow. If someone sparks my interest with a comment, I’ll click their profile and check out their time line and bio. If I like what I see, I’ll follow. It’s as simple as that.
If people spend a lot of time tweeting about religion, teabagging, or other things I don’t like, I silently un-follow. That stuff stresses me out, which kind of defeats the whole purpose of Twitter. For me, Twitter is a way to relieve stress and amuse myself.
Speaking of un-following, there are tools to notify you when someone un-follows. Last year someone (who I don’t know) send me a personal email telling me he was un-following me. It’s OK, really. You don’t need to tell people when you leave, just go away.
I believe people should not concern themselves with un-follows. Sanitizing your thoughts and censoring yourself is a great way to be boring on Twitter. Instead, just be yourself and have fun.
Well, it’s about time. You no longer have to use workarounds to put images into your messages or attach images when you really want to inline them. Just turn on “Inserting images” from the Labs tab under Settings, and you’ll see a new toolbar icon like this:
Nice improvement, though drag and drop is what we really want.
Posted via web from Eric Burke
I received a poor rating on my State Capitals application from "Raymond". He gives only 3 stars and writes (in the Android Market):
"You may ace your geography test, but you fail English: the correct spelling in this context is 'capitol'."
Actually, I am correct and Raymond is wrong. The capitol is the building in which a state legislature meets. The capital is a town or city that is the official seat of government in a political entity, such as a state or nation.
I used a dictionary and confirmed this before I wrote the app. If only I had his true identity, I could contact him about his mistake. For now, the best I can do is report his comment as spam.