- Notifications
You must be signed in to change notification settings - Fork 48
Description
Hello!
We started using multik in production for matrix .dot and .inv methods.
It's working smoothly for some Android users, but we noticed lots of crashes happening in production for others:
Caused by java.lang.IllegalStateException: Fail to find engine. Consider to add one of the following dependencies: - multik-default - multik-kotlin - multik-openblas at org.jetbrains.kotlinx.multik.api.EngineKt.enginesProvider(Engine.kt:13) at org.jetbrains.kotlinx.multik.api.Engine.<clinit>(Engine.kt:68) at org.jetbrains.kotlinx.multik.api.Multik.getLinalg(Multik.kt:49) at org.jetbrains.kotlinx.multik.api.linalg._linalgKt.dotDefMMNumber(_linalg.kt:21) ... We're simply using these two dependencies in our KMM module, which we then include as JAR in our Android project:
commonMain { dependencies { implementation("org.jetbrains.kotlinx:multik-core:0.2.0") implementation("org.jetbrains.kotlinx:multik-kotlin:0.2.0") } }The line in multik where the service is loaded is this one:
https://github.com/Kotlin/multik/blob/master/multik-core/src/jvmMain/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt#L9
This is calling ServiceLoader.load(Engine::class.java).toList(), which uses The Java ServiceLoader.
The class that should be loaded here is KEEngine, which is referenced in the META-INF/services folder here:
https://github.com/Kotlin/multik/blob/master/multik-kotlin/src/jvmMain/resources/META-INF/services/org.jetbrains.kotlinx.multik.api.Engine
What's weird about this is that it either should or should not work. But for our affected users, the app crashes one time - and after that it seems to work fine. At first I thought that the class is optimized away by R8 - but that wouldn't explain why it works some of the times.
Does anyone else have this issue?