-
Notifications
You must be signed in to change notification settings - Fork 396
feat!: Turbomodule support for ios + android #622
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
feat!: Turbomodule support for ios + android #622
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Thanks a bunch for proposing this, really nice to see someone having an attempt at forward-porting this.
I sprinkled a few questions around but in general this looks pretty good, I'd love to get this merged as long as I'm sure we can handle the privacy concerns with android MAC API access,
@@ -37,7 +37,6 @@ public abstract class ConnectivityReceiver { | |||
private final WifiManager mWifiManager; | |||
private final TelephonyManager mTelephonyManager; | |||
private final ReactApplicationContext mReactContext; | |||
public boolean hasListener = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature was added to address privacy-related store rejections, in #548
How do you plan to defer getting the MAC address until the user has consented, or is this no longer necessary specifically because of the turbomodule migration (and if so, how exactly - please be specific so we make sure not to blow up approval process for all Chinese apps that use this module)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow. Thanks for pointing this out. Didn't know this. I thought it was for performance reasons.
I've started a discussion regarding some changes in NativeEventEmitter. The addListener and removeListeners methods doesn't seem to be triggering on Android with Turbomodule. I'll verify again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - hopefully there is resolution on that one - much of the netinfo information may be considered an information leak so perhaps the restrictions won't stop at MAC address only, and this was the best way (we thought!) to do a "privacy related total information cutout" so it either must be handled or there must be some other way to defer calling any platform APIs until desired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikehardy I just tried and those methods are working on fabric and non-fabric. I think I messed up something while testing! I have added them back, so should be fine now. Thanks again!
android/src/main/java/com/reactnativecommunity/netinfo/NetInfoModuleImpl.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
|
||
public void removeListeners(double count) { | ||
// iOS only | ||
numberOfListeners -= count; | ||
if (numberOfListeners == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated to this PR - removeListeners
doesn't get called as we're initialising a single listener and managing emitters on JS. I think it'll be only called on tearDown. I don't think it's a big issue, just wanted to point it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright - thank you! - as status, I wanted to get an initial review on this immediately to make sure there were no deal-breakers, I/we have achieved that, I think this should be merge-able, as code.
Now status is: I'm in the middle of a big work crunch so this either goes on a slightly deep pile in my work queue (which means I can make no guarantees on timing). So I don't have time to validate this unfortunately or perform the project management / documentation stuff that goes along with a serious PR (which this is)
Steps to move this to merge despite me not having time to actually do anything but hit buttons and type comments:
-
we need to determine + document how backwards compatible this release will be. Will it work with react-native < 0.59 still? or just 0.64+ or something else? We need to issue this as a breaking change and indicate lower level of support. I think it will be 0.64 or 0.65 because of the 7.1.1 gradle plugin but I'm not sure where the cutoff is. Maybe just pick one (64 or 65 or ?, test it and declare the rest untested / upgrade at your own risk / report results and PR doc updates if support is broader)
-
assert that you have tested this in non-fabric mode to at least the level indicated, for android + ios
It needs a fabric support documentation update - a new section in README with a grid for where fabric is supported - with a green check for ios / mac / android and a red X for windows and a note PRs are happily accepted
If you make the decision about a react-native backwards-compatibility testing cutoff for support + test it + document it + document the fabric support status we can tag this as a breaking change feature release and merge it (at which point semantic release will auto package + release and it is out the door)
Looks like there is a CI failure as well, the example may need an update to work with these changes:
commit message for merge, pending interpolation of backwards support results: BREAKING CHANGE: adding turbomodule support requires gradle vNNN, which drops support for react-native < 0.NN.NN - If you cannot update to that version of react-native or higher stay on previous version |
@mikehardy thanks for reviewing! I'll report back with the required changes.
👍 |
any updates on this? |
@mikehardy I've never done that before but I could handle the finalisation of that PR as @intergalacticspacehighway doesn't seem to respond... Do I create a new PR for that ? |
@matt-oakes can you take a look? 🙏 |
Closing this PR on favor of updated - #655. Thanks @j-piasecki. |
Overview
Addresses - #608
TurboModules is the new way to create native modules in react native. It loads the module lazily which can improve the start-up time and uses JSI to communicate with the platform. This PR migrates the existing native module to use turbomodule with backward compatibility.
Test Plan