Last Comment Bug 681941 - update() method of nsIGeolocationUpdate cannot be used with multiple tabs
: update() method of nsIGeolocationUpdate cannot be used with multiple tabs
Status: RESOLVED FIXED
[inbound]
:
Product: Core
Classification: Components
Component: Geolocation (show other bugs)
: Trunk
: x86 Linux
: -- normal (vote)
: mozilla9
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-25 07:17 PDT by Louis-Rémi BABE
Modified: 2011-08-27 01:52 PDT (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Test case to be pasted in scratchpad (2.05 KB, application/javascript)
2011-08-25 07:17 PDT, Louis-Rémi BABE
no flags Details
Ensure that we always clear geolocation requests that are not long-lived, and never clear ones that are. (4.51 KB, patch)
2011-08-25 12:10 PDT, Josh Matthews [:jdm]
no flags Details | Diff | Splinter Review
Ensure that we always clear geolocation requests that are not long-lived, and never clear ones that are. (2.25 KB, patch)
2011-08-25 12:13 PDT, Josh Matthews [:jdm]
dougt: review+
Details | Diff | Splinter Review

Description Louis-Rémi BABE 2011-08-25 07:17:52 PDT
Created attachment 555724 [details]
Test case to be pasted in scratchpad

the update() method of nsIGeolocationUpdate can be used to pass a location (coords) to every "geolocation listener" (watchPosition or getCurrentPosition).
I'm trying to use it from an addon to be able to generate arbitrary locations.

When the addon is active in multiple tabs, only the first tab is able to detect location updates.
Worse: when the first tab is reloaded, it doesn't receive updates anymore. I have to reinstall the addon or restart firefox.

Test case:
1. Open http://fiddle.jshell.net/louisremi/DXTmH/1/show/ to track your current location with watchPosition
2. set pref "devtools.chrome.enabled" to true (once for all)
3. Open scratchpad and switch "environment" to "browser"
3. paste the content of the attached file in it
4. Modify your location on line 66-68
5. Run the code
6. See your position updated in the test page
7. Repeat steps 4 to 6 at will

8. Open the test page in a new tab
9. Modify your location & run the code
10. See your position not being updated in the current tab
11. Switch to the first tab and see your position updated

12. Reload the first tab
13. Modify your location & run the code
14. See your position not being updated anymore
Comment 1 Josh Matthews [:jdm] 2011-08-25 12:04:12 PDT
Thanks, this testcase was great. Patch coming up; look like we messed up the logic of when to cancel requests a bit.
Comment 2 Josh Matthews [:jdm] 2011-08-25 12:10:14 PDT
Created attachment 555805 [details] [diff] [review]
Ensure that we always clear geolocation requests that are not long-lived, and never clear ones that are.
Comment 3 Josh Matthews [:jdm] 2011-08-25 12:13:40 PDT
Created attachment 555807 [details] [diff] [review]
Ensure that we always clear geolocation requests that are not long-lived, and never clear ones that are.

Now without extra cruft.
Comment 4 Alexandre Poirot [:ochameau] PTO, back on 1st 2011-08-25 14:31:47 PDT
Hi Josh, I helped Louis-rémi building his addon around geolocation.
I was wondering if there is any way to fix this issue by using geolocation xpcom component in a alternative way so that all tabs gets update correctly?
(In order to get something working on current Firefox releases, before this fix finally end up in a release)
Comment 5 Josh Matthews [:jdm] 2011-08-25 14:55:43 PDT
I can think of a couple ways - use getLocation and setInterval, but the logic error being fixed here is weird enough that this may not be foolproof. Alternatively, you could try getting the geolocation information from a chrome listener, then load a content script which has a message listener which listens for messages your addon sends whenever a geolocation update occurs. That's assuming that it's possible to add geolocation listeners from non-content pages.
Comment 6 Louis-Rémi BABE 2011-08-26 12:22:43 PDT
Thank you for being so quick at fixing this bug Josh.
I hope it gets reviewed and commited soon so I can move on with my own work.
Comment 7 Doug Turner (:dougt) 2011-08-26 14:33:28 PDT
Comment on attachment 555807 [details] [diff] [review]
Ensure that we always clear geolocation requests that are not long-lived, and never clear ones that are.

The white space looks kinda off in one place.
Comment 8 Louis-Rémi BABE 2011-08-26 15:13:06 PDT
Wow that was really quick too! Thank you Doug.
Comment 10 Marco Bonardo [::mak] (Away 6-20 Aug) 2011-08-27 01:52:10 PDT
http://hg.mozilla.org/mozilla-central/rev/0938cf5252cd

Note You need to log in before you can comment on or make changes to this bug.