Open Bug 784505 Opened 12 years ago Updated 2 years ago

Fennec shouldn't use the GPS when the tab or app is in the background

Categories

(Core :: DOM: Geolocation, defect, P3)

ARM
Android
defect

Tracking

()

REOPENED

People

(Reporter: dbaron, Unassigned, Mentored)

References

Details

(Keywords: power, privacy)

I noticed a usage pattern I've started doing to save battery that seems like I shouldn't have to do it.  In particular, I sometimes load http://nextmuni.com/ on Fennec... and I want to leave the page open so that I can go back to it a few minutes later.  However, if I leave the page open in Fennec and hit the [Home] key to use another app, the GPS icon on my phone stays active and the battery drains rather quickly as a result.  So to avoid this I have to make sure to leave a page that uses the GPS before leaving Fennec, so that Fennec will stop using the GPS.

I feel like I shouldn't have to do this, and Fennec should do the right thing for me by default.

Steps to reproduce:
 1. load http://nextmuni.com/
 2. hit the home button and start doing something with another app

Expected results:  Fennec stops using the GPS

Actual results: Fennec continues using the GPS

(Same steps apply replacing (2) with switching to another Fennec tab.)
Assignee: nobody → doug.turner
unassigning things that I am not working on.
Assignee: doug.turner → nobody
This is still valid, a watch position stays active 
1) when the app is backgrounded,
2) when tab is not current,

Chrome on Android does not do (1) or (2).
Mentor: gkeeley
(In reply to David Baron [:dbaron] ⏰UTC-7 from comment #0)
> Expected results:  Fennec stops using the GPS

For one of the pages I use a ton, this actually would be a completely unexpected behavior. I run lantea.kairo.at in a Fennec tab to record my GPS tracks (because apparently our web apps support seems to fail to launch it as an app installed from the Marketplace, with a very weird error message). I would never want that to be stopped and I'm actually pretty annoyed at both Lollipop and Fennec because either the tab or Fennec get unloaded quite often when I don't keep that tab in front all the time.
(In reply to Robert Kaiser (:kairo@mozilla.com) - on vacation or slow to reply until the end of June from comment #3)
> (In reply to David Baron [:dbaron] ⏰UTC-7 from comment #0)
> > Expected results:  Fennec stops using the GPS
> 
> For one of the pages I use a ton, this actually would be a completely
> unexpected behavior.

I'd argue that it's bad *default* behavior to keep the GPS running for non-focused pages. (or once the browser is no longer the foreground application) This is especially true since GPS has the potential to drain the mobile's battery very quickly, leading to unhappy users. It should probably be possible to request an exception from this to enable Robert's use case, but to me that is secondary to remedying the bad user experience of "Oh god, my battery is half-dead. Why? Oh, I left Google Maps open in a browser tab."
I think:
users gained by this behaviour < users lost by this behaviour
This is a duplicate bug of bug 1216148. We posted a patch there that tried to stop background app using GPS as default.
Flags: needinfo?(doug.turner)
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Flags: needinfo?(doug.turner)
I tested the behavior on Fennec today and sadly this problem still exists. 
I am not sure how Feenec works at this point so I remove the duplicate flag to the Bug 1216148.

Looking forward to having Fennec team to take look at this issue.
Thanks!
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Fennec uses unrelated geolocation provider code to gecko, the code is all here:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java#506

public static void enableLocation(final boolean enable) is the function.

Roughly speaking, onPause() of the main activity, this could be 
if isLocationEnabled {
enableLocation(false)
} 
and onResume()
if isLocationEnabled {
enableLocation(true)
}
*Please* see: - https://github.com/slightlyoff/ServiceWorker/issues/745
IMHO the following is also well worth a look : - https://github.com/w3c/geofencing-api/issues/25

Also, Chromes bugfix for the same problem can be found here: - https://code.google.com/p/chromium/issues/detail?id=112938

WAKE_LOCKs or CPU_LOCKs or GPS_LOCKs, are a retrograde step with battery consumption and, curiously, ignore the best background processing since slice-bread "Service Workers"!
I am curious about the lack of importance flagged against this bug. FireFox is facilitating the unauthorized tracking of users by unscrupulous sites, and is not in a hurry to do anything about it :-( The user may well be happy to consent but the fact that they are oblivious to what's going on cannot be good surely?

This doesn't sound like the mozilla way or, for that matter, the way of anyone who doesn't want to open themselves up to litigation.

Do you know if this is still happening on Android?
I was thinking this is a P3, wdyt?

Flags: needinfo?(cpeterson)

(In reply to :garvan from comment #12)

Do you know if this is still happening on Android?

I haven't tested this, but bug 1482733 reported that navigator.geolocation.watchPosition() in Fennec stopped working when the phone's display is off (after the reporter got a new phone running Android O). That suggests watchPosition() had been working when the phone's display was off.

Testing watchPosition() when the phone's display is off is not the same as testing from a background tab or backgrounded app, but it is related.

Flags: needinfo?(cpeterson)
Priority: -- → P3
See Also: → 1482733
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.