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

Abstract storage implementation? #3

Open
rexxars opened this issue Jan 23, 2018 · 8 comments
Open

Abstract storage implementation? #3

rexxars opened this issue Jan 23, 2018 · 8 comments

Comments

@rexxars
Copy link

rexxars commented Jan 23, 2018

Hi,

This project looks like exactly the thing I need for a bunch of things I've been wanting to do. I tried including it in a project, but it seems Realm has a known issue where debugging JS remotely in react native fails on Android (see for instance realm/realm-js#562).

I was wondering how closely this project is tied to Realm, and whether or not you could achieve the same functionality with AsyncStorage, for instance? I understand you wouldn't get quite the same performance characteristics, but in many cases that isn't really an issue - rather you are looking for the queue semantics.

@billmalarky
Copy link
Owner

billmalarky commented Jan 23, 2018 via email

@rexxars
Copy link
Author

rexxars commented Jan 23, 2018

Thanks for the background and thorough explanation.
It's unfortunately pretty much impossible to use it as it is, since we really do need to debug the apps. I had a quick look for realm alternatives, but there's nothing that comes close to how easy it is to set up :/

@billmalarky
Copy link
Owner

@rexxars do you mind doing a rapid install of react-native-queue into your project and quickly throwing up a test worker and some example jobs then trying remote debugging?

I used chrome remote debugging for console logging etc when I was building this and performance was never a problem.

I also just fired up the workspace app I used to build react-native-queue and set up a bunch of debugging breakpoints, pause on exception etc, and walked through the code line-by-line and performance was never an issue.

I have a feeling that react-native-queue's realm footprint is just so small, that the known debugging performance problem is really a non-issue for react-native-queue.

For others, I'll paste the relevant part of the reddit thread here:

Typically realm native code communicates directly with your JS code via a private React Native api (ie, realm native code makes calls directly to JS code and vice versa), so it has great performance. This is possible when the JS thread and native code threads are running on the same device/simulator. However when using chrome debugging, your JS code is NOT run on your device/simulator, it is run inside of the chrome browser, while all the native code is running on your device/simulator. As a result, instead of realm native code making direct calls into your JS and vice versa, realm has to communicate using blocking ajax requests to chrome. You can imagine how awful performance is in that situation (well you don't have to imagine I guess).

The good news is this. These performance hits occur each and every time you touch realm. If you minimize exposure to realm, you minimize the debugging performance issues. React Native Queue is backed by realm, but the footprint is quite small (we only hit realm when a job is created, and when we pull jobs off the queue, and on job completion, that's pretty much it), such that I'd be surprised if the problem was anywhere near as bad as debugging a large app where realm was used for all persistence logic.

TL;DR react-native-queue doesn't seem to be hitting realm hard enough to actually cause the debugging performance issues that have people concerned about realm.

@rexxars
Copy link
Author

rexxars commented Jan 29, 2018

I'm afraid it's even worse than that - even without actually using the queue for anything, the app simply hangs on startup. Something like a minute before it actually kicks off and continues. Realm does do a bunch of weird things, like attempting to contact the remote debugging server over the 4G (public) IP, so it might just be that it's trying to connect to an incorrect IP and eventually times out and tries the next in line, for all I know.

I'm confident this doesn't have anything to do with your library, I was just hoping there was an alternative that is as easy to get up and running, but I have been unable to find one.

@billmalarky
Copy link
Owner

That's so weird, I've run this queue on simulated iOS/Android as well as on an actual android device and have never run into this problem. What version of react-native are you on if you don't mind me asking? That problem seems so glaring that I'd imagine just about everyone would report it, but I've only heard about it from some people, and I know that a fair amount of projects are already using react-native-queue (in addition to myself of course).

@rexxars
Copy link
Author

rexxars commented Jan 29, 2018

I'm on 0.52.1

@juliancorrea
Copy link

juliancorrea commented Apr 20, 2018

@rexxars I posted in another issue in this repo (#9) a workaround for it. The correction was done in realms(master), but there is no release yet.
Many devs are discussing this issue in: realm/realm-js#1711

@giautm
Copy link

giautm commented Jun 16, 2018

I want to use this project with another storage layer (ie Expo’s SQLite). So please abstract the data storage layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants