-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Bridge] RFC: Shader-like native code system #2212
Comments
@devknoll - don't know how I didn't notice this sooner, really cool idea. cc @vjeux @sahrens @tadeuzagallo |
This sounds like a promising idea. I'd really love to see a list of proposals / prototypes to fix this class of problems. Huge potential there |
I'd probably amend this proposal to import Obj-C/Java classes as modules, instead of functions, as originally written. I'd love to see some other proposals too. This seems like the lesser of the evils (another being full cocoa pods support / importing pods from node modules, which seems like it might be over kill) so far... |
Would it basically he a code-gen step before compilation? Definitely interesting...might not even be that hard to build. I'm not sure it would be that much better than just writing actual native code though...we could design some of our native modules, like TextFieldManager, to have a pluggable extention system, so you could, for example, register a custom shouldChangeCharactersInRange handler, similar to how you can inject bridge modules, but they would be within other modules. |
It would be kind of like subclass in or categories, but with a more explicit API. |
I think one big benefit would be sharing code with native bits more streamlined. Currently you have to use cocoa pods, or manually add an Xcodeproj. This is a bummer when all I want to do is format my text input ;-) Longer term, it might be possible to break up react-native into smaller modules, with each containing just the small bit of native code that it actually uses. I'm not sure if the current proposal deserves the name of a codegen step -- it would just concatenate all of the native modules it found as a prebuild step, possibly with some annotations so that the runtime could discover it. |
I'd be interested in seeing a way to enable synchronous calls in regular modules. For example: The use case I'm interested in is working with OpenGL from React Native. Shimming WebGL would be a massive feature for React Native that would have tremendous potential. |
Thanks for opening this issue! We are closing it because it's a feature discussion, and we're trying to focus Github issues on bugs. Feel free to send us a Pull Request or create an entry on Product Pains. If the feature gets upvoted enough it might get implemented. |
I briefly mentioned this here, but I thought I'd take a moment to hash it out a little further.
It seems like there are a number of cases where you might need to perform some logic either synchronously (e.g.
shouldChangeCharactersInRange
for formatting) or the bridge is too slow (e.g.Animated
).I think it would be beneficial to allow those cases to be mostly resolved in JavaScript where possible, but with the ability to use native code where necessary to get the job done.
I propose that we add some way for npm module authors to specify snippets of native code that they can then use in their components. Here's how that might look for
TextInput
:You could imagine doing the same thing to allow e.g. arbitrary formulas to be used by
Animated
.The first step in the build process would then be to scour node_modules/ for any native requires, and generate a single file (already in the Xcode project, so it can just be overwritten) with the contents.
I'm happy to work on this if it sounds like a good idea.
Thoughts?
The text was updated successfully, but these errors were encountered: