You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/09/26 21:14:00 UTC

[jira] [Commented] (CB-12035) [cordova-plugin-network-information] connection info is not reliable on Android 6

    [ https://issues.apache.org/jira/browse/CB-12035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629419#comment-16629419 ] 

ASF GitHub Bot commented on CB-12035:
-------------------------------------

PieterVanPoyer opened a new pull request #74: CB-12035 (android) Fix bug [cordova-plugin-network-information] connection info is not reliable on Android 6
URL: https://github.com/apache/cordova-plugin-network-information/pull/74
 
 
   https://issues.apache.org/jira/browse/CB-12035 && https://github.com/apache/cordova-plugin-network-information/issues/64: in case of TYPE_NONE (android bug?) return TYPE_UNKNOWN if ConnectivityManager.EXTRA_NO_CONNECTIVITY from the intent return false.
   
   <!--
   Please make sure the checklist boxes are all checked before submitting the PR. The checklist
   is intended as a quick reference, for complete details please see our Contributor Guidelines:
   
   http://cordova.apache.org/contribute/contribute_guidelines.html
   
   Thanks!
   -->
   
   ### Platforms affected
   android (6+)
   
   ### What does this PR do?
   There is an Android bug that returns a null activeNetworkInfo after idle time when there is a connection.
   This PR solves it by using the EXTRA_NO_CONNECTIVITY flag from the receiver Intent.
   In case the EXTRA_NO_CONNECTIVITY returns false, but the activeNetworkInfo is null, the network type is set to 'unknown'. (@see https://developer.android.com/reference/android/net/ConnectivityManager.html#EXTRA_NO_CONNECTIVITY )
   The receiver is also removed in the onPause and reattached in the onResume (this is not backwards compatible).
   
   ### What testing has been done on this change?
   Thoroughly testing on my Samsung device.
   An extract from my logging (type none, but switched to unknown because 'no connectivity' was false:
   `
   09-26 22:20:13.483 25806-25806/appId D/NetworkManager: Connection Type: none
       Connection Extra Info: null
   `
   `
   09-26 22:20:13.484 25806-25806/appId D/NetworkManager: Intent no connectivity: false
       !!! Switching to unknown
   `
   
   ### Checklist
   - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
   - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
   - [ ] Added automated test coverage as appropriate for this change.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> [cordova-plugin-network-information] connection info is not reliable on Android 6
> ---------------------------------------------------------------------------------
>
>                 Key: CB-12035
>                 URL: https://issues.apache.org/jira/browse/CB-12035
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-network-information
>    Affects Versions: 1.3.0
>         Environment: Samsung Galaxy Edge S6 / Android 6
> useragent: "Mozilla/5.0 (Linux; Android 6.0.1; SM-G925F Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.124 Mobile Safari/537.36"
> reproduced with:
> cordova-plugin-network-information@1.3.0 (latest)
> cordova-plugin-network-information@1.2.0
>            Reporter: jakub-g
>            Priority: Major
>              Labels: android
>
> I've noticed that information exposed by the plugin is not reliable. It happens often that I'm connected to the internet via WiFi, and the plugin says that there's no connection.
> It's not easy to reproduce it on-demand, but I reproduced it many times recently. It happens most often when in the morning, I open the Cordova app that was running in background throughout the night.
> Then, when I connect to Chrome Dev Tools, I can do a repl session like this:
> {code}
> > navigator.connection.type
> "none"
> > window.fetch('http://www.example.org').then(function(res) {console.log(res.status)})
> Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
> 200
> Fetch complete: GET "http://www.example.org/".(anonymous function)
> > navigator.connection.type
> "none"
> {code}
> So, the plugin thinks I'm offline, yet any HTTP calls done within the app without checking if I'm offline or online, are successful (either from the app or devtools).
> When I disable WiFi and reenable it, after a few seconds the plugin updates its state and then it tells that connection type is "wifi".
> There are several possibilities here:
> - either system (or device driver) gives us incorrect information, or
> - cordova plugin is caching data and/or not listening properly to all the events and/or incorrectly processing it
> and most probably the issue manifests itself when the device is asleep for many hours (but I'm not sure about this).
> Note that I also noticed another issue, that sometimes the Chrome network stack thinks I'm offline (when I do an HTTP call, it fails immediately and I see network errors in devtools console) - and then I restart the Cordova app, and everything's fine, all HTTP calls are ok - but this is unrelated to this ticket, and perhaps a bug in Chrome.
> This ticket seems to be most likely a bug in the plugin, because as I said before, doing HTTP call succeeds despite the plugin telling me that I'm offline.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org