John O'Reilly
09/29/2020, 8:00 PMrusshwolf
09/29/2020, 8:39 PM1.3.9-native-mt
instead of 1.3.9-native-mt-2
John O'Reilly
09/29/2020, 8:40 PMisForce = true
on the kotlinx-coroutines dependencyrusshwolf
09/29/2020, 8:43 PM./gradlew dependencies
anyway and see if there's anything surprisingJohn O'Reilly
09/29/2020, 8:45 PMmt-2
e.g. for sqldelight
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.3.9-native-mt-2
ensureNeverFrozen()
in my project that it's using but then get different crashrusshwolf
09/30/2020, 1:27 PMJohn O'Reilly
09/30/2020, 1:29 PMeopleInSpaceApi@2f31fb8 has failed, first blocker is com.surrus.common.remote.PeopleInSpaceApi
which I guess is point that ktor client request is being madekotlin.native.concurrent.FreezingException: freezing of <no name provided>_1@3b81ce8 has failed, first blocker is com.surrus.common.remote.PeopleInSpaceApi@35c88a8
at 0 PeopleInSpaceSwiftUI 0x000000010d3ceccd kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93
at 1 PeopleInSpaceSwiftUI 0x000000010d3c787b kfun:kotlin.Exception#<init>(kotlin.String?){} + 91
at 2 PeopleInSpaceSwiftUI 0x000000010d3c7acb kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 91
at 3 PeopleInSpaceSwiftUI 0x000000010d3fd8f3 kfun:kotlin.native.concurrent.FreezingException#<init>(kotlin.Any;kotlin.Any){} + 643
at 4 PeopleInSpaceSwiftUI 0x000000010d3fef77 ThrowFreezingException + 231
at 5 PeopleInSpaceSwiftUI 0x000000010d4ee10f FreezeSubgraph + 2815
at 6 PeopleInSpaceSwiftUI 0x000000010d50733b Kotlin_Worker_freezeInternal + 27
at 7 PeopleInSpaceSwiftUI 0x000000010d3fda1e kfun:kotlin.native.concurrent#freeze@0:0(){0§<kotlin.Any?>}0:0 + 62
at 8 PeopleInSpaceSwiftUI 0x000000010d758df2 kfun:io.ktor.util.collections.internal.MapNode.<no name provided>_1.<init>#internal.33 + 338
at 9 PeopleInSpaceSwiftUI 0x000000010d75776d kfun:io.ktor.util.collections.internal.MapNode#<init>(1:0;1:1){} + 701
at 10 PeopleInSpaceSwiftUI 0x000000010d748461 kfun:io.ktor.util.collections.ConcurrentMap.put$lambda-3#internal + 1137
at 11 PeopleInSpaceSwiftUI 0x000000010d74c935 kfun:io.ktor.util.collections.ConcurrentMap.$put$lambda-3$FUNCTION_REFERENCE$25.invoke#internal + 165
at 12 PeopleInSpaceSwiftUI 0x000000010d7473d7 kfun:io.ktor.util.collections.ConcurrentMap.locked#internal + 439
at 13 PeopleInSpaceSwiftUI 0x000000010d745adb kfun:io.ktor.util.collections.ConcurrentMap#put(1:0;1:1){}1:1? + 379
at 14 PeopleInSpaceSwiftUI 0x000000010d7ce6e1 kfun:io.ktor.client.HttpClientConfig#install(io.ktor.client.features.HttpClientFeature<0:0,0:1>;kotlin.Function1<0:0,kotlin.Unit>){0§<kotlin.Any>;1§<kotlin.Any>} + 1041
at 15 PeopleInSpaceSwiftUI 0x000000010d32ac62 kfun:com.surrus.common.remote.PeopleInSpaceApi.<init>$lambda-4$lambda-3#internal + 386
at 16 PeopleInSpaceSwiftUI 0x000000010d32b59f kfun:com.surrus.common.remote.PeopleInSpaceApi.$<init>$lambda-4$lambda-3$FUNCTION_REFERENCE$16.invoke#internal + 95
at 17 PeopleInSpaceSwiftUI 0x000000010d32b61f kfun:com.surrus.common.remote.PeopleInSpaceApi.$<init>$lambda-4$lambda-3$FUNCTION_REFERENCE$16.$<bridge-UNNN>invoke(-1:0){}#internal + 95
at 18 PeopleInSpaceSwiftUI 0x000000010d7c8013 kfun:io.ktor.client#HttpClient(io.ktor.client.engine.HttpClientEngineFactory<0:0>;kotlin.Function1<io.ktor.client.HttpClientConfig<0:0>,kotlin.Unit>){0§<io.ktor.client.engine.HttpClientEngineConfig>}io.ktor.client.HttpClient + 595
at 19 PeopleInSpaceSwiftUI 0x000000010d81ae1e kfun:io.ktor.client#HttpClient(kotlin.Function1<io.ktor.client.HttpClientConfig<*>,kotlin.Unit>){}io.ktor.client.HttpClient + 638
at 20 PeopleInSpaceSwiftUI 0x000000010d32ae7f kfun:com.surrus.common.remote.PeopleInSpaceApi.<init>$lambda-4#internal + 223
at 21 PeopleInSpaceSwiftUI 0x000000010d32b15d kfun:com.surrus.common.remote.PeopleInSpaceApi.$<init>$lambda-4$FUNCTION_REFERENCE$13.invoke#internal + 157
at 22 PeopleInSpaceSwiftUI 0x000000010d3ffe15 kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.getOrInit#internal + 1045
at 23 PeopleInSpaceSwiftUI 0x000000010d4005ae kfun:kotlin.native.concurrent.FreezeAwareLazyImpl#<get-value>(){}1:0 + 670
at 24 PeopleInSpaceSwiftUI 0x000000010d3254a3 kfun:com.surrus.common.remote.PeopleInSpaceApi.<get-client>#internal + 323
at 25 PeopleInSpaceSwiftUI 0x000000010d3261d7 kfun:com.surrus.common.remote.PeopleInSpaceApi.$fetchPeopleCOROUTINE$0#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any? + 2983
at 26 PeopleInSpaceSwiftUI 0x000000010d327d94 kfun:com.surrus.common.remote.PeopleInSpaceApi#fetchPeople(){}com.surrus.common.remote.AstroResult + 244
at 27 PeopleInSpaceSwiftUI 0x000000010d32e186 kfun:com.surrus.common.repository.PeopleInSpaceRepository.$fetchPeople$lambda-1COROUTINE$5.invokeSuspend#internal + 726
at 28 PeopleInSpaceSwiftUI 0x000000010d3f07f6 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 758
at 29 PeopleInSpaceSwiftUI 0x000000010d5bba52 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2802
louiscad
09/30/2020, 1:58 PMribesg
09/30/2020, 1:59 PMJohn O'Reilly
09/30/2020, 2:00 PMInvalidMutabilityException
) (with "Frozen during lazy computation" message)public actual fun <T> lazy(initializer: () -> T): Lazy<T> = FreezeAwareLazyImpl(initializer)
private val client by lazy {
HttpClient() {
InstanceCreationException: Could not create instance for [Single:'com.surrus.common.remote.PeopleInSpaceApi
) seems in turn to be related to another
InvalidMutabilityException: mutation attempt of frozen com.surrus.common.remote.PeopleInSpaceApi@
russhwolf
09/30/2020, 3:45 PMJohn O'Reilly
09/30/2020, 3:46 PMHttpClient
to not use by lazy
(but again KaMPKit is also doing that so not sure yet what difference is)by lazy
means that the HttpClient
instance is being created when PeopleInSpaceApi
is created ....triggering mutation attempt of frozen com.surrus.common.remote.PeopleInSpaceApi
breedModel = BreedModel()
in NativeViewModel
....and BreedModel
then uses Koin to inject dependencies (like KtorApi
)Ktor
issue 🙂 )russhwolf
09/30/2020, 4:41 PMJohn O'Reilly
09/30/2020, 5:39 PMlouiscad
09/30/2020, 5:40 PMJohn O'Reilly
09/30/2020, 5:40 PMHttpClient
for 1.4.1 release https://github.com/ktorio/ktor/commit/3471ee7e00a0fdf09375d9d16617d5540cc02a9a#diff-cac393be67723a02e3a8cc96c0f298a5nrobi
11/07/2020, 8:51 PMJohn O'Reilly
11/07/2020, 8:52 PMribesg
11/08/2020, 4:18 PMnrobi
11/08/2020, 4:53 PMIncorrectDereferenceException: illegal attempt to access non-shared object from other thread
, which makes sense and was fixed by explicitly freezing the KtorApi
Then I was hitting InvalidMutabilityException
, converted the KtorApi
to an object and made it @ThreadLocal
, but the InvalidMutabilityException
still occured.
• The IncorrectDereferenceException should be fixed by: https://github.com/ktorio/ktor/pull/2092, with the new release
• I still don’t quite get, why KtorApi
needs to be explicitly frozen, if it’s an object
• If I’m correct even if @ThreadLocal
introduces side-effects/new issues, it should’ve fixed InvalidMutabilityException
ribesg
11/09/2020, 11:29 AM