The Real Reason the Droid's Camera Fixed Itself

Illustration for article titled The Real Reason the Droid's Camera Fixed Itself

When the Droid was shipped, it was plagued with a lousy autofocus bug. But then, it magically seemed to fix itself. Did Verizon secretly update all the phones from afar? Nope. The explanation is much weirder than that.

There's a rounding-error bug in the camera driver's autofocus routine (which uses a timestamp) that causes autofocus to behave poorly on a 24.5-day cycle. That is, it'll work for 24.5 days, then have poor performance for 24.5 days, then work again.

The 17th is the start of a new "works correctly" cycle, so the devices will be fine for a while. A permanent fix is in the works.

But of course! I understand perfectly why a camera would be dependent on the date. Chances are good that this will have a legit fix before 24.5 days are up, but man, what a weird bug. [Engadget via GadgetLab]

Share This Story

Get our `newsletter`

DISCUSSION

elliuotatar-old
Elliuotatar

I am a programmer and I think I can explain this bug.

Autofocus is probably choosing to sample the scene X times a second or something. To do this, it would read the system clock to dtermine how much time has passed to see if it should take a new sample. This clock would measure time in milliseconds, and the result here is probably stored in a long integer.

A long integer can have a value from −2,147,483,648 to 2,147,483,647. If you multiply 1000 milliseconds in a second, by 60 seconds in a minute, by 60 minutes in an hour by 24 hours in a day, you get 86400000 milliseconds in a day. And if you then divide 2,147,483,647 by this, you get 24.85.

The problem would likely occur when the millisecond timer goes negative. Their algorithm probably can't handle that, and either fails to take several samples as needed, or takes too many too rapidly.

At least, that's my best guess. I can't see any other reason to use a timer, and the timeframe for the rollover there being so close to their quoted time seems too unlikely to be a coincidence.