Comments (7)
I don't think this is fixed yet. I am running into InvalidMutabilityException
error when running my project on kotlin/native (macOS):
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.collections.HashMap@3ce1088
at 0 Teleport 0x0000000105a40c6c kfun:kotlin.Throwable#<init>(kotlin.String?){} + 96
at 1 Teleport 0x0000000105a39aa4 kfun:kotlin.Exception#<init>(kotlin.String?){} + 92
at 2 Teleport 0x0000000105a39cd8 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 92
at 3 Teleport 0x0000000105a6de40 kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 92
at 4 Teleport 0x0000000105a6f254 ThrowInvalidMutabilityException + 336
at 5 Teleport 0x0000000105c09334 MutationCheck + 156
at 6 Teleport 0x0000000105a52568 kfun:kotlin.collections.HashMap.<set-length>#internal + 96
at 7 Teleport 0x0000000105a56920 kfun:kotlin.collections.HashMap#addKey(1:0){}kotlin.Int + 1048
at 8 Teleport 0x0000000105a535e8 kfun:kotlin.collections.HashMap#put(1:0;1:1){}1:1? + 236
at 9 Teleport 0x00000001060b9ebc kfun:me.tatarka.inject.internal.LazyMap#get(kotlin.String;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1008
at 10 Teleport 0x00000001057d31f4 kfun:me.saket.teleport.di.InjectAppComponent#<get-strings>(){}me.saket.teleport.localization.AppStrings + 232
at 11 Teleport 0x00000001057d3768 kfun:me.saket.teleport.di.InjectAppComponent#<get-notificationDispatcher>(){}me.saket.teleport.pairing.NotificationDispatcher + 200
at 12 Teleport 0x00000001057f7a30 kfun:me.saket.teleport.di.AppComponent#startLongRunningStuff(){} + 400
at 13 Teleport 0x00000001057f8680 kfun:me.saket.teleport.di.AppComponent.Companion#create(me.saket.teleport.di.PlatformDependencies){}me.saket.teleport.di.AppComponent + 212
at 14 Teleport 0x00000001059015e0 objc2kotlin.2825 + 188
at 15 Teleport 0x0000000104b0844c $s8Teleport0A3AppC30applicationWillFinishLaunchingyy10Foundation12NotificationVF + 448 (/Users/saket/projects/teleport/macOS/Teleport/Teleport/TeleportApp.swift:16:47)
at 16 Teleport 0x0000000104b08840 $s8Teleport0A3AppC30applicationWillFinishLaunchingyy10Foundation12NotificationVFTo + 136
at 17 CoreFoundation 0x00000001821f5f08 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
at 18 CoreFoundation 0x0000000182297e5c ___CFXRegistrationPost_block_invoke + 52
at 19 CoreFoundation 0x0000000182297dc8 _CFXRegistrationPost + 456
at 20 CoreFoundation 0x00000001821c49d8 _CFXNotificationPost + 720
at 21 Foundation 0x0000000182f503c0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
at 22 AppKit 0x00000001849e2128 -[NSApplication finishLaunching] + 364
at 23 AppKit 0x00000001849e1d1c -[NSApplication run] + 292
at 24 AppKit 0x00000001849b3878 NSApplicationMain + 1064
at 25 Teleport 0x0000000104b091a8 main + 12 (/Users/saket/projects/teleport/macOS/Teleport/Teleport/TeleportApp.swift:<unknown>)
at 26 libdyld.dylib 0x0000000182121430 start + 4
from kotlin-inject.
You try with
kotlin.native.binary.memoryModel=experimental
? See https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md
from kotlin-inject.
I'm still using Kotlin 1.5.31 so can't do that yet
from kotlin-inject.
Yeah ended up going with a simple mutex to keep it in line with the jvm version. This does mean it doesn't work on the older memory model. 1.6.0 is out now so hopefully pieces will fall in place to be able to update soon. In the meantime you may be able to use https://github.com/touchlab/Stately#stately-isolate to confine access to a single thread.
from kotlin-inject.
Ohey I was able to use Kotlin 1.6.0 without k/n complaining about ABI incompatibility. I'm still running into the same exception even with kotlin.native.binary.memoryModel=experimental
:
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.collections.HashMap@5563bcf0
at 0 Teleport 0x0000000102e8f9d8 kfun:kotlin.Throwable#<init>(kotlin.String?){} + 96
at 1 Teleport 0x0000000102e87f4c kfun:kotlin.Exception#<init>(kotlin.String?){} + 92
at 2 Teleport 0x0000000102e881a0 kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 92
at 3 Teleport 0x0000000102ebcc94 kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 92
at 4 Teleport 0x0000000102ebdfa0 ThrowInvalidMutabilityException + 340
at 5 Teleport 0x00000001037d4b8c MutationCheck + 100
at 6 Teleport 0x0000000102ea1108 kfun:kotlin.collections.HashMap.<set-length>#internal + 92
at 7 Teleport 0x0000000102ea55fc kfun:kotlin.collections.HashMap#addKey(1:0){}kotlin.Int + 1092
at 8 Teleport 0x0000000102ea21d8 kfun:kotlin.collections.HashMap#put(1:0;1:1){}1:1? + 220
at 9 Teleport 0x0000000103443ba8 kfun:me.tatarka.inject.internal.LazyMap#get(kotlin.String;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1060
at 10 Teleport 0x000000010350a554 kfun:me.saket.teleport.di.InjectAppComponent#<get-strings>(){}me.saket.teleport.localization.AppStrings + 232
at 11 Teleport 0x000000010350aae4 kfun:me.saket.teleport.di.InjectAppComponent#<get-notificationDispatcher>(){}me.saket.teleport.pairing.NotificationDispatcher + 200
at 12 Teleport 0x0000000103530274 kfun:me.saket.teleport.di.AppComponent#startLongRunningStuff(){} + 400
at 13 Teleport 0x0000000103530f6c kfun:me.saket.teleport.di.AppComponent.Companion#create(me.saket.teleport.di.PlatformDependencies){}me.saket.teleport.di.AppComponent + 212
at 14 Teleport 0x00000001036920ec objc2kotlin.6497 + 196
at 15 Teleport 0x000000010215438c $s8Teleport0A3AppC30applicationWillFinishLaunchingyy10Foundation12NotificationVF + 448 (/Users/saket/projects/teleport/macOS/Teleport/Teleport/TeleportApp.swift:16:47)
at 16 Teleport 0x0000000102154780 $s8Teleport0A3AppC30applicationWillFinishLaunchingyy10Foundation12NotificationVFTo + 136
at 17 CoreFoundation 0x00000001821f5f08 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
at 18 CoreFoundation 0x0000000182297e5c ___CFXRegistrationPost_block_invoke + 52
at 19 CoreFoundation 0x0000000182297dc8 _CFXRegistrationPost + 456
at 20 CoreFoundation 0x00000001821c49d8 _CFXNotificationPost + 720
at 21 Foundation 0x0000000182f503c0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
at 22 AppKit 0x00000001849e2128 -[NSApplication finishLaunching] + 364
at 23 AppKit 0x00000001849e1d1c -[NSApplication run] + 292
at 24 AppKit 0x00000001849b3878 NSApplicationMain + 1064
at 25 Teleport 0x00000001021550e8 main + 12 (/Users/saket/projects/teleport/macOS/Teleport/Teleport/TeleportApp.swift:<unknown>)
at 26 libdyld.dylib 0x0000000182121430 start + 4
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
1.6.0 is out now so hopefully pieces will fall in place to be able to update soon.
I'm surprised k/native isn't complaining about ABI incompatibility yet, but in general updating kotlin version is a giant PITA in kotlin multiplatform because some libraries can take months to update. Additionally, the new memory model isn't stable yet either so it's difficult to expect companies to start using it right away. Can I convince you to support the older memory model? I imagine you can simply drop-in stately with trivial effort.
from kotlin-inject.
My understanding is stately works by confining access to a single thread. I'm curious what benefits that would have in the impl vs using
val component = IsolateState { AppComponent::class.create() }
client-side?
You must dispose of IsolateState instances to avoid memory leaks.
fun usage(){
val cacheMap = IsolateState { mutableMapOf<String, String>() }
cacheMap.dispose()
}
this is something I really would not like to have to expose, and would be better for the client to handle imo.
from kotlin-inject.
Unfortunately my understanding about the underlying state of iso-collections is limited too. FWIW I tried accessing my app's component through IsolateState
but it hangs forever. I'm not sure why and I didn't spend any time investigating.
Given that the lifecycle of my app's component
is tied with the app, I can safely choose to not worry about disposing any IsolateState
. I'll go ahead and maintain a fork of kotlin-inject
in the meantime to use IsoMutableMap
until kotlin's new memory model is usable and compatible with other necessary libraries.
from kotlin-inject.
Related Issues (20)
- Improve documentation to better understand how to use kotlin-inject HOT 4
- Conflicting overloads error when upgrading another library to use KSP 2.0.0 HOT 5
- Can't inject provided dependency into java class HOT 5
- There seem to be no way to define bindings in a separate file (like module for dagger) HOT 2
- Generated code tries to use property or variable that isn't there HOT 1
- Incremental compilation sometimes fails with exception HOT 2
- In some cases scope doesn't apply to provided dependency HOT 1
- Is nesting @Assisted possible? HOT 1
- Support qualifieres in multibinds map keys and set elements. HOT 2
- Resolving type arguments may throw an exception for star projections
- Annotation support for exposing a supertype to the graph HOT 6
- Implementation for scoped components HOT 7
- Critical obfuscation issue. HOT 8
- How to create ViewModel in Jetpack Compose? HOT 2
- How to inject WorkManager? HOT 3
- Checking for cyclic dependencies HOT 1
- KmpComponentCreate not generated for IosSimulatorArm64 HOT 5
- Different behavior between extension property and function when providing a scoped class using `@Qualifier` annotations
- The order of dependencies with `@Qualifier` annotation modifies the scope of the dependency.
- Build fails when declaring two `Lazy` dependencies.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-inject.