Closed Bug 826089 Opened 13 years ago Closed 13 years ago

camera uses GPS even when not visible

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect)

x86
macOS
defect
Not set
normal

Tracking

(blocking-basecamp:-, b2g18+ fixed)

RESOLVED FIXED
blocking-basecamp -
Tracking Status
b2g18 + fixed

People

(Reporter: djf, Unassigned)

Details

The camera app queries the user's position every 10 minutes. But it doesn't clear the 10 minute timer when the user switches to another app. So it keeps querying location even long after the user has forgotten about the camera. I don't know how this affects battery use, but I fear that it is a drain, so I'm going to nominate this as a blocker. The fix in Gaia is almost trivial: just clear the timer when the camera goes to the background and restart it when the camera comes to the foreground. Note though, that a better fix might be to get rid of the timer and use watchPosition() instead of getCurrentPosition(), and then use cancelWatch() when the camera goes to the background. Also, it would be a good idea to set (if gecko supports it) a staleness value to tell the GPS that we're okay with a slightly out-of-date location. In addition to fixing this in the camera app, I wonder if there isn't also a gecko bug here. Looking at logcat, it appears that when the camera is running, we're getting logging messages from the GPS hardware once a second. It looks like the camera only calls getCurrentPosition() every 10 minutes. It does not use watchPosition(), so I don't know why the GPS hardware stays active.
Cc'ing Dale and nominating as blocking because of the potential to drain the battery. And cc'ing Doug to assess whether there is a Gecko bug here.
blocking-basecamp: --- → ?
I've split the gecko issue off int bug 826097 and have assigned that to Doug. Separately, we should be sure that the camera does not query the GPS while it is hidden. I suspect that converting to watchPosition() and clearWatch() might be the best way to do that. Maybe calling clearWatch() when the camera goes to background will shutdown the GPS hardware even despite 826097.
I'd be happy to take this bug, but will defer to you, Dale.
Triage: BB-, tracking-b2g18+ does not seem like the battery impact is causing dogfooders to notice any battery life issues. Battery life concern should be minimal.
blocking-basecamp: ? → -
tracking-b2g18: --- → +
The timer that updates the user position is cleared when the app goes into the background https://github.com/mozilla-b2g/gaia/blob/master/apps/camera/js/camera.js#L611 Using watchPosition may be better, I think the best solution would be manually update the metadata of the image file once a getPosition call has succeeded though, but yeh this bug isnt valid (in that the camera doesnt use GPS, it does look like there is a bug with GPS staying active) I believe there was a bug open about the GPS activity indicator being wrong and / or the GPS not being released properly, but I cant find them.
Status: NEW → UNCONFIRMED
Ever confirmed: false
Sorry Dale. I just looked at the mozvisiblitychange handler and missed line 611. I wonder if switching to watchPosition()/clearWatch() in Camera would work around the gecko bug. Is it worth keeping this bug open for that?
I have a personal app that using watchPosition and I am seeing bugs in that as well, I dont think we should be picking some other API just because it might be less buggy or not. I used getPosition as it is going to give you a reasonably accurate location without having to keep the GPS active the entire time, I think if we were to do any fix we should just do the proper one (writing location metadata after the fact)
Dale, When chatting with Doug about 826097 he commented that using getPosition() on a timer makes it hard for gecko to be smart about the GPS hardware. You might want to consult with him about how he plans to fix bug 826097. If the GPS hardware is going to stay active for some time after the call to getPosition(), maybe watchPosition() would be the better choice, anyway. The current solution will fail for anyone who is taking pictures from a moving vehicle.
Flags: needinfo?(dflanagan)
Rick: you're right. I'll close it.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Flags: needinfo?(dflanagan)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.