Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug][Question] Connectivity changes potentially not picked up by application #1106

Open
MitchBomcanhao opened this issue Feb 20, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@MitchBomcanhao
Copy link

Description

note: we're reporting this for Android but have not looked into iOS and UWP.

We've had a few reports of our app appearing to be "offline" while the device has internet connectivity via other apps or the browsers.
Looking at our telemetry, it would appear that these are mostly related to instances where the user was possibly offline, left the app running, went to do other stuff (ie stop using the device for a period of time). When they come back to the app, the app still believes that it is offline even though they are now connected.

Speculation:

  • the ConnectivityChanged event erroneously never fired even though it should have.
  • the ConnectivityChanged event never fired because the app was in a suspended state (?) when network status changed and when it later resumed nothing happened;

Are we missing something in the Connectivity pattern?
Should we recheck connectivity at certain app lifecycle events?
Has anyone had any similar issues?

For context, we have a network monitor service that keeps a variable for "isAvailable" and subscribes to the Connectivity.ConnectivityChanged event.
There are some code paths that will trigger a recheck of the status, but we try to avoid doing this too much - is the impact of checking Connectivity.NetworkAccess negligible enough that we could potentially run it very frequently whenever web requests are about to be performed?
if so, is there any point in subscribing to the ConnectivityChanged event if you're not notifying users of changes in real time?

@MitchBomcanhao MitchBomcanhao added the bug Something isn't working label Feb 20, 2020
@sergey-rubtsov-05
Copy link

I had a similar problem and I think I found the reason and solution to it.
For this time I've met it only on Samsung devices with Android 10 (API 29).

Reason:

Connectivity.ConnectivityChanged doesn't raise when OS calls NetworkCallback.OnBlockedStatusChanged
https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback#onBlockedStatusChanged(android.net.Network,%20boolean). NetworkCallback.onBlockedStatusChanged was added in API 29. When the argument boolean blocked is true an app doesn't see any ConnectivityProfiles.
I think it happens because Connectivity.ConnectivityChanged uses ConnectivityManager.ConnectivityAction inside which is deprecated in API 28 https://developer.android.com/reference/android/net/ConnectivityManager#CONNECTIVITY_ACTION

Solution:

I've created a derived type from type ConnectivityManager.NetworkCallback with a self-made event and used my event instead of Connectivity.ConnectivityChanged.

@patrickdoodyIRL
Copy link

I had a similar problem and I think I found the reason and solution to it.
For this time I've met it only on Samsung devices with Android 10 (API 29).

Reason:

Connectivity.ConnectivityChanged doesn't raise when OS calls NetworkCallback.OnBlockedStatusChanged
https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback#onBlockedStatusChanged(android.net.Network,%20boolean). NetworkCallback.onBlockedStatusChanged was added in API 29. When the argument boolean blocked is true an app doesn't see any ConnectivityProfiles.
I think it happens because Connectivity.ConnectivityChanged uses ConnectivityManager.ConnectivityAction inside which is deprecated in API 28 https://developer.android.com/reference/android/net/ConnectivityManager#CONNECTIVITY_ACTION

Solution:

I've created a derived type from type ConnectivityManager.NetworkCallback with a self-made event and used my event instead of Connectivity.ConnectivityChanged.

Would you be able to share your solution code? I think I've just encountered this problem with one of my own applications.

@ssauxescoubet
Copy link

ssauxescoubet commented Feb 5, 2021

We have also this issue on our application. Maybe this merge request : /pull/1568 will be correct this issue. When will she be merged in main branch ?

@nashworth1
Copy link

Still in need of solution for this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants