Closed
Bug 777145
Opened 13 years ago
Closed 12 years ago
B2G Network Manager: support navigator.onLine / online / offline events
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
Tracking | Status | |
---|---|---|
b2g18 | --- | fixed |
People
(Reporter: philikon, Assigned: hub)
References
Details
(Keywords: feature, Whiteboard: [WebAPI:P0][LOE:S])
Attachments
(2 files)
658 bytes,
patch
|
philikon
:
review+
hub
:
checkin+
|
Details | Diff | Splinter Review |
813 bytes,
patch
|
jgriffin
:
review+
hub
:
checkin+
|
Details | Diff | Splinter Review |
This is useful if web apps want to be notified when the network comes back online. Also useful for Gecko (e.g. for submitting crash reports or metric or whatever). I think this is as simple as updating nsIIOService::offline.
Assignee | ||
Comment 1•13 years ago
|
||
ok, this one seems to really be blocking me for bug 773892. I'll take a crack at it.
Assignee: nobody → hub
Reporter | ||
Comment 2•13 years ago
|
||
Cool, thanks! Basically, you want to hook into the end of NetworkManager::setAndConfigureActive [1], ideally when we successfully activate interfaces and set routes.
[1] https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/NetworkManager.js#179
Assignee | ||
Comment 3•13 years ago
|
||
when I set Service.io.offline, I currently get the following error on the console:
E/GeckoConsole( 3442): [JavaScript Error: "[Exception... "'JavaScript component does not have a method named: "onStopListening"' when calling method: [nsIServerSocketListener::onStopListening]" nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)" location: "<unknown>" data: no]"]
Also it seems that I get, at https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/NetworkManager.js#179 this.active to be null as the state of wlan seems to always be disconnected, and when I try to force reconnection from the settings I don't get the event.
(I'm running on a SGS2)
Assignee | ||
Comment 4•13 years ago
|
||
Correction, I get that when I reboot the phone completely. Not when I restart b2g.
Reporter | ||
Comment 5•13 years ago
|
||
(In reply to Hub Figuiere [:hub] from comment #3)
> when I set Service.io.offline, I currently get the following error on the
> console:
>
> E/GeckoConsole( 3442): [JavaScript Error: "[Exception... "'JavaScript
> component does not have a method named: "onStopListening"' when calling
> method: [nsIServerSocketListener::onStopListening]" nsresult: "0x80570030
> (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)" location: "<unknown>" data:
> no]"]
That just means some nsIServerSocketListener implementation (in JS) out there hasn't implemented the full interface or has been cycle-collected. I suspect it's https://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/debugger/server/dbg-server.js#194, even though that does implement an empty onStopListening().
> Also it seems that I get, at
> https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/
> NetworkManager.js#179 this.active to be null as the state of wlan seems to
> always be disconnected, and when I try to force reconnection from the
> settings I don't get the event.
That's definitely weird. I can take a look at that later/tomorrow. Have you enabled DEBUG = true in NetworkManager.js and looked at logcat at all?
Assignee | ||
Comment 6•13 years ago
|
||
I didn't have DEBUG, but I added some logging.
It shows that when it iterate through the network interfaces it finds one, wlan, and its state isn't "CONNECTED". ~line 175
Assignee | ||
Comment 7•13 years ago
|
||
If I restart b2g, here is what Networkmanager does:
I/Gecko ( 3104): -*- NetworkManager: Starting worker.
I/Gecko ( 3104): -*- NetworkManager: Evaluating whether active network needs to be changed.
I/Gecko ( 3104): -*- NetworkManager: Network 'wlan0' registered.
I/Gecko ( 3104): -*- NetworkManager: Network 'wlan0' changed state to 4
I/Gecko ( 3104): -*- NetworkManager: Evaluating whether active network needs to be changed.
I/Gecko ( 3104): -*- NetworkManager: Network 'wlan0' changed state to 4
I/Gecko ( 3104): -*- NetworkManager: Evaluating whether active network needs to be changed.
I/Gecko ( 3104): -*- NetworkManager: Network 'wlan0' changed state to 4
I/Gecko ( 3104): -*- NetworkManager: Evaluating whether active network needs to be changed.
I/Gecko ( 3104): -*- NetworkManager: Network 'wlan0' changed state to 4
I/Gecko ( 3104): -*- NetworkManager: Evaluating whether active network needs to be changed.
I/Gecko ( 3104): -*- NetworkManager: Network 'wlan0' changed state to 4
I/Gecko ( 3104): -*- NetworkManager: Evaluating whether active network needs to be changed.
Assignee | ||
Comment 8•13 years ago
|
||
Just so that it is clear: by restart b2g I mean the b2g process (gecko) not the phone.
A reboot of the phone is a totally different story and seems to work as advertised.
Assignee | ||
Comment 9•13 years ago
|
||
Assignee | ||
Updated•13 years ago
|
Attachment #646758 -
Flags: review?(philipp)
Assignee | ||
Comment 10•13 years ago
|
||
This patch need bug 778360 to be properly fixed to work. Ie on restart of b2g, it will remain offline until wifi is restarted manually. (don't have cellular data ATM)
Reporter | ||
Comment 11•13 years ago
|
||
Comment on attachment 646758 [details] [diff] [review]
Bug 777145 - Set offline flag depending on the actual state of the network.
Review of attachment 646758 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/system/gonk/NetworkManager.js
@@ +178,4 @@
> if (this.active) {
> this.setDefaultRouteAndDNS(oldActive);
> }
> + Services.io.offline = !this.active;
Elegant!
Attachment #646758 -
Flags: review?(philipp) → review+
Assignee | ||
Comment 12•13 years ago
|
||
I'll check it in when bug 778360 is fixed. if I don't a restart of b2g will cause it to be offline.
Reporter | ||
Comment 13•12 years ago
|
||
Nom'ing because a dupe (bug 786764) was nom'ed.
blocking-basecamp: --- → ?
Reporter | ||
Comment 15•12 years ago
|
||
Folks were running into this issue here at the work week. Since we had an r+'ed patch that works most of the time, I went ahead and landed this:
https://hg.mozilla.org/integration/mozilla-inbound/rev/982d02faef3f
No reason to wait for bug 778360.
Assignee | ||
Comment 16•12 years ago
|
||
oh yes BIG REASON.
Each time one restart b2g, one has to restart wifi by doing setings > wifi > off then on.
This is time that could be better use to do real stuff. That's the whole reason I marked this as being blocked by another bug and the whole reason I held up landing.
This is actually MY DISCLAIMER of responsibility, I didn't approve this landing. I DIDN'T BREAK THE SYSTEM.
Reporter | ||
Comment 17•12 years ago
|
||
(In reply to Hub Figuiere [:hub] from comment #16)
> Each time one restart b2g, one has to restart wifi by doing setings > wifi >
> off then on.
I cannot reproduce this on the Otoro. So I think we're ok.
Assignee | ||
Comment 18•12 years ago
|
||
so can I get an Otoro device now?
Assignee | ||
Comment 19•12 years ago
|
||
So it seems that the problem was specific SGS2 (the only device I have). Blake has a final solution for bug 778360 that will land soon. We should be all set in the end.
blocking-basecamp: ? → ---
Comment 20•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
Comment 21•12 years ago
|
||
Seems like a blocker and even though it's fixed we don't want it to regress.
blocking-basecamp: --- → +
Reporter | ||
Comment 22•12 years ago
|
||
Backed out in https://hg.mozilla.org/mozilla-central/rev/e56edfeb2bb4 due to B2G marionette breakage (see bug 787298). Will reland once we have a fix.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 23•12 years ago
|
||
Philipp is someone active on the fix? Is the fix happening on this bug?
Reporter | ||
Comment 24•12 years ago
|
||
(In reply to David Bolter [:davidb] from comment #23)
> Philipp is someone active on the fix?
I was for a bit, but I couldn't get it working. Pinging Hub about possibly taking over the fix was on my list... So thanks for the reminder. ;)
Hub, could you look at this?
> Is the fix happening on this bug?
Yes, it would have to. Breaking Marionette is like breaking any other test suite in the tree, so fixes need to land at the same time.
Assignee | ||
Comment 25•12 years ago
|
||
The thing is I have no clue about Marionette nor how it works.
Reporter | ||
Comment 26•12 years ago
|
||
(In reply to Hub Figuiere [:hub] from comment #25)
> The thing is I have no clue about Marionette nor how it works.
https://developer.mozilla.org/en-US/docs/Marionette has an overview. To run the Marionette test suite against B2G, configure your B2G for the emulator, build, and then run ./test.sh.
Comment 27•12 years ago
|
||
Adding Malini for Marionette expertise.
Comment 28•12 years ago
|
||
@hub, if you have any problems running Marionette, ping myself (jgriffin) or mdas on #b2g and we can help.
Updated•12 years ago
|
Whiteboard: [WebAPI:P0]
Comment 29•12 years ago
|
||
@hub: You could try to look in the /proc/cpuinfo file and scan for Hardware: For the emulator, this appears to be set to Goldfish (for ARM). For x86 based emulator, The model name field looks like a Pentium II.
if MOZ_WIDGET_GONK is defined then you should be able to use the above to tell if you're in an emulator.
You may also be able to try and retrieve the IMEI number, I've read that the emulator returns 0 for this, but philikon can probably confirm
Assignee | ||
Updated•12 years ago
|
Whiteboard: [WebAPI:P0] → [WebAPI:P0][LOE:S]
Reporter | ||
Comment 30•12 years ago
|
||
(In reply to Dave Hylands [:dhylands] from comment #29)
> @hub: You could try to look in the /proc/cpuinfo file and scan for Hardware:
> For the emulator, this appears to be set to Goldfish (for ARM). For x86
> based emulator, The model name field looks like a Pentium II.
>
> if MOZ_WIDGET_GONK is defined then you should be able to use the above to
> tell if you're in an emulator.
I'm not sure what this is useful for. I don't think we want to special-case the emulator in Gecko, but rather make the test harness work with Gecko's behaviour. At least that would be my preference. Otherwise how are we going to write a test for it?
Hub, how are we doing here? This is a P0 basecamp blocker. Can we finish it up this week?
Assignee | ||
Comment 31•12 years ago
|
||
(In reply to Philipp von Weitershausen [:philikon] from comment #30)
> (In reply to Dave Hylands [:dhylands] from comment #29)
> > @hub: You could try to look in the /proc/cpuinfo file and scan for Hardware:
> > For the emulator, this appears to be set to Goldfish (for ARM). For x86
> > based emulator, The model name field looks like a Pentium II.
> >
> > if MOZ_WIDGET_GONK is defined then you should be able to use the above to
> > tell if you're in an emulator.
>
> I'm not sure what this is useful for. I don't think we want to special-case
> the emulator in Gecko, but rather make the test harness work with Gecko's
> behaviour. At least that would be my preference. Otherwise how are we going
> to write a test for it?
I was actually trying to special case it for the emulator, at least for now. I don't see how we can fix the emulator case without changing the actual emulator.
> Hub, how are we doing here? This is a P0 basecamp blocker. Can we finish it
> up this week?
That's my plan.
Assignee | ||
Comment 32•12 years ago
|
||
This patch to fix marionette. Needs the previous one to be relevant.
Assignee | ||
Updated•12 years ago
|
Attachment #662727 -
Flags: review?(jgriffin)
Comment 33•12 years ago
|
||
Comment on attachment 662727 [details] [diff] [review]
Bug 777145 - Part 2: Make sure we are online when runing marionette.
Review of attachment 662727 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks! I verified this works in both B2G and desktop Firefox.
Attachment #662727 -
Flags: review?(jgriffin) → review+
Assignee | ||
Comment 34•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #646758 -
Flags: checkin+
Assignee | ||
Updated•12 years ago
|
Attachment #662727 -
Flags: checkin+
Assignee | ||
Updated•12 years ago
|
Status: REOPENED → ASSIGNED
Comment 35•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/2e21fddbc007
https://hg.mozilla.org/mozilla-central/rev/2c8cb9b79705
Status: ASSIGNED → RESOLVED
Closed: 12 years ago → 12 years ago
Resolution: --- → FIXED
In light of bug 654579, I just wanted to verify that we set navigator.onLine to false and fire an "offline" event if the user doesn't currently have data connection through wifi or 2g/3g?
Comment 37•12 years ago
|
||
Noting here since people cc'ed are likely interested: I filed bug 798451 to see if we might want a non-wifi crash submission option.
Comment 38•12 years ago
|
||
Ryan, Jonas, I've noticed that after the device boots and is offline by default, navigator.onLine returns true instead of false. Only after connecting and disconnecting does the property return false as expected.
Can you take a look at this?
Comment 39•12 years ago
|
||
(In reply to Ran Ben Aharon (everything.me) from comment #38)
> Ryan, Jonas, I've noticed that after the device boots and is offline by
> default, navigator.onLine returns true instead of false. Only after
> connecting and disconnecting does the property return false as expected.
>
> Can you take a look at this?
Hey Ran, do you mind filing a new bug and ask for blocking-basecamp? ?
Comment 40•12 years ago
|
||
It has stopped working. STR:
Gecko-257e1c1.Gaia Master
Go to Gaia and turn on / off airplane mode. The online / offline events are not raised over the window object. And the following JS error appears on the console
E/GeckoConsole( 717): [JavaScript Error: "NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIPrefBranch.setIntPref]" {file: "jar:file:///system/b2g/omni.ja!/components/RILContentHelper.js" line: 878}]
E/GeckoConsole( 768): [JavaScript Error: "NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIPrefBranch.setIntPref]" {file: "jar:file:///system/b2g/omni.ja!/components/RILContentHelper.js" line: 878}]
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Reporter | ||
Comment 41•12 years ago
|
||
Thanks for the bug report, Jose. But please don't reopen really old bugs. Please always file new ones blocking the bug that's regressing. Thanks!
Status: REOPENED → RESOLVED
Closed: 12 years ago → 12 years ago
Resolution: --- → FIXED
Updated•12 years ago
|
status-b2g18:
--- → fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•