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

fix(android): try async state fetch as stale state workaround #547

Merged

Conversation

cristianoccazinsp
Copy link
Contributor

@cristianoccazinsp cristianoccazinsp commented Dec 3, 2021

Overview

Attempt to fix #542 and #537 without fully undoing #510 changes.

The change aims to address the issue #510 fixes (not calling the network methods in the callback), but preserving the original implementation that uses data from the callbacks.

Could use some review and thoughts @mikehardy and @Willham12

Test Plan

Manually tested on a Google Pixel 5 (Android 12)

Commands that helped debug:
adb shell dumpsys deviceidle force-idle
adb shell dumpsys deviceidle unforce
adb shell input keyevent KEYCODE_WAKEUP

@cristianoccazinsp cristianoccazinsp changed the title Android fix Android stale state fix Dec 3, 2021
@mikehardy mikehardy added android Issues related to Android help wanted Issues that you can help with labels Dec 3, 2021
@mikehardy
Copy link
Contributor

queued for review + testing but me work queue is ridiculous at the moment, no promises on time. I'm listening though in case others have results

@Titozzz
Copy link
Contributor

Titozzz commented Dec 6, 2021

Haven't tried android 12, (still on 11) but I can confirm this builds + fixes the issue on my device

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but I haven't had a chance to test sadly. I have deep respect for @Titozzz as a source of truth though, and will be available for mopup reviews+merges in case for some reason this blows up. @cristianoccazinsp you have really been a champion here, along with the rest of the crew like @Willham12 really trying to root out this problem. My sincere appreciation for that: thank you

@mikehardy mikehardy changed the title Android stale state fix fix(android): try async state fetch as stale state workaround Dec 7, 2021
@mikehardy mikehardy merged commit 937cf48 into react-native-netinfo:master Dec 7, 2021
@cristianoccazinsp
Copy link
Contributor Author

Awesome! With Android, it's impossible to tell whether or not something will work for all devices, so it's a matter of testing and patiently waiting.

github-actions bot pushed a commit that referenced this pull request Dec 7, 2021
## [7.1.4](v7.1.3...v7.1.4) (2021-12-07)

### Bug Fixes

* **android:** try async state fetch as stale state workaround ([#547](#547)) ([937cf48](937cf48)), closes [#542](#542)
@matt-oakes
Copy link
Collaborator

🎉 This PR is included in version 7.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@cristianoccazinsp
Copy link
Contributor Author

cristianoccazinsp commented Dec 9, 2021

@mikehardy looks like I missed a null check (damn Java).

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkCapabilities.hasCapability(int)' on a null object reference
        at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver.updateAndSend(NetworkCallbackConnectivityReceiver.java:115)
        at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver$1.run(NetworkCallbackConnectivityReceiver.java:136)

PR to fix it will be coming up shortly today.

PR: #550

@mikehardy
Copy link
Contributor

"The billion dollar mistake" (re: null in general)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issues related to Android help wanted Issues that you can help with released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Listener randomly not triggered when turning on/off wifi or airplane mode
5 participants