Vapor Life

Vapor life... My life as it is, as it should be. *********************************************************************************************************** Life is something that happens when you can't get to sleep. Fran Lebowitz (1950 - )

Wednesday, November 18, 2009

So This Is why I let others work out the bugs first

I had said this before. So the dPhone super phone has had some camera glitch. It seems that for some reason the camera would not focus right, then it automagicly fixed itself. Everyone thought it was fixed overnight with some secret OTA firmware update.

Turns out, this is not the case. The real reason Per Giz:

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.

A commenter explained it this way:

It's not the DATE that it's relying on so much as the TIME. And on any modern OS, the same variable holds both the date and time, stored as one huge number, such as the number of milliseconds since zero-date. The date is actually calculated by dividing that number lots of times.

When you write routines that are time-dependent (such as "move the lens forward for 1/1000 of a second and re-sample the image"), you often write a loop that looks for a specific amount of time that's passed, then exit the loop.

You might end up with a routine that looks like this:

start the lens moving


while Now <>



stop the lens moving

sample the picture. If it's not focused, repeat the loop

If rounding occurs, TimePassed could get rounded down or up... if it's rounded down, then the loop will execute too long.

In the previous example, a rounding error could cause the camera to move the lens further than expected, causing the camera to move the lens all the way to its stop trying to focus. It'll then start moving the other way, but the rounding error STILL causes the lens to overshoot, causing the camera to hit the stop going the other way...

So what we end up with is a pattern of the lens moving back and forth, trying to focus and skipping the "sweet spot" as it goes.

OK so I am glad it was a simple explanation.



Post a Comment

<< Home