Slashdot Mirror


Bizarre Droid Auto-Focus Bug Revealed

itwbennett writes "Pity the poor engineer who had to find this one. One of the more interesting of the handful of bugs that have appeared since the launch of Verizon's Droid smartphone has to do with the on-board camera's auto-focus. Apparently it just didn't work. And then suddenly it did. Naturally, this off-again, on-again made the theories fly. But the real reason for the bug was revealed in a comment on an Engadget post by someone claiming to be Google engineer Dan Morrill: '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,' said Morrill. '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.'"

43 of 275 comments (clear)

  1. When Signed/Unsigned Strikes by eldavojohn · · Score: 5, Informative

    It's all over the comments on the engadget page but since 2^31 milliseconds is about 24.5 days, it's highly probably we're dealing with a very classic not so funny sign extension bug here. So if I may presume the real problem, it's that autofocusing depends on catching timestamps from the system to know how long it's been since the last sampling in order to adjust the lens and check for accuracy. It's casting this to a signed 32 bit variable which means that during the 24.5 days it is miscast to a negative number, thus breaking the algorithm when it measures time deltas and causing it to mis focus before snapping the picture.

    The patch is simple, make that signed int something like an unsigned long or truncate it properly. Hopefully we're not waiting long.

    --
    My work here is dung.
    1. Re:When Signed/Unsigned Strikes by Whalou · · Score: 5, Funny

      Hopefully we're not waiting long.

      We're waiting unsigned long.

      --
      English is not this .sig mother tongue...
    2. Re:When Signed/Unsigned Strikes by rsborg · · Score: 5, Funny

      Hopefully we're not waiting long.

      We're waiting unsigned long.

      As long as it's not a justin long... he's already signed.

      --
      Make sure everyone's vote counts: Verified Voting
    3. Re:When Signed/Unsigned Strikes by Anonymous Coward · · Score: 5, Funny

      Waiting long? Hopefully we're not waiting double!

    4. Re:When Signed/Unsigned Strikes by msauve · · Score: 4, Interesting

      Probably not measuring the times per sampling, but measuring the time the focus mechanism is moving. To keep costs down, I suspect the mechanism has no feedback mechanism, so to focus you move one way for a set amount of time (guaranteed to hit a mechanical stop). Then the software might keep track of focus position by how long it's driven the lens in one direction or the other starting at that known position (oops, I moved "out" 100 ms, but overshoot, so now I'll move "in" 50 ms). Or it might be that the bug makes it so the lens never gets properly reset to it's starting position.

      --
      "National Security is the chief cause of national insecurity." - Celine's First Law
    5. Re:When Signed/Unsigned Strikes by nhytefall · · Score: 4, Funny

      WRONG FOCUS...

      Sounds like you are on the wrong end of the 24.5 day cycle :)

      --
      0100010001101001011001 0100100000011010010110 1110001000000110000100 1000000110011001101001 0111001001100101
    6. Re:When Signed/Unsigned Strikes by BitZtream · · Score: 5, Informative

      Most cameras do, they just don't use a RTC value to do so.

      You don't want it continually focusing, you want it to focus then wait a bit otherwise it'll bounce all over the place. You check the distance, wait a moment, and check again, is it close to the same? If so use that as your focal length, other wise you'll probably end up never in focus cause you'll be using all the various raw values given to you by the sensor. This is likely input averaging to get a smooth value and throw out bad samples.

      Take a look at the raw input values provided by most game controllers, try to hold an analog stick in one spot and not get jitter in the raw values, unless the device itself is averaging you won't got a solid result. Plug a xbox controller into your PC and use the Windows control panel (if you're using windows, never plugged a joystick into a unix box myself) to see how jumpy it is.

      A sensor measuring the environment outside, in someones hand is going to bounce around like a mad man, so it has to be smoothed out somehow.

      --
      Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
    7. Re:When Signed/Unsigned Strikes by Anonymous Coward · · Score: 4, Informative

      The support for the camera in the Droid was developed by Motorolla, not Google.

    8. Re:When Signed/Unsigned Strikes by Mike+Buddha · · Score: 5, Insightful

      Whenever I write something I think it particularly clever, I comment it out and write something simpler. The clever stuff I find is nearly impossible to figure out next year when you have to go back and add a feature or change something. It doesn't help that I usually think, "Oh that's so clever, there's no way I would forget how that works. It's so elegant." and don't bother to comment the hell out of it.

      Simple == good

      --
      by Mike Buddha -- Someday the mountain might get him, but the law never will.
    9. Re:When Signed/Unsigned Strikes by Abstrackt · · Score: 5, Funny

      Sounds like you are on the wrong end of the 24.5 day cycle :)

      That's what my wife keeps telling me. :(

      --
      They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance. - Terry Pratchett
    10. Re:When Signed/Unsigned Strikes by Fael · · Score: 5, Funny

      Under most circumstances, you would be correct. However, there are certain situations under which it is grammatically correct to omit the final mark of punctuation: when a speaking character is defenestrated mid-dialogue; when the narrator has just discovered himself to be his own grandpa; and (as is clearly the case in the grandparent post) when quoting the first line of a limerick:

      Wish I had mod points, this entire thread is one of the funniest ever on /.
      Second quite possibly only to last week's delightful essay on the breakdancing robot
      Of course it would be
      somewhat remiss of me
      Not to mention that I find most everything hilarious because I just don't get out a whole lot.

    11. Re:When Signed/Unsigned Strikes by shut_up_man · · Score: 5, Insightful

      Obligatory quote:

      "Debugging is twice as hard as writing the program, so if you write the program as cleverly as you can, by definition, you won't be clever enough to debug it. "

    12. Re:When Signed/Unsigned Strikes by Jarik+C-Bol · · Score: 5, Funny

      Yes, but on the other hand, piss off you pedantic bastard.

      --
      I've decided to Diversify my Holdings. I've divided my cash between my left and right pockets, instead of all in one.
    13. Re:When Signed/Unsigned Strikes by StikyPad · · Score: 5, Funny

      Word.

  2. Auto-Focus by kellyb9 · · Score: 5, Funny

    ... Droid doesn't

    1. Re:Auto-Focus by josteos · · Score: 5, Funny

      ... Droid might

      --
      Save the Music; Save the World at http://www.TuneTriever.com (Our latest Android game)
  3. In case you were worried.... by EdIII · · Score: 5, Funny

    Spring Break, the biggest part of it, occurs within a working cycle.

  4. Alleged... by Anonymous Coward · · Score: 5, Funny

    by someone claiming to be Google engineer Dan Morrill

    Yeah, it could also be one of those lame Dan Morrill impersonators who solve perplexing engineering/programming issues, then post the solution under his name. MAN that's annoying..

    1. Re:Alleged... by Ragzouken · · Score: 4, Funny

      You have some interesting points, person, posting using Artraze's account, on a website my DNS tells me is slashdot.org.

  5. "Not waiting long"? by Singularity42 · · Score: 5, Funny

    I've been waiting a long long time for standardization of integer types.

    1. Re:"Not waiting long"? by Anonymous Coward · · Score: 5, Funny

      Yeah? Well, I've been waiting an unsigned long long time for standardization of integer types. Twice as long!

    2. Re:"Not waiting long"? by hpa · · Score: 4, Informative

      Keep waiting ... the behaviour still won't be transparent. For example, on 64-bit x86 cpus, you still can't shift left more than 31 bits at a time.

      Nonsense. In 64-bit mode you can shift up to 63 bits at a time.

  6. iFocus ... NOT by OzPeter · · Score: 4, Funny

    This is definitely NOT the Droid you are looking for

    --
    I am Slashdot. Are you Slashdot as well?
  7. Time-releated bugs by Iphtashu+Fitz · · Score: 5, Interesting

    15+ years ago I had to debug some code in a report printing app for OS/2 (remember that OS?). The bug would cause the app to crash when a report was printed out. But the bug would only happen on certain days. Certain days in September. Only on Wednesdays in September. Only when it was a Wednesday in September after the 9th.

    The bug? The original programmer had tried to optimize memory usage as much as possible and was off by a count of one. With "September" being the longest month spelled out, "Wednesday" the longest day spelled out, and a 2 digit date, the header that the program put together to send to the printer would overflow its buffer by one character.

    1. Re:Time-releated bugs by qoncept · · Score: 4, Funny

      I got a "bug report" that our Oracle Forms app would give an undefined error message after you "type in a first name, push tab twice, and click save 17 times." I didn't debug it, but I did offer a workaround.

      I also had a bug report for when you tried to add a prerequisite that didn't exist to a training task (the system tracked flight Air Force crew training and experience), an error would pop up that said "All this time and it still doesn't work..." In that case, apparently debugging was as far as anyone ever got.

      --
      Whale
  8. IIRC, this is the same sort of bug by wiredog · · Score: 4, Insightful

    that caused Windows 95 to require a reboot in about the same timeframe.

    1. Re:IIRC, this is the same sort of bug by NoYob · · Score: 5, Funny
      Huh. I ended up giving my Win 95 box a woman's name and just chalked it up to "that time of the month."

      I didn't realize there was a real software reason for it.

      I wonder if there's a way to do the same for my wife - you know, fix a software bug.

      Gotta run she's home!

      --
      It's NOT me! It's the meds! I'm on 1000mg of Fukitol.
    2. Re:IIRC, this is the same sort of bug by kalirion · · Score: 4, Funny

      Same timeframe? You could actually keep a Win 95 system up and running for 24 days?

    3. Re:IIRC, this is the same sort of bug by Mr.Mustard · · Score: 4, Informative

      It was actually 49.7 days.

      --
      fnord
  9. Re:Rounding error? by Anonymous Coward · · Score: 4, Funny

    In excusable. The industry is too mature for that type of shit.

    Spelling error? Inexcusable. The English language is too mature for that type of shit.

    (In case you missed it, your argument has just as much validity in the real world due to differences in people.)

  10. iPhone 3G/3GS GPS bug by acidblood · · Score: 5, Interesting

    Since we're talking about phone bugs, here's one I had to fight with for a while...

    Lots of users are having problems with the GPS functionality on the iPhone 3G/3GS (see e.g. here). No apparent pattern there, but in Brazil, lots of users from one specific carrier were having GPS problems, and the beginning of these problems coincided with the start of Daylight Savings Time in Brazil. My iPhone, as well as my girlfriend's, are with this carrier and were experiencing the problem. Those with unlocked phones report trying other carriers' SIM cards and had GPS working again, but once you popped back the problematic carrier's SIM card, the GPS was dead again.

    This nearly drove me nuts as I paid an obscene amount of money for the TomTom app and couldn't get it to work, so keeping up with the engineer spirit, I tried to debug the problem myself. I observed an interesting fact: there's a Clock app on the iPhone with a World Clock pane, and if I added a clock from any time zone, including my own, it was off by one hour. However the iPhone's main clock, shown on the top of the screen, was showing the right time. Eventually I discovered that if I restored my phone as a brand new phone (not restoring from backup) the GPS would work fine and world clocks would be fine... until you reboot the phone. After rebooting, the GPS is gone again and the world clock is off by one hour again.

    Now you might ask what the time has to do with GPS. A lot, it turns out. GPS works by triangulating your distance from the satellites in the GPS constellation, which depends on knowing the exact position of the satellites. Since their orbits are corrected every so often, you must rely on so-called ephemeris data from each satellite, which is the required information to compute fairly exact orbits, and is updated fairly often (Wikipedia says GPS receivers should update ephemeris data every 4 hours). Originally this data is broadcast by the satellites themselves in their navigation message, at an awfully slow rate of 50 bits/s. You read it right, bits, not bytes or KB or MB, that's bits. As the navigation message is 1500 bits long, it takes at least 30 seconds to download it, which is about the time most standalone GPS receivers take to get a fix from a cold start (i.e. with stale ephemeris data). To work around this delay, most phones with GPS use the assisted-GPS variety, which downloads ephemeris data from a faster channel such as the cellular network. My theory is that some WTF-worthy excuse for an engineer at the carrier decided that, rather than doing time zone updates the right way, by updating configuration files to point to the new time zone, he'd just rather adjust the clock forward by one hour. The GPS chipset probably works with time zone neutral clocks so it asks for (say) UTC time and gets it off by one hour, and then computes the satellite orbits as though it were one hour later than it actually is. Obviously this means the triangulation computations go horribly wrong and rather than reporting something absurd, the chipset just pretends it couldn't get a fix.

    It took a lot of complaining from a lot of people (to the carrier and to the government agencies responsible for telecommunications), but the carrier finally fixed the problem. However, it was a nightmare trying to deal with clueless customer support representatives who didn't try in the least to help (and probably were thinking all along `what does this wacko think GPS has to do with DST?'), just blindly suggesting that we restore the phone, or even try to uninstall the built-in Maps app, or blaming it on Apple and saying they weren't responsible -- and never mind that unlocked phones with SIM cards from other carriers worked fine, and that the iPhone support situation is unique in Brazil as Apple outsourced support to the carriers themselves. In the end, the customer support WTFs would be worth another post of its own, at least twice the size of this one.

    But

    --

    Join the NFSNET. Our prime goal is making little numbers out of big ones. http://www.nfsnet.org/

  11. Schrodinger's Auto-Focus by Dareth · · Score: 4, Funny

    It is necessary to have some radioactive elements in your phone for it to focus.

    PS, it may or may not also kill cats!

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
  12. Re:A timestamping overflow error by ground.zero.612 · · Score: 5, Funny

    Congratulations. You are among the few (but growing in number) who not only can't RTFA, but lack the attention span or comprehension skills to read the summary itself.

    MTV has a network for you.

    Is that network called MTV?

    --
    "Be prepared, son. That's my motto. Be prepared." --Joe Hallenbeck
  13. Kudos to Google for being so open about the bug by cryfreedomlove · · Score: 4, Insightful

    It is gratifying for Google to be so open about the fact that it is a bug, the details of the bug, and a promise to fix it. Most consumer electronics companies are much more cagey about this sort of thing. I suspect Google will win some important trust because they are treating their customers like adults.

  14. Re:Does it use an Intel CPU? by Bakkster · · Score: 4, Funny

    Read and be enlightened.

    Of course my favorite joke about the matter:
    Q: "How did Intel decide to name the 586 processor?"
    A: "They took 486, added 100, and came up with 585.999999999999824"

    --
    Write your representatives! Repeal the 2nd Law of Thermodynamics!
  15. I must have the same bug... by Gavin+Scott · · Score: 4, Funny

    After about 42 years my auto-focus suddenly stopped working as well.

    You think if I live to 84 or so it will suddenly get better again?

    I sure hope there's a patch...

    G.

    1. Re:I must have the same bug... by bennomatic · · Score: 5, Funny

      Unfortunately, applying a patch causes the loss of depth perception.

      --
      The CB App. What's your 20?
    2. Re:I must have the same bug... by AcidPenguin9873 · · Score: 5, Funny

      And increases one's propensity for rum, parrots, and the letter R.

  16. Bigger bugs afoot... by jddj · · Score: 5, Interesting

    Honestly, autofocus on the just-so-so camera is the last of my worries:

    • Can't sync with Outlook (the phone doesn't have on-device encryption that would satisfy Exchange policies). Only calendar works, not contacts or email.
    • Can't hands-free voice dial (have to touch the phone to unlock it, touch to turn on voice dial, speak your choice, touch the choice from the menu of likely suspected contacts).
    • Locked phone's touch-screen comes on in pocket when answering with a headset, causing much mute/disconnect/speakerphone hilarity.
    • Turn-by-turn navigation is way off, literally by miles. Wrong 4 of 4 tries so far (in metro Atlanta and DC).
    • Immature bluetooth won't support HCI (portable bluetooth keyboards).
    • Rotating the phone after checking email checkboxes unchecks everything
    • Can't order contact list by last name (fixed in first name order)
    • Can't charge it with ANYTHING but the included AC adaptor (over-draws USB power from my old USB car and wall chargers)

    Really, fix the camera sometime down the line. But make the phone dial hands-free. Make email work. Make the navigation something other than worthless. Make "lock the screen" really lock the screen.

    Someone at Google should use one of their own phones for a while and see how (s)he likes it.

    It's a wonderfully powerful platform, but clearly not as well-thought-out or fluid to work as iPhone/iPod Touch

    1. Re:Bigger bugs afoot... by DeadCatX2 · · Score: 5, Informative

      Exchange works great for me. So does navigation. I had no problem charging my phone with my netbook's USB port. I did, however, notice that changing the orientation can cause not-yet-applied settings to be forgotten (happened to me while setting up Exchange).

      I don't have any Bluetooth stuff so I can't comment on Bluetooth support, but I imagine it will improve. Bluetooth seems like a very temperamental protocol. That said, hands-free Bluetooth voice dialing is actually a showstopper for a lot of important business types, so that should get fixed right away.

      If you don't like the native Contacts application, I'm sure you can find some others. Personally, I use the Favorites tab of the Contacts widget, and that handles 95% of the times I want to make a phone call in two clicks.

      Finally...Motorola made the phone, not Google.

      --
      :(){ :|:& };:
    2. Re:Bigger bugs afoot... by Mike+Buddha · · Score: 5, Insightful

      • Can't sync with Outlook (the phone doesn't have on-device encryption that would satisfy Exchange policies).

      They should've just made it to lie about its policy enforcement to Exchange server like the iPhone did. That way it'd be banned from my corporate network like my iPhone was. Thanks Steve, you're such a smart guy.

      --
      by Mike Buddha -- Someday the mountain might get him, but the law never will.
  17. 4.3BSD had a bug like that by Animats · · Score: 4, Insightful

    The initial release of 4.3BSD had a bug like that. It wouldn't interoperate with implementations that chose TCP sequence numbers in the upper half of the 32-bit address space. BSD itself didn't do this until it had been up for 2^31 seconds, so it got through testing. Other implementations cycled faster. We were losing network connections for two hours out of every four.

    It took a 1-line fix, after three days of looking at the generated machine code to figure out exactly how the sequence number arithmetic worked. Too many casts in the source.

  18. Mother said there would be days like this by Cryacin · · Score: 4, Funny

    Woke up today, and just can't focus!!!

    --
    Science advances one funeral at a time- Max Planck