Since the 2.13.0 release yesterday which I believe included the missing Realm.Sync.Subscription object being returned after subscribing to a results object. Calling the addlistener method provokes a crash on RN
Add a listener to a partial realm subscription object
Listener is added without issues.
The app crashes.
* thread #55, name = 'com.facebook.react.JavaScript', stop reason = EXC_BAD_ACCESS (code=1, address=0x3ed8)
frame #0: 0x000000010aa3bb4f JavaScriptCore`JSC::JSLockHolder::JSLockHolder(JSC::ExecState*) + 15
frame #1: 0x000000010a31bda1 JavaScriptCore`JSValueMakeNumber + 33
* frame #2: 0x0000000106a6030f UgoApp`realm::js::Value<realm::jsc::Types>::from_number(ctx=0x000070000a78f320, number=1) at jsc_value.hpp:135
frame #3: 0x0000000106aff5fb UgoApp`realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(this=0x000061400047f288)::'lambda'()::operator()() const at js_sync.hpp:673
frame #4: 0x0000000106aff58d UgoApp`void std::__1::__invoke_void_return_wrapper<void>::__call<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) [inlined] decltype(__f=0x000061400047f288)::'lambda'()&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) at type_traits:4323
frame #5: 0x0000000106aff57c UgoApp`void std::__1::__invoke_void_return_wrapper<void>::__call<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(__args=0x000061400047f288)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) at __functional_base:349
frame #6: 0x0000000106aff249 UgoApp`std::__1::__function::__func<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'(), std::__1::allocator<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()>, void ()>::operator(this=0x000061400047f280)() at functional:1562
frame #7: 0x00000001062a6adb UgoApp`std::__1::function<void ()>::operator(this=0x000061400047f280)() const at functional:1921
frame #8: 0x0000000106cc933d UgoApp`realm::partial_sync::Subscription::add_notification_callback(this=0x00006140002ae670, (null)=CollectionChangeSet @ 0x000070000a7902b0, (null)=(__ptr_ = 0x0000000000000000))>)::$_6::operator()(realm::CollectionChangeSet, std::exception_ptr) const at partial_sync.cpp:585
frame #9: 0x0000000106cc8fe1 UgoApp`realm::CollectionChangeCallback::Impl<realm::partial_sync::Subscription::add_notification_callback(std::__1::function<void ()>)::$_6>::after(this=0x00006140002ae660, change=0x000070000a7903c0) at collection_notifications.hpp:157
frame #10: 0x00000001069ff7ea UgoApp`realm::CollectionChangeCallback::after(this=0x000070000a7903b0, c=0x000070000a7903c0) at collection_notifications.hpp:122
frame #11: 0x00000001069ff756 UgoApp`auto realm::_impl::CollectionNotifier::after_advance(this=0x000070000a790580, lock=0x000070000a7904d8, callback=0x00007fe7cf9020d0)::$_9::operator()<std::__1::unique_lock<std::__1::mutex>, realm::_impl::CollectionNotifier::Callback>(std::__1::unique_lock<std::__1::mutex>&, realm::_impl::CollectionNotifier::Callback&) const at collection_notifier.cpp:332
frame #12: 0x00000001069f2d88 UgoApp`void realm::_impl::CollectionNotifier::for_each_callback<realm::_impl::CollectionNotifier::after_advance()::$_9>(this=0x00007fe7df60ba18, fn=0x000070000a790580)::$_9&&) at collection_notifier.cpp:378
frame #13: 0x00000001069f2bd9 UgoApp`realm::_impl::CollectionNotifier::after_advance(this=0x00007fe7df60ba18) at collection_notifier.cpp:321
frame #14: 0x00000001069f5618 UgoApp`realm::_impl::NotifierPackage::after_advance(this=0x000070000a7907a0) at collection_notifier.cpp:490
frame #15: 0x0000000106ba46b4 UgoApp`realm::_impl::RealmCoordinator::advance_to_ready(this=0x00007fe7dc641b70, realm=0x00007fe7dc643eb0) at realm_coordinator.cpp:801
frame #16: 0x0000000106c74f72 UgoApp`realm::Realm::notify(this=0x00007fe7dc643eb0) at shared_realm.cpp:801
frame #17: 0x0000000106d6cebe UgoApp`realm::_impl::WeakRealmNotifier::Callback::operator(this=0x000060c000238460)() const at weak_realm_notifier.cpp:42
frame #18: 0x0000000106d6df1c UgoApp`realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::EventLoopSignal(this=0x0000000106d6dee0, info=0x000060c000238460)::'lambda'(void*)::operator()(void*) const at event_loop_signal.hpp:37
frame #19: 0x0000000106d6def8 UgoApp`realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::EventLoopSignal(info=0x000060c000238460)::'lambda'(void*)::__invoke(void*) at event_loop_signal.hpp:36
frame #20: 0x000000010f953bb1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #21: 0x000000010f9384af CoreFoundation`__CFRunLoopDoSources0 + 271
frame #22: 0x000000010f937a6f CoreFoundation`__CFRunLoopRun + 1263
frame #23: 0x000000010f93730b CoreFoundation`CFRunLoopRunSpecific + 635
frame #24: 0x0000000106230d6b UgoApp`::+[RCTCxxBridge runRunLoop](self=RCTCxxBridge, _cmd="runRunLoop") at RCTCxxBridge.mm:246
frame #25: 0x000000010d4fa3b3 Foundation`__NSThread__start__ + 1221
frame #26: 0x0000000110d16661 libsystem_pthread.dylib`_pthread_body + 340
frame #27: 0x0000000110d1650d libsystem_pthread.dylib`_pthread_start + 377
frame #28: 0x0000000110d15bf9 libsystem_pthread.dylib`thread_start + 13
Assign a listenr to a result as below..
const results = realm.objects('Job')
const subscription = results.subscribe()
subscription.addListener(() => {}) // crash here
Yes, I can reproduce the bug (also on Android). But it seems to work if you add a listener to results (subscription.state will have the expected value when it is called).
[edited] A temporary work around for anyone who comes across this is...
static subscribe (results) {
var subscription = results.subscribe()
var interval
return new Promise((resolve, reject) => {
interval = setInterval(() => {
if (subscription.state === Realm.Sync.SubscriptionState.Complete) {
clearInterval(interval)
resolve(results)
}
}, 200)
setTimeout(() => {
clearInterval(interval)
reject('subscribe timeout')
}, 5000)
})
}
// usage
let objs = realm.objects('ObjectName')
subscribe(objs).then(...)
@sambwest I believe I have found it, and it is a bit embarrassing to have overlooked it for so many weeks.
@kneth should this be fixed in 2.14.2? I just upgraded and still seem to have an issue.
@sambwest No, but it will be included in 2.15.0 which I will release today or tomorrow.
The issue seems to still be present after upgrade 2.15.3:
* thread #18, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x000000010bd3eb59 JavaScriptCore`JSC::JSLockHolder::JSLockHolder(JSC::ExecState*) + 25
frame #1: 0x000000010b61eda1 JavaScriptCore`JSValueMakeNumber + 33
* frame #2: 0x0000000107d6a68f UgoApp`realm::js::Value<realm::jsc::Types>::from_number(ctx=0x000070000acf2e90, number=1) at jsc_value.hpp:135
frame #3: 0x0000000107e0997b UgoApp`realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(this=0x0000624000267cc8)::'lambda'()::operator()() const at js_sync.hpp:673
frame #4: 0x0000000107e0990d UgoApp`void std::__1::__invoke_void_return_wrapper<void>::__call<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) [inlined] decltype(__f=0x0000624000267cc8)::'lambda'()&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) at type_traits:4323
frame #5: 0x0000000107e098fc UgoApp`void std::__1::__invoke_void_return_wrapper<void>::__call<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(__args=0x0000624000267cc8)::'lambda'()&>(realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()&&&) at __functional_base:349
frame #6: 0x0000000107e095c9 UgoApp`std::__1::__function::__func<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'(), std::__1::allocator<realm::js::SubscriptionClass<realm::jsc::Types>::add_listener(OpaqueJSContext const*, OpaqueJSValue*, realm::js::Arguments<realm::jsc::Types>, realm::js::ReturnValue<realm::jsc::Types>&)::'lambda'()>, void ()>::operator(this=0x0000624000267cc0)() at functional:1562
frame #7: 0x00000001075b0dfb UgoApp`std::__1::function<void ()>::operator(this=0x0000624000267cc0)() const at functional:1921
frame #8: 0x0000000107fd36bd UgoApp`realm::partial_sync::Subscription::add_notification_callback(this=0x00006240000af990, (null)=CollectionChangeSet @ 0x000070000acf2e70, (null)=(__ptr_ = 0x0000000000000000))>)::$_6::operator()(realm::CollectionChangeSet, std::exception_ptr) const at partial_sync.cpp:585
frame #9: 0x0000000107fd3361 UgoApp`realm::CollectionChangeCallback::Impl<realm::partial_sync::Subscription::add_notification_callback(std::__1::function<void ()>)::$_6>::after(this=0x00006240000af980, change=0x000070000acf2f80) at collection_notifications.hpp:157
frame #10: 0x0000000107d09b6a UgoApp`realm::CollectionChangeCallback::after(this=0x000070000acf2f70, c=0x000070000acf2f80) at collection_notifications.hpp:122
frame #11: 0x0000000107d09ad6 UgoApp`auto realm::_impl::CollectionNotifier::after_advance(this=0x000070000acf3140, lock=0x000070000acf3098, callback=0x00007f85c2b15890)::$_9::operator()<std::__1::unique_lock<std::__1::mutex>, realm::_impl::CollectionNotifier::Callback>(std::__1::unique_lock<std::__1::mutex>&, realm::_impl::CollectionNotifier::Callback&) const at collection_notifier.cpp:332
frame #12: 0x0000000107cfd108 UgoApp`void realm::_impl::CollectionNotifier::for_each_callback<realm::_impl::CollectionNotifier::after_advance()::$_9>(this=0x00007f85c2d10368, fn=0x000070000acf3140)::$_9&&) at collection_notifier.cpp:378
frame #13: 0x0000000107cfcf59 UgoApp`realm::_impl::CollectionNotifier::after_advance(this=0x00007f85c2d10368) at collection_notifier.cpp:321
frame #14: 0x0000000107cff998 UgoApp`realm::_impl::NotifierPackage::after_advance(this=0x000070000acf3910) at collection_notifier.cpp:490
frame #15: 0x000000010804c2b8 UgoApp`void (anonymous namespace)::advance_with_notifications<realm::_impl::transaction::advance(context=0x000061c00010a3b0, sg=0x00007f85c2b1a720, func=0x000070000acf37f8, notifiers=0x000070000acf3910)::$_1>(realm::BindingContext*, std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> > const&, realm::_impl::transaction::advance(std::__1::unique_ptr<realm::SharedGroup, std::__1::default_delete<realm::SharedGroup> > const&, realm::BindingContext*, realm::_impl::NotifierPackage&)::$_1&&, realm::_impl::NotifierPackage&) at transact_log_handler.cpp:792
frame #16: 0x000000010804bb6c UgoApp`realm::_impl::transaction::advance(sg=0x00007f85c2b1a720, context=0x000061c00010a3b0, notifiers=0x000070000acf3910) at transact_log_handler.cpp:826
frame #17: 0x0000000107eaeafa UgoApp`realm::_impl::RealmCoordinator::advance_to_ready(this=0x00007f85c2b18100, realm=0x00007f85c2b1a5c0) at realm_coordinator.cpp:809
frame #18: 0x0000000107f7f2f2 UgoApp`realm::Realm::notify(this=0x00007f85c2b1a5c0) at shared_realm.cpp:801
frame #19: 0x000000010807723e UgoApp`realm::_impl::WeakRealmNotifier::Callback::operator(this=0x0000600000223f00)() const at weak_realm_notifier.cpp:42
frame #20: 0x000000010807829c UgoApp`realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::EventLoopSignal(this=0x0000000108078260, info=0x0000600000223f00)::'lambda'(void*)::operator()(void*) const at event_loop_signal.hpp:37
frame #21: 0x0000000108078278 UgoApp`realm::util::EventLoopSignal<realm::_impl::WeakRealmNotifier::Callback>::EventLoopSignal(info=0x0000600000223f00)::'lambda'(void*)::__invoke(void*) at event_loop_signal.hpp:36
frame #22: 0x0000000110bb4bb1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #23: 0x0000000110b994af CoreFoundation`__CFRunLoopDoSources0 + 271
frame #24: 0x0000000110b98a6f CoreFoundation`__CFRunLoopRun + 1263
frame #25: 0x0000000110b9830b CoreFoundation`CFRunLoopRunSpecific + 635
frame #26: 0x0000000110bd4c63 CoreFoundation`CFRunLoopRun + 99
frame #27: 0x0000000107f17036 UgoApp`realm::rpc::RPCWorker::RPCWorker(this=0x000060c0000128f8)::$_0::operator()() const at rpc.cpp:107
frame #28: 0x0000000107f16d71 UgoApp`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::rpc::RPCWorker::RPCWorker()::$_0> >(void*) [inlined] decltype(__f=0x000060c0000128f8)::$_0>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<realm::rpc::RPCWorker::RPCWorker()::$_0>(realm::rpc::RPCWorker::RPCWorker()::$_0&&) at type_traits:4323
frame #29: 0x0000000107f16d60 UgoApp`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::rpc::RPCWorker::RPCWorker()::$_0> >(void*) [inlined] void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::rpc::RPCWorker::RPCWorker()::$_0>(__t=0x000060c0000128f0)::$_0>&, std::__1::__tuple_indices<>) at thread:342
frame #30: 0x0000000107f16d3c UgoApp`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::rpc::RPCWorker::RPCWorker()::$_0> >(__vp=0x000060c0000128f0) at thread:352
frame #31: 0x000000011201a661 libsystem_pthread.dylib`_pthread_body + 340
frame #32: 0x000000011201a50d libsystem_pthread.dylib`_pthread_start + 377
frame #33: 0x0000000112019bf9 libsystem_pthread.dylib`thread_start + 13
(lldb)
@sambwest Thanks for reporting.
@sambwest are you still experiencing this? I couldn't reproduce the crash after updating to 2.15.3
1- How did you perform the upgrade?
2- Are you able to reproduce it consistently?
3- Does it happen in debug mode only?
@nhachicha apologies for the delay, what code are you using to test?
1 - Yarn add [email protected] - react-native link realm - clean - build
2 - Yes
3 - No. It happens in both.
Apologies I think this is due to my updating. Gone in 2.15.3, thanks closing.