-
Notifications
You must be signed in to change notification settings - Fork 586
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
Realm.open() hangs on Android #1248
Comments
This only happens on Android, iOS works fine. |
@Damnum In the server log, can you see that the user is logged in? |
@kneth by the time I make the
I suppose that happens when the user token is refreshed. Same error happens with iOS on the server, though it only hangs on Android. Happens on Android physical device and simulator. I'm connecting to a server hosted on DigitalOcean. May be related to realm/realm-tasks#397 EDIT: I also setup the realm on a server running on localhost. Still hangs, and the server doesn't even show the error above, so the error is probably not related. |
@kneth I tested the exact same configuration on Android (both simulator and device) and iOS, with both localhost and server. Result: On iOS, everything works as expected. On Android, function Looks like this function is wrapped into CPP code: Line 588 in 85fb49b
Please let me know how to debug this code. Is there a way to print out logs there? |
@Damnum Sorry the the late reply. Is it possible for you to contribute a small project which can reproduce the issue? |
@kneth I will try. Not sure if it's important but I'm using the Android Java SDK to pre-fill the data in the first place. I now tried to switch to ROS 2.0.0 rc-2, and realm-js 2.0.0-rc5 (on Android Java site: 4.0.0-BETA2-afe7114-SNAPSHOT). Same result though. I'm attaching the server log from the moment the client makes the EDIT: I'm also attaching the server log for the (working) Seems like the login takes place in both logs, but the actual synced realm (called |
@kneth have you had the chance to look at the logs? I realized that the logs are identical until a point where on iOS, the log says:
After that, the actual download starts. On Android, the log is silent instead (apart from sending stats). (see time 3:50:13) |
@kneth I could reproduce the bug with a very simple setup.
|
Guys, this maybe related to not invoking the promise rejection with settimeout. This maybe the fix for it Long story short on RN we have a requirement to use this hack with setTimeout(func, 1) to allow the promise to continue. We have an issue to resolve this properly here #1255 until then this seems like the workaround to use. You may try cherry picking this fix and testing if the rejection is causing the promise to be stuck |
@blagoev I think that will not help in this case. When I debug in this code, the callback given to the Line 47 in 416632c
That means, line 48 will not even get called at all, so your timeout will never be reached. mE the only way to fix this is inside the wrapping As far as I can tell, the server log is also silent about it. |
I'm able to reproduce the issue and indeed the callback to |
@Damnum I mentioned this maybe the reason for a hang. If the callback is not called then the hang is in c++ code and we need to debug it to know exactly why. Still a hang in Realm.open will happen in RN if setTimeout is not used for resolve and reject, until we fix the callback issue in RN. Hopefully when we debug the c++ we will get more details why this happens. |
@blagoev do you know how to add debug statements into the c++ code? I tried it with
But no luck so far... |
Probably the best way is to debug the c++ code in Android Studio, but these __android_log_print should be working as well. Check that this code is picked up when you build the android app. Probably this requires an npm uninstall realm realm-tests && npm install again before build. @ashwinphatak is looking into this as well. |
Added some debugging statements and it appears that the callback to |
Thanks for the digging @ashwinphatak ! I'm not really familiar with these native components... do you know if the source code for them is open source? |
@ashwinphatak any news on this? This is a real blocker for our project. |
|
I'm using With even simpler setup code:
|
I'm able to reproduce this as well, on android the first app load works, but reloading JS code makes |
@bmunkholm @kneth not sure why this has been marked as "optional"? Failing to open the database is pretty basic stuff because without it you can't do anything else?! |
@Damnum I can see how that can be confusing :-) |
Ok thanks for clarifying, that makes sense! |
is this fix available via npm yet? |
yes it is |
EDIT: This also happens after reloading the emulator on React Native, in a very simple setup (see below #1248 (comment))
Goals
Get an error message when opening a synced realm if server not available or user is offline.
Expected Results
Realm.open() returns a promise that gets rejected with useful error message.
Actual Results
The promise simply stays in pending status indefinitely.
This callback does not get called:
realm-js/lib/extensions.js
Line 47 in 416632c
Hence the promise never returns.
Steps to Reproduce
Run this code after log in with valid user:
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: