react-native-threads icon indicating copy to clipboard operation
react-native-threads copied to clipboard

Doesn't work with realm

Open IamRoman opened this issue 6 years ago • 9 comments

Hi! I'm trying a project with realm but I catch error "com.facebook.react.JavaScript (15): EXC_BAD_ACCESS (code=1, address=0x0)" after (Cmd + R), testing also did on android (real devices), it works without errors, but it does not start another thread.

2018-05-11 14 46 13

Thanks!

IamRoman avatar May 11 '18 12:05 IamRoman

Hi @IamRoman, I have no experience using Realm so unfortunately I am not sure what we could do to resolve this issue. I do not think this error is caused by react-native-threads but is probably an error with Realm

Traviskn avatar Jun 02 '18 20:06 Traviskn

Same issue here

joaom182 avatar Jul 14 '18 18:07 joaom182

Hi! Did anybody find a solution or workaround?

gitTeub avatar Oct 12 '18 09:10 gitTeub

Hi there ! You are not alone using Realm and this package at the same time. For now, my project is targetting only Android and I have not crossed yet any problem on Android. We will soon target iOS so I guess we will have the same issue. I'll tell here if we find a solution...

zabojad avatar Nov 14 '18 14:11 zabojad

OK, actually, it is not working with Android neither.

As soon as we start a new thread, Realm gets closed. I've created an issue about it there: https://github.com/realm/realm-js/issues/2117

zabojad avatar Nov 15 '18 23:11 zabojad

any update? pls

z98361 avatar Nov 24 '18 13:11 z98361

Hi, I found a workaround that makes these two libraries work together. Firstly, starting of new thread for some reason kills realm, so I reinitialized realm whenever I used it. Rather then exporting realm instance and using it in every file I just exported schema and reinitialized realm there. It looks something like this const realm = new Realm({ schema : schemas }); I initialized this variable before using any realm operation and it worked without crashing

nickymagic avatar Feb 01 '19 13:02 nickymagic

Unfortunately this is still an issue. Any ideas for even a hacky fix?

tastyqbit avatar May 18 '20 15:05 tastyqbit

I can use both of these libraries in my project. All you need to do is to use Realm in only one thread. For example I only use Realm in the worker thread so that my main thread doesn't know there is Realm, but you can communicate with postMessage and onmessage methods. Hope it helps.

[Edit] It works on Android, but in my test on iOS, it failes to bundle the thread. Loading stucks at 100%.

SMhdAsadi avatar May 19 '22 12:05 SMhdAsadi