Martin Gagnon
09/28/2020, 9:28 PMcancellableManager.cancel()
that cancel and frees a list of object.
• The list inside the cancellableManager
is replaced by a frozen new list (Stored inside an AtomicReference)
• Assert happens
I would really like some support from @cschramm here 😉 In any case, I’ll continue trying to understand this issue.
Could it be possible that the GC can be triggered by the common code and simultaneously by Swift ? (Common Code triggers the GC -> this has an impact on the swift Code, swift code triggers the GC)?svyatoslav.scherbina
09/29/2020, 8:21 AMSwift class deinit gets callPlease try to dispatch the deinit task (at least the part involving Kotlin) to execute it later asynchronously, i.e.
class SwiftClass {
deinit {
foo()
}
}
->
class SwiftClass {
deinit {
DispatchQueue.main.async {
foo()
}
}
}
Does this fix the problem?
Also please share your stack trace from the debugger.Martin Gagnon
09/29/2020, 1:35 PMMartin Gagnon
09/29/2020, 1:35 PMCrashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x199f64df0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x199e84948 pthread_kill + 228
2 libsystem_c.dylib 0x199e13ba4 abort + 104
3 Leogali 0x103b99050 ObjHeader::createMetaObject(TypeInfo**) + 10
4 Leogali 0x103b98ff4 konan::snprintf(char*, unsigned long, char const*, ...) + 166
5 Leogali 0x103ba0914 (anonymous namespace)::garbageCollect(MemoryState*, bool) + 116
6 Leogali 0x103baf72c FreezeSubgraph + 316
7 Leogali 0x103bc59cc Kotlin_Worker_freezeInternal + 32
8 Leogali 0x1033d2ae8 kfun:kotlin.native.concurrent#freeze@0:0(){0§<kotlin.Any?>}0:0 + 33 (Freezing.kt:33)
9 Leogali 0x1034738e0 kfun:com.mirego.trikot.foundation.concurrent.AtomicReference#compareAndSet(1:0;1:0){}kotlin.Boolean + 13 (AtomicReference.kt:13)
10 Leogali 0x10346e0f8 kfun:com.mirego.trikot.foundation.concurrent.AtomicListReference.mutateWhenReady#internal + 27 (AtomicListReference.kt:27)
11 Leogali 0x10346dae4 kfun:com.mirego.trikot.foundation.concurrent.AtomicListReference#removeAll(kotlin.collections.List<1:0>){}kotlin.collections.List<1:0> + 13 (AtomicListReference.kt:13)
12 Leogali 0x1034792b4 kfun:com.mirego.trikot.streams.cancellable.CancellableManager.doCancelAll$lambda-0#internal + 37 (CancellableManager.kt:37)
13 Leogali 0x1034796cc kfun:com.mirego.trikot.streams.cancellable.CancellableManager.$doCancelAll$lambda-0$FUNCTION_REFERENCE$1150.invoke#internal + 35 (CancellableManager.kt:35)
14 Leogali 0x10347972c kfun:com.mirego.trikot.streams.cancellable.CancellableManager.$doCancelAll$lambda-0$FUNCTION_REFERENCE$1150.$<bridge-UNN>invoke(){}#internal + 35 (CancellableManager.kt:35)
15 Leogali 0x1034709b0 kfun:com.mirego.trikot.foundation.concurrent.dispatchQueue.SynchronousDispatchQueue#dispatch(kotlin.Function0<kotlin.Unit>){} + 7 (SynchronousDispatchQueue.kt:7)
16 Leogali 0x10346fa50 kfun:com.mirego.trikot.foundation.concurrent.dispatchQueue.SequentialDispatchQueue#dispatch(kotlin.Function0<kotlin.Unit>){} + 20 (SequentialDispatchQueue.kt:20)
17 Leogali 0x10347913c kfun:com.mirego.trikot.streams.cancellable.CancellableManager.doCancelAll#internal + 35 (CancellableManager.kt:35)
18 Leogali 0x10347901c kfun:com.mirego.trikot.streams.cancellable.CancellableManager#cancel(){} + 31 (CancellableManager.kt:31)
19 Leogali 0x103996448 objc2kotlin.2207 + 1 (<compiler-generated>:1)
20 libswiftCore.dylib 0x1a7c5f3e0 _swift_release_dealloc + 36
21 libobjc.A.dylib 0x199ea924c _object_remove_assocations + 336
22 libobjc.A.dylib 0x199ea602c objc_destructInstance + 104
23 libobjc.A.dylib 0x199eac8e8 _objc_rootDealloc + 60
24 UIKitCore 0x19e2d3830 -[UIResponder dealloc] + 156
25 UIKitCore 0x19e748288 -[UIView dealloc] + 876
26 UIKitCore 0x19dc8de20 -[UIControl dealloc] + 72
27 UIKitCore 0x19dc7d9a4 -[UIButton dealloc] + 100
28 Foundation 0x19a53e54c NSKVODeallocate + 208
29 Leogali 0x103ba5c74 Kotlin_ObjCExport_releaseAssociatedObject + 40
30 Leogali 0x103ba5568 (anonymous namespace)::freeContainer(ContainerHeader*) + 1176
31 Leogali 0x103ba4ea0 (anonymous namespace)::decrementRC(ContainerHeader*) + 308
32 Leogali 0x103ba0c94 (anonymous namespace)::garbageCollect(MemoryState*, bool) + 1012
33 Leogali 0x103bae904 AllocArrayInstanceStrict + 568
34 Leogali 0x103bd4454 Kotlin_Interop_CreateKStringFromNSString + 128
35 Leogali 0x103bd2c58 Kotlin_ObjCExport_refFromObjC + 84
36 Leogali 0x103bd4008 Kotlin_NSDictionaryAsKMap_getOrThrowConcurrentModification + 292
37 Leogali 0x1033ed0f0 kfun:kotlin.native.internal.NSDictionaryAsKMap.EntryIterator.next#internal + 172 (ObjCExportUtils.kt:172)
38 Leogali 0x1033beef4 kfun:kotlin.collections.HashMap.putAllEntries#internal + 439 (HashMap.kt:439)
39 Leogali 0x1033ba0f4 kfun:kotlin.collections.HashMap#putAll(kotlin.collections.Map<out|1:0,1:1>){} + 82 (HashMap.kt:82)
40 Leogali 0x1033b99d4 kfun:kotlin.collections.HashMap#<init>(kotlin.collections.Map<out|1:0,1:1>){} + 43 (HashMap.kt:43)
41 Leogali 0x10337a4a8 kfun:kotlin.collections#plus@kotlin.collections.Map<out|0:0,0:1>(kotlin.collections.Map<out|0:0,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}kotlin.collections.Map<0:0,0:1> + 662 (Maps.kt:662)
42 Leogali 0x10352e664 kfun:com.mirego.trikot.kword.DefaultI18N.getWithReplacements#internal + 44 (DefaultI18N.kt:44)
43 Leogali 0x10352e810 kfun:com.mirego.trikot.kword.DefaultI18N#getWithReplacements$default(com.mirego.trikot.kword.KWordKey;kotlin.collections.Map<kotlin.String,kotlin.String>?;kotlin.Int){}kotlin.String + 38 (DefaultI18N.kt:38)
44 Leogali 0x10352de74 kfun:com.mirego.trikot.kword.DefaultI18N#get(com.mirego.trikot.kword.KWordKey){}kotlin.String + 22 (DefaultI18N.kt:22)
45 Leogali 0x10352df9c kfun:com.mirego.trikot.kword.DefaultI18N#t(com.mirego.trikot.kword.KWordKey){}kotlin.String + 26 (DefaultI18N.kt:26)
46 Leogali 0x1037e8a98 kfun:com.aaa.Leogali.presentation.onboarding.step.impl.AccountOnboardingStepViewModelImpl#<init>(com.aaa.Leogali.domain.usecases.AccountOnboardingUseCase;com.aaa.Leogali.domain.usecases.DeepLinkUseCase;com.aaa.Leogali.domain.usecases.OnboardingUseCase;com.mirego.trikot.kword.I18N){} + 31 (AccountOnboardingStepViewModelImpl.kt:31)
47 Leogali 0x10376b028 kfun:com.aaa.Leogali.presentation.factories.impl.ViewModelFactoryImpl#<get-accountOnboardingStepViewModel>(){}com.aaa.Leogali.presentation.onboarding.step.AccountOnboardingStepViewModel + 106 (ViewModelFactoryImpl.kt:106)
48 Leogali 0x103ad45f0 objc2kotlin.8016 + 1 (<compiler-generated>:1)
49 iosApp 0x102a657e8 OnboardingAccountStepViewController.loadView() + 4334393320 (<compiler-generated>:4334393320)
50 iosApp 0x102a65bb8 @objc OnboardingAccountStepViewController.loadView() + 4334394296 (<compiler-generated>:4334394296)
51 UIKitCore 0x19dc37ff0 -[UIViewController loadViewIfRequired] + 188
52 UIKitCore 0x19dc386d8 -[UIViewController view] + 32
53 UIKitCore 0x19dc4e68c -[UIViewController _setPresentationController:] + 112
54 UIKitCore 0x19dc471d8 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1348
55 UIKitCore 0x19dc48c00 -[UIViewController _presentViewController:withAnimationController:completion:] + 4212
56 UIKitCore 0x19dc4b2e8 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2 + 72
57 UIKitCore 0x19e769620 +[UIView(Animation) performWithoutAnimation:] + 104
58 UIKitCore 0x19dc4b240 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 224
59 UIKitCore 0x19dc4b720 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 528
60 UIKitCore 0x19dc4b118 -[UIViewController _presentViewController:animated:completion:] + 212
61 UIKitCore 0x19dc4b3ac -[UIViewController presentViewController:animated:completion:] + 176
62 iosApp 0x102a42520 thunk for @escaping @callee_guaranteed () -> () + 4334249248 (<compiler-generated>:4334249248)
63 UIKitCore 0x19db5284c -[UIPresentationController transitionDidFinish:] + 988
64 UIKitCore 0x19db5cafc -[_UICurrentContextPresentationController transitionDidFinish:] + 44
65 UIKitCore 0x19db56ef0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.516 + 212
66 UIKitCore 0x19dc608c0 -[_UIViewControllerTransitionContext completeTransition:] + 112
67 UIKitCore 0x19e2af1f8 _runAfterCACommitDeferredBlocks + 324
68 UIKitCore 0x19e29e774 _cleanUpAfterCAFlushAndRunDeferredBlocks + 236
69 UIKitCore 0x19e2cfee4 _afterCACommitHandler + 80
70 CoreFoundation 0x19a0f811c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
71 CoreFoundation 0x19a0f2e4c __CFRunLoopDoObservers + 420
72 CoreFoundation 0x19a0f32dc __CFRunLoopRun + 1004
73 CoreFoundation 0x19a0f2bc8 CFRunLoopRunSpecific + 480
74 GraphicsServices 0x1a44db5cc GSEventRunModal + 164
75 UIKitCore 0x19e2a5744 UIApplicationMain + 1936
76 iosApp 0x1029f23b0 main + 16 (AppDelegate.swift:16)
77 libdyld.dylib 0x199f6f384 start + 4
Martin Gagnon
09/29/2020, 1:36 PMsvyatoslav.scherbina
09/29/2020, 1:40 PMMartin Gagnon
09/29/2020, 1:57 PMsvyatoslav.scherbina
09/29/2020, 2:21 PM