Kotlin/native FreezingException cased by ScopeDefinition
See original GitHub issueDescribe the bug Starting koin from iOS app throws an exception
Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: kotlin.native.concurrent.FreezingException: freezing of com.example.freezingexceptionsample.shared.GreetModule@17a4188 has failed, first blocker is org.koin.core.scope.ScopeDefinition@cea8c1fa
at 0 shared 0x000000010f3960ff kfun:kotlin.Throwable#<init>(kotlin.String?){} + 95 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
at 1 shared 0x000000010f39008d kfun:kotlin.Exception#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 shared 0x000000010f39026d kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 shared 0x000000010f3b7755 kfun:kotlin.native.concurrent.FreezingException#<init>(kotlin.Any;kotlin.Any){} + 645 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:15:9)
at 4 shared 0x000000010f3b79f9 ThrowFreezingException + 233 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:87:15)
at 5 shared 0x000000010f412810 FreezeSubgraph + 4912
at 6 shared 0x000000010f410fa1 InitSharedInstanceStrict + 417
at 7 shared 0x000000010f3479f2 kfun:com.example.freezingexceptionsample.shared.initKoin$lambda-1#internal + 450 (/Users/bmukhutdinov/StudioProjects/FreezingExceptionSample/shared/src/commonMain/kotlin/com/example/freezingexceptionsample/shared/Koin.kt:10:9)
at 8 shared 0x000000010f347b71 kfun:com.example.freezingexceptionsample.shared.$initKoin$lambda-1$FUNCTION_REFERENCE$2.invoke#internal + 97 (/Users/bmukhutdinov/StudioProjects/FreezingExceptionSample/shared/src/commonMain/kotlin/com/example/freezingexceptionsample/shared/Koin.kt:6:67)
at 9 shared 0x000000010f347bf1 kfun:com.example.freezingexceptionsample.shared.$initKoin$lambda-1$FUNCTION_REFERENCE$2.$<bridge-UNNN>invoke(-1:0){}#internal + 97 (/Users/bmukhutdinov/StudioProjects/FreezingExceptionSample/shared/src/commonMain/kotlin/com/example/freezingexceptionsample/shared/Koin.kt:6:67)
at 10 shared 0x000000010f431a6c kfun:org.koin.core.context#startKoin(org.koin.core.context.KoinContext;kotlin.Function1<org.koin.core.KoinApplication,kotlin.Unit>){}org.koin.core.KoinApplication + 620 (/Users/a.giuliani/workspace/koin_3.0.0/koin-projects/koin-core/src/commonMain/kotlin/org/koin/core/context/ContextFunctions.kt:39:5)
at 11 shared 0x000000010f431d3d kfun:org.koin.core.context#startKoin$default(org.koin.core.context.KoinContext?;kotlin.Function1<org.koin.core.KoinApplication,kotlin.Unit>;kotlin.Int){}org.koin.core.KoinApplication + 365 (/Users/a.giuliani/workspace/koin_3.0.0/koin-projects/koin-core/src/commonMain/kotlin/org/koin/core/context/ContextFunctions.kt:35:1)
at 12 shared 0x000000010f3477aa kfun:com.example.freezingexceptionsample.shared#initKoin(kotlin.Function1<org.koin.core.KoinApplication,kotlin.Unit>){}org.koin.core.KoinApplication + 234 (/Users/bmukhutdinov/StudioProjects/FreezingExceptionSample/shared/src/commonMain/kotlin/com/example/freezingexceptionsample/shared/Koin.kt:6:57)
at 13 shared 0x000000010f3644b8 objc2kotlin.323 + 216 (/<compiler-generated>:1:0)
at 14 iosApp 0x000000010f0c1f83 $s6iosApp0B8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 211
at 15 UIKitCore 0x00007fff2468d0f1 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232
at 16 UIKitCore 0x00007fff2468ec73 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3919
at 17 UIKitCore 0x00007fff24694681 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1237
at 18 UIKitCore 0x00007fff23cbd940 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 179
at 19 UIKitCore 0x00007fff24690a6e -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59
at 20 UIKitCore 0x00007fff24690dfd -[UIApplication _run] + 898
at 21 UIKitCore 0x00007fff24695cbc UIApplicationMain + 101
at 22 iosApp 0x000000010f0c265b main + 75 (/Users/bmukhutdinov/StudioProjects/FreezingExceptionSample/iosApp/iosApp/AppDelegate.swift:<unknown>)
at 23 libdyld.dylib 0x00007fff202593e9 start + 1
at 24 ??? 0x0000000000000001 0x0 + 1
CoreSimulator 732.18.6 - Device: iPhone 12 (8D6421A4-31C3-4873-B376-6390A153FA8A) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 12
To Reproduce I created the sample project showing the exception https://github.com/BulatMukhutdinov/FreezingExceptionSample
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
FreezingException with Koin in Korlin/Native - Stack Overflow
Uncaught Kotlin exception: kotlin.native.concurrent.FreezingException: freezing of savrov.sdk.store.client.feature.product.di.
Read more >FreezingException - Kotlin Programming Language
Exception thrown whenever freezing is not possible. Parameters. toFreeze - an object intended to be frozen. blocker - an object preventing freezing, ...
Read more >Kotlin Native Stranger Threads. Episode 2 — Two Rules
As far as the KN runtime is concerned, all non-frozen state is possibly mutable, and restricted to one thread. Freeze. Freeze is a...
Read more >kotlin.native.concurrent.InvalidMutabilityException - YouTrack
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen <object>@72c18 · (1) file blob without (3) upload progress: does not work · (1) ...
Read more >Spring Native documentation
3. Build the native application. The native application can be built as follows: Maven. Gradle Groovy. Gradle Kotlin.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If anyone’s wondering, this happens because
objects
are frozen by default.Slightly tangential from this issue, but you should also make sure that koin dependencies are always resolved on the main thread (or the thread on which the graph was created). Accessing dependencies from a different thread will cause the graph to freeze.
Good