-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
Goals
I want to add an array of Chapter's of type Realm.Object to a Realm.List:
if videoChapters.isEmpty, let url = moduleSession.videoChaptersURL { _ = fileCacheVideoChapters.download(url) .then(on: .global()) { url -> Promise<[Chapter]> in return Chapter.readChapters(fromFile: url, ofContentId: moduleSessionID) } .done { [weak self] chapters in let realm = try Realm() if let moduleSession = realm.object(ofType: sessionType.objectType, forPrimaryKey: moduleSessionID) as? ModuleSession { try realm.write { realm.add(chapters, update: .all) moduleSession.videoChapters.append(objectsIn: chapters) } } self?.videoChapters = chapters.safeCopy() self?.sendEvent(.newData) } }
ModuleSession.videoChapters type is List<Chapter>.
Expected Results
Adding chapters to the ModuleSession object.
Actual Results
Stack trace from Crashlytics:
Crashed: com.apple.main-thread 0 libsystem_kernel.dylib 0x1c96457b0 __pthread_kill + 8 1 libsystem_pthread.dylib 0x1e5dc09c0 pthread_kill + 212 2 libsystem_c.dylib 0x1a64bfa44 abort + 100 3 Realm 0x101e29b70 realm::util::terminate(char const*, char const*, long) + 10 4 Realm 0x101e29e70 realm::util::terminate_internal(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 768 5 Realm 0x101e29fe8 realm::util::terminate(char const*, char const*, long, std::initializer_list<realm::util::Printable>&&) + 328 6 Realm 0x101c9a470 realm::BPlusTreeBase::create() + 256 7 Realm 0x101cdcb1c realm::Lst<realm::ObjKey>::insert(unsigned long, realm::ObjKey) + 80 8 Realm 0x101df6654 realm::LnkLst::insert(unsigned long, realm::ObjKey) + 2364 9 Realm 0x101bba0dc auto realm::List::dispatch<void realm::List::insert<objc_object* const __strong&, RLMAccessorContext>(RLMAccessorContext&, unsigned long, objc_object* const __strong&, realm::CreatePolicy)::'lambda'(objc_object* const __strong&)>(objc_object* const __strong&) const + 226 (list.hpp:226) 10 Realm 0x101bb6754 void realm::List::insert<objc_object* const __strong&, RLMAccessorContext>(RLMAccessorContext&, unsigned long, objc_object* const __strong&, realm::CreatePolicy) + 228 (list.hpp:228) 11 Realm 0x101bb92b8 invocation function for block in RLMInsertObject(RLMManagedArray*, objc_object*, unsigned long) + 260 (RLMManagedArray.mm:260) 12 Realm 0x101bb9300 auto translateErrors<void () block_pointer __strong&>(void () block_pointer __strong&) + 175 (RLMManagedArray.mm:175) 13 Realm 0x101bb68e0 changeArray(RLMManagedArray*, NSKeyValueChange, unsigned long, void () block_pointer) + 192 (RLMManagedArray.mm:192) 14 Realm 0x101bb61a4 RLMInsertObject(RLMManagedArray*, objc_object*, unsigned long) + 261 (RLMManagedArray.mm:261) 15 Realm 0x101bb60dc -[RLMManagedArray addObject:] + 265 (RLMManagedArray.mm:265) 16 RealmSwift 0x10221ce48 List.append<A>(objectsIn:) + 271 (List.swift:271) 17 Optimize 0x100d1e438 partial apply for closure #1 in closure #8 in ModuleSessionViewModel.fetchRelatedContent() + 213 (ModuleSessionViewModel.swift:213) 18 Optimize 0x100d8e934 thunk for @callee_guaranteed () -> (@error @owned Error) + 4379896116 (<compiler-generated>:4379896116) 19 Optimize 0x100d1e468 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) + 4379436136 (<compiler-generated>:4379436136) 20 RealmSwift 0x102233ed0 Realm.write<A>(withoutNotifying:_:) + 255 (Realm.swift:255) 21 Optimize 0x100d1d870 closure #8 in ModuleSessionViewModel.fetchRelatedContent() + 211 (ModuleSessionViewModel.swift:211) 22 Optimize 0x100d1e390 partial apply for closure #10 in ModuleSessionViewModel.fetchRelatedContent() + 4379435920 23 Optimize 0x100d1e36c partial apply for closure #8 in ModuleSessionViewModel.fetchRelatedContent() + 4379435884 24 Optimize 0x100d1e15c partial apply for thunk for @escaping @callee_guaranteed (@guaranteed [MasterClass]) -> (@error @owned Error) + 4379435356 (<compiler-generated>:4379435356) 25 Optimize 0x100d1e710 thunk for @escaping @callee_guaranteed (@guaranteed [Chapter]) -> (@error @owned Error)partial apply + 4379436816 26 PromiseKit 0x101b51950 partial apply for closure #1 in closure #1 in Thenable.done(on:flags:_:) + 207 (Thenable.swift:207) 27 PromiseKit 0x101b2e494 thunk for @escaping @callee_guaranteed () -> () + 4364 (<compiler-generated>:4364) 28 libdispatch.dylib 0x19d4d22b0 _dispatch_call_block_and_release + 24 29 libdispatch.dylib 0x19d4d3298 _dispatch_client_callout + 16 30 libdispatch.dylib 0x19d481ce0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 904 31 CoreFoundation 0x19d81a2e0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 32 CoreFoundation 0x19d814740 __CFRunLoopRun + 2528 33 CoreFoundation 0x19d813818 CFRunLoopRunSpecific + 572 34 GraphicsServices 0x1b3f19570 GSEventRunModal + 160 35 UIKitCore 0x1a013f0e8 -[UIApplication _run] + 1052 36 UIKitCore 0x1a0144664 UIApplicationMain + 164 37 Optimize 0x100c70d98 main + 20 38 libdyld.dylib 0x19d4f2140 start + 4
Steps for others to Reproduce
It does not fail consistently, I couldn't reproduce the issue locally.
Version of Realm and Tooling
Realm framework version: 10.7.4
Xcode version: 12.5
iOS/OSX version: 14.6
Dependency manager + version: CocoaPods 1.10.1