Open Bug 683472 Opened 13 years ago Updated 2 years ago

geolocation has trouble dealing with simultaneous calls to getCurrentPosition() and watchPosition()

Categories

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

x86
Linux
defect

Tracking

()

People

(Reporter: public, Unassigned, Mentored)

Details

(Whiteboard: [lang=js])

Attachments

(1 file, 1 obsolete file)

1. When using watchPosition and *then* getCurrentPosition() in the same snippet, only "CURRENT" will be displayed in the console. navigator.geolocation.watchPosition(function( pos ) { console.log( "WATCH", pos ); }); navigator.geolocation.getCurrentPosition(function( pos ) { console.log( "CURRENT", pos ); }); 2. When using getCurrentPosition() and *then* watchPosition() or getCurrentPosition() again, geolocation will stop working, accross all tabs (sometime you have to rune the snippet twice to see the bug) navigator.geolocation.getCurrentPosition(function( pos ) { console.log( "CURRENT", pos ); }); navigator.geolocation.watchPosition(function( pos ) { console.log( "WATCH", pos ); }); 3. Using watchPosition() and then watchPosition() again has the same effect as 2. In any case, only the callback of the last call to watchPosition() or getCurrentPosition() ever fires (if geolocation does not stop working immediately).
Can you provide a minimized testcase which showcases this bug?
Here are the test cases: http://fiddle.jshell.net/louisremi/MypZQ/2/show/ http://fiddle.jshell.net/louisremi/MypZQ/6/show/ I have trouble reproducing the case where geolocation stops working. Sometime I have to refresh http://fiddle.jshell.net/louisremi/MypZQ/2/show/ a dozen of times before it happens, sometime it happens on the first time I open the page. When it happens, I have to restart the browser. So the first thing to fix is the fact that only the last call to watchPosition() or getCurrentPosition() has its callback executed.
When this starts failing do any errors appear in the Error Console?
No, I have checked and I haven't seen any.
Oh, gross, this happens because two prompts are triggered, but they're collapsed into one prompt for the most recent geolocation request (the watch request). Then when that's allowed and an update occurs, we see the getCurrentPosition request which hasn't been allowed, so we skip over it, and then remove it so it doesn't get any more updates.
This solves the problem of the first testcase. I'm still digging into why the second one behaves so strangely.
Mark, I'm interested in your feedback as to whether we should look into collapsing similar content permission prompts on mobile. I believe that with the sample testcase above we'll just display two prompts.
Comment on attachment 558299 [details] [diff] [review] Allow or deny all similar pending content permission requests when permissino is granted or denied. It seems like this is the "right" thing to do. We could start stacking each prompt in it's own row, but that seems like it could confuse the user and just look amateurish.
Attachment #558299 - Flags: feedback+
Hey Josh, thank you for taking care of this once again. While you are at it, I suggest you have a look at bug 683656. Users should have to click only once on "share location" per browsing session.
Attachment #558299 - Attachment is obsolete: true
Attachment #585162 - Flags: review?(firefox-reviewers)
Comment on attachment 585162 [details] [diff] [review] Allow or deny all similar pending content permission requests when permissino is granted or denied. No response from firefox-reviewers for more than a month. Let's try throwing a dart at the map.
Attachment #585162 - Flags: review?(firefox-reviewers) → review?(gavin.sharp)
(In reply to Josh Matthews [:jdm] from comment #12) > No response from firefox-reviewers for more than a month. Let's try throwing > a dart at the map. Sorry if there was some misunderstanding, but that's not a valid use of the alias. The mailing list doesn't get normal bugmail, and this bug isn't in the Firefox product, so that request went to /dev/null. firefox-reviewers get mail when "review" flags are changed in bugs that are in the Firefox product, regardless of the assignee.
Comment on attachment 585162 [details] [diff] [review] Allow or deny all similar pending content permission requests when permissino is granted or denied. It looks like this can potentially leak request objects indefinitely (including past the time when their associated tabs are closed), which doesn't seem acceptable. One way to solve that might be to have the requests live on the notification object (which gets cleared out on tab close), rather than in the prompter. Does the relevant spec mention how to deal with multiple successive prompts? Do you know how other browsers handle this?
Attachment #585162 - Flags: review?(gavin.sharp) → review-
Assignee: nobody → josh
I'm not actively looking into this. However, if someone wanted to tackle this, answering Gavin's question about what other browsers do would be a great first step, and then the notification code lives at http://mxr.mozilla.org/mozilla-central/source/toolkit/modules/PopupNotifications.jsm . Adapting the patch here to store the request objects inside the notifications instead of the prompt code should not be too difficult.
Assignee: josh → nobody
Blocks: e10s
Whiteboard: [mentor=jdm][lang=js]
Mass tracking-e10s flag change. Filter bugmail on "2be0fcce-e36a-4e2c-aa80-0e3d33eb5406".
tracking-e10s: --- → +
It's unclear to me why this was blocking e10s.
No longer blocks: e10s
tracking-e10s: + → ---
Mentor: josh
Whiteboard: [mentor=jdm][lang=js] → [lang=js]
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: