Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's actually written in React Native with a fair bit of C++ (TensorFlow), and some Objective-C++ to glue the two. One cool thing we added on top of React Native was a hack to let us inject new versions of our deep learning model on the fly without going through an App Store review. If you thought injecting JavaScript to change the behavior of your app was cool, you need to try injecting neural nets, it's quite a feeling :D


This looks great, haha! Shame I can't access it from the UK.

It would be really interesting to read more about your thoughts on working with RN and C++ and perhaps how you did some of it. I'm currently doing the same (but with a C++ audio engine rather than image processing stuff) and I think it's an incredibly powerful combination - but I do feel like I'm making up some interop patterns as I go and there might be better ways, so would love to hear how other people use it!

Broadly, I've created a "repository" singleton that stores a reference to both the React Native module instance (which gets set when I call its setup method from JS) and the C++ main class instance (which gets set when it starts up), so they can get a handle on each other (I bet there are better ways to do this, but I'm new to C++/ObjC and couldn't work out a better way to get a reference to the RN module).

I'm then using RCT_EXPORT_METHOD to provide hooks for JS to call into C++ via an ObjC bridge (in an RCT_EXPORT_MODULE class), and using the event emitter to communicate back to JS (so the C++ can get the RN module instance from the singleton and call methods which emit events).

I've not done anything that really pushes the bridge performance to a point where I've seen any noticeable latency/slow down caused by the interop - have you had any issues here?

Like I say, I'm finding a really cool way to build apps that need the power of native code but still with the ease of RN as the GUI and some logic, and I actually quite like the separation it enforces with the communication boundary.


Sounds like you're further ahead than I was with the React Native part! Not Hotdog is very simple so I just wrote a simple Native module around my TensorFlow code and let the chips fall where they may performance-wise. The snap/analyze/display sequence is slow enough that I don't need to worry about fps or anything like that. As much as I enjoyed using RN for this app, I would probably move to native code if I needed to be able to tune performance.


Can you explain to a noob how you wrote the Native module around TensorFlow? My main area of focus is in python, but I feel hindered when I think I'm ready to start developing for mobile apps. I'm looking into RN, but still not sure how that plays with TF and other python modules.


It was honestly just maybe 10 lines of code, but I was very confused about it before I got it done. The message passing is a bit counterintuitive at first. I'll try to share example code in my blogpost!


awesome, what's your blog?


See this sub-discussion re:performance (+serialization/marshalling) in today's React Native discussion:

https://news.ycombinator.com/item?id=14349426


can you please open source it. It would be great if you open source it.


So what you're saying is you can update the neural net to do dick or not dick without going through the App Store review?


Nice! I'd never known that C++ could be used in an iOS app; learned something new today thanks.


It would be relatively easy to port to Android. Please open source it!


Hey guys, how would I be able to add characters to an account for injustice and then disable the anti-cheat. I want to basically make it so that i cant get banned for using characters I added to my account.


What was the hack?


When using React Native (and also storing your network in JS) you can choose to push updates and fixes to JS part of your code without going through store again.

Check: http://microsoft.github.io/code-push/


Yup that's basically it. The hack was just in getting Tensorflow to accept/load its neural network definition from the JS bundle (what CodePush distributes for you) rather than from the main Cocoa bundle.


Just as a note, people/developers have had messages from Apple telling them that they need to remove code which allows them to update their app outside of the app update/review process.

See https://news.ycombinator.com/item?id=13817557 for some more detail/discussion.

[edit: Apart from in Apple-approved manners]


https://developer.apple.com/programs/ios/information/iOS_Pro...

> 3.3.2 […] The only exception to the foregoing is scripts and code downloaded and run by Apple’s built-in WebKit framework or JavascriptCore […]


Well, that's not gonna fly with the "code is data, data is code" crowd ...

If the newspaper apps get to load fresh front page images, why should a poor neural net be discriminated in its quest for fresh coefficients?

(Raw oppression and injustice there, get yer indignation reservoir topped up.)


Really cool stuff! I didn't even realise you've switched jobs, but that explains why I didn't see you when we popped in at Townsend the other day! Keep up the good work.


I'm surprised Apple allows this, I thought they hated this kind of thing.


I really have no idea what any of that means, no Android then?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: