New issue
Advanced search Search tips

Issue 624737 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Jul 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

NetworkInfo API: "change" only fires twice

Reported by stef...@gmail.com, Jun 30 2016

Issue description

Steps to reproduce the problem:
1. In a SW script, register a handler for 'change' event on Network Information API http://wicg.github.io/netinfo/
2. Toggle network I/F (e.g. WiFi) on and off (repeat)
3. Check that the event handler is called

What is the expected behavior?
The event handler is called

What went wrong?
In all my tests the event handler is only called twice, after that any change on networks (e.g. WiFi on/off toggling) is ignored

Did this work before? N/A 

Chrome version: 51.0.2704.63  Channel: beta
OS Version: Android 6
Flash Version:
 
Cc: igrigo...@chromium.org jkarlin@chromium.org
Cc: -jkarlin@chromium.org
Labels: Needs-Feedback
Owner: jkarlin@chromium.org
Thanks for the report. I believe this is due to an issue where if Chrome on Android is not the foreground app then it won't listen for connectivity events.

If I make chrome foreground then the following code works well as I change my network type:

navigator.connection.addEventListener('change', function(event) { 
  console.log("Connection changed to " + 
              navigator.connection.type + 
	      ":" + 
	      navigator.connection.downlinkMax); 
});

And it reliably printed each network change. But if I change to another app and then switch networks I don't see the change (I'm inspecting chrome's console via dev tools inspector). When I switch back to the app it does get notification of the current network type though.

Is that the behavior that you're seeing?


Comment 3 by stef...@gmail.com, Jun 30 2016

Hm, the only other thing I bring to the screen is pulling down the top bar
of the screen twice to be able to tap on WiFi (to toggle between on and
off). I quickly switch back to Chrome (where I switch between the
serviceworkers-internal tab and the tab my web app lives in).

Does that count as putting Chrome in non-foreground?

Br,
Stefan
I don't believe the status bar causes onPause when you pull it down so I think it should keep working. But maybe different status bars act differently. I'm testing this on a Nexus 6P.

Regardless, you should get a notification of the current network type when you go back to Chrome (if it is different from before you hid it) and if that isn't happening there is a bug.

Comment 5 by stef...@gmail.com, Jul 1 2016

This seems to have something to do with the ServiceWorker life cycle. My
code is very similar to the snippet you provided, only that I have it in
the ServiceWorker.

If I, in addition to having it in the ServiceWorker, add it to the page
script, the page script detects network changes every time, regardless of
how many they are and how long time has passed since the last one. But for
the ServiceWorker I get the same issue as reported above, it detects the
first couple (if I'm quick I can get three detected) before stopping to
detect them.

Comment 6 by jkarlin@google.com, Jul 1 2016

Ah, I see. Yes it sounds like your Service Worker is closing after going idle, which is working as intended. There is no guarantee on the lifetime of a Service Worker.

Note that my experiment was also on a service worker, but it stayed open because it was attached to dev tools.
Project Member

Comment 7 by sheriffbot@chromium.org, Jul 1 2016

Labels: -Needs-Feedback Needs-Review
Thank you for providing more feedback. Adding "Needs-Review" label for tracking.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: -Needs-Review
Status: WontFix (was: Unconfirmed)
Closing as working as intended.

Comment 9 by stef...@gmail.com, Jul 1 2016

I agree, should be closed as "wontfix". Sorry for bothering!

Sign in to add a comment