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
Listener randomly not triggered when turning on/off wifi or airplane mode #542
Comments
With more testing it happens mostly when turning airplane mode on. |
With apologies I'm not aware of anyone currently that's responding to these issues that has time to dig in here on your behalf. To set expectations, you'll need to do the related work to diagnose, though I can collaborate on any possible fixes and get a PR merged+released. If this were my project I would immediately want the answer to the question "what exactly are the native platform APIs being called with as parameters, and when exactly are the native platform APIs being called / what are they returning?" That implies cracking open the module code in node_modules and adding logging all over at the Java level like Based on your detailed findings there I or someone else might be able to help |
For review.
@CptMaumau can you test if the changes here resolve the issue for you? https://github.com/cristianoccazinsp/react-native-netinfo/tree/android-fix |
@cristianoccazinsp it works for me |
Sadly, it doesn’t fix another probably more important bug. When the app goes to background for a while there’s a high chance that the library reports no connection and then never reports connection on app resume, something that worked fine with 6.2.0, so I wouldn’t take this change as an actual fix. |
@cristianoccazinsp Is there any version which works fine? |
So far, it seems like (if I understand this correctly @cristianoccazinsp ...) the only methods that work fine are the deprecated ones. Is that right? |
Was 6.2.0 using a deprecated method? That one does not have this nor the other (#537) issue, but with 6.2.1 (#510) the way of getting the connection info (always querying it rather than using the semantics of the event, such as "on lost, make connection None") causes the app to randomly return wrong connection info. So an immediate fix: downgrade to 6.2.0 until the changes in 6.2.1 can be fixed with a proper solution. |
@cristianoccazinsp I think at this point your the expert on it, and there was quite a bit of discussion related to the revert simply being best. If you want to propose something that just reverts the connection handling to 6.2.0 style I think that may be the best way. I thought was a step forward but clearly not |
I believe 6.2.1 fixed something related to Android 12, so I think the best would be to fix it and not revert it, but the issues are so tricky to debug that I've run out of ideas and time to keep debugging it. |
Android 12 currently 1-2% market share on my apps. Growing of course, but sometimes it's best of all evil |
@matyj @CptMaumau can you test the newest commit from https://github.com/cristianoccazinsp/react-native-netinfo/tree/android-fix ? I believe I got a fix for both this and the other issue. |
* Test a possible fix for #542 For review. * Combine 6.2.0 and 6.2.1 fixes into one. Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>
It didn't work.
NetInfo: 7.1.6 |
@Rebsos "PRs happily accepted", as are any really detailed things you can determine and report from your investigation of the issue as you go into node_modules and instrument the code. Fixes here will require troubleshooting and fixes from people with affected devices + use cases - I'm happy to collaborate but this is not a use case of mine professionally, and it's not something I feel like working on in personal time |
Does it happen all the time? I’m unable to reproduce it on a pixel 5 with android 12. There’s also another issue (from long time before) when starting the app without wifi or airplane mode. At app startup, the connection always seem to be unknown or connected, but it eventually resolves itself. |
Yes all the time. It is 100% reproducible. Did you try it with RN 64.2? I've setup two fresh projects, just with NetInfo and a button.
Devices: Samsung Galaxy S10+ Android 11. I think all devices are affected. |
That may explain it, I’m using RN 0.66.3. Is it only fetch that fails? What about the listeners? Do they work as expected. I don’t know what’s different between RN 0.64 and 0.66, and I don’t really have time to test right now. |
@Rebsos actually I know what's the difference. This PR #548 added code that relies on What about using netinfo 7.1.5 ? I'm sorry I cannot be of any further help, I would suggest just upgrading RN if 0.64 is the problem. When I get some time, I will try to debug a bit more into the other issue where the network connectivity is not correctly reported at app startup until there's an actual network change. |
You found something RN 64.2 + NetInfo 7.1.5 is working I've tested it multiple times. Something breaks from 7.1.5 to 7.1.6 |
It’s what I described above. 7.1.6 added a change that will only work from RN 0.65 and above. @mikehardy @HatCloud thoughts on changing #548 so it works for all RN versions? |
Or just say, min supported version of rn for that version and higher is 65. 64 doesn't even build clean on xcode 13, it's hard to bring much attention to it. If someone needs 64, stay on older version of netinfo? |
I would be fine with that too. Although that version update should have been a major update then hehe, but I wouldn’t mind a simple note in the change log and read me about it. |
Agreed that's an unintentional breaking change, that happens sometimes and is always regrettable but occasionally is just life |
Environment
System:
OS: macOS 11.6
CPU: (8) x64 Apple M1
Memory: 17.72 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.5.0 - ~/.nvm/versions/node/v12.5.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v12.5.0/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.5.0/bin/npm
Watchman: 2021.08.30.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.0 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_144 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.3 => 0.63.3
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Platforms
Android
Versions
Description
When only wifi connected, the network change listener is randomly not triggered when turning on/off wifi or airplane mode.
Reproducible Demo
turn on/off wifi or airplane mode.
The text was updated successfully, but these errors were encountered: