Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Repeated Connectivity result - ConnectivityResult.mobile #2142

Closed
7 tasks done
raphire08 opened this issue Sep 8, 2023 · 6 comments
Closed
7 tasks done

[Bug]: Repeated Connectivity result - ConnectivityResult.mobile #2142

raphire08 opened this issue Sep 8, 2023 · 6 comments
Labels
bug Something isn't working triage

Comments

@raphire08
Copy link

Platform

iOS 16

Plugin

Connectivity Plus

Version

3.0.2

Flutter SDK

3.7.12

Steps to reproduce

Whenever connectivity result change we are logging it

Connectivity _connectivity = Connectivity();
 _connectivity.onConnectivityChanged
        .listen((ConnectivityResult result) {
     log('Connectivity subscription result: $result');
});

For many users we are getting repeated ConnectivityResult.mobile. Wanted to know what could cause this? Ideally it should be ConnectivityResult.mobile -> ConnectivityResult.none -> ConnectivityResult.mobile.

 
Info: 9/5/2023 2:05:01 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:05:02 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:05:02 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:05:05 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:05:05 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:11:51 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:11:51 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:11:54 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:11:54 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:11:56 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:11:56 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:12:01 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:12:01 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:17 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:17 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:20 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:20 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:22 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:22 PM - Skipping connectivity change : ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:25 PM - Connectivity subscription result: ConnectivityResult.mobile
 
Info: 9/5/2023 2:32:25 PM - Skipping connectivity change : ConnectivityResult.mobile

Code Sample

Connectivity _connectivity = Connectivity();
 _connectivity.onConnectivityChanged
        .listen((ConnectivityResult result) {
     log('Connectivity subscription result: $result');
});

User cellular network and we get repeated ConnectivityResult.mobile.



### Logs

```shell
// not required

Flutter Doctor

[✓] Flutter (Channel stable, 3.7.12, on macOS 13.0.1 22A400 darwin-x64, locale en-IN)
    • Flutter version 3.7.12 on channel stable at /Volumes/Work/flutter_sdk/flutter_3.7.12
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (5 months ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/sumeet/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.80.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.68.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 116.0.5845.179
    ! Error: Failed to prepare the device for development. Please unlock and reconnect the device. (code 806)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Checklist before submitting a bug

  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@raphire08 raphire08 added bug Something isn't working triage labels Sep 8, 2023
@burekas7
Copy link

burekas7 commented Oct 29, 2023

Me too.
On IOS -
when disable/enable WiFi, why do I get several messages (3 times when disable, 7 times when enable):
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.none
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.none
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.none

flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi
flutter: ConnectivityManager: Connectivity subscription result: ConnectivityResult.wifi

@daniellampl
Copy link

Same for me. This started to occur with version 5.0.0

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the Stale label Feb 28, 2024
@raphire08
Copy link
Author

Anything on this ?

@miquelbeltran
Copy link
Member

The callback is called whenever the OS NotificationCenter emits a value, and the package doesn't check if the value is distinct to the previous one, that would be something you would have to do on your side.

There is also a PR on the works that is changing the way the connectivity values are returned, it would be good if you could test it for your usecase: #2599

@github-actions github-actions bot removed the Stale label Feb 29, 2024
@vbuberen
Copy link
Collaborator

vbuberen commented Apr 8, 2024

It is mentioned in the README already that currently plugin doesn't filter values returned by the underlying platform. Check the last sentence here: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/connectivity_plus/connectivity_plus#ios--macos

Closing as currently this is how the plugin works. We plan to update the behavior to distinct values, but it will happen a bit later.

@vbuberen vbuberen closed this as completed Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

5 participants