InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
9.08k stars 719 forks source link

Maximum call stack size exceeded in compose multiplatform application #2041

Open Tooto opened 2 weeks ago

Tooto commented 2 weeks ago

Describe the bug I have crash only in wasm part of project. Same code works well on android and desktop. Log: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at <AppKardaz:composeApp>.kotlin.CharArray.<init> (http://localhost:8080/composeApp.wasm:wasm-function[11100]:0x2c6d40) at <AppKardaz:composeApp>.kotlin.collections.copyOfUninitializedElements (http://localhost:8080/composeApp.wasm:wasm-function[15715]:0x2e4b69) at <AppKardaz:composeApp>.kotlin.collections.copyOfUninitializedElements (http://localhost:8080/composeApp.wasm:wasm-function[15714]:0x2e4b08) at <AppKardaz:composeApp>.kotlin.collections.copyOf (http://localhost:8080/composeApp.wasm:wasm-function[15713]:0x2e4afb) at <AppKardaz:composeApp>.kotlin.text.StringBuilder.ensureCapacityInternal (http://localhost:8080/composeApp.wasm:wasm-function[6370]:0x288c7d) at <AppKardaz:composeApp>.kotlin.text.StringBuilder.ensureExtraCapacity (http://localhost:8080/composeApp.wasm:wasm-function[6369]:0x288c36) at <AppKardaz:composeApp>.kotlin.text.StringBuilder.append (http://localhost:8080/composeApp.wasm:wasm-function[6335]:0x2880fc) at <AppKardaz:composeApp>.org.koin.core.definition.BeanDefinition.toString (http://localhost:8080/composeApp.wasm:wasm-function[52006]:0x619ecb) at <AppKardaz:composeApp>.kotlin.toString (http://localhost:8080/composeApp.wasm:wasm-function[11244]:0x2c83f4) at <AppKardaz:composeApp>.kotlin.text.StringBuilder.append (http://localhost:8080/composeApp.wasm:wasm-function[6326]:0x287fe5)

To Reproduce I have this code:

fun appModule() = module {
    single<ProjectRepository> { DefaultProjectRepository() }
    single<SignInComponent.Factory> {
        DefaultSignInComponent.Factory()
    }
    single<RootComponent.Factory> {
        DefaultRootComponent.Factory(
            signInComponentFactory = get(),
        )
    }
}

And its crashed only in wasm part. When i change signInComponentFactory = get(), to signInComponentFactory = DefaultSignInComponent, everething works well.

Code of DefaultSignInComponent:

class DefaultSignInComponent(
    componentContext: ComponentContext,
    private val onShowProjects: () -> Unit,
) : SignInComponent, ComponentContext by componentContext {
    override fun onShowProjectsClicked() {
        onShowProjects()
    }
    class Factory(
    ) : SignInComponent.Factory {
        override fun invoke(
            componentContext: ComponentContext,
            onShowProjects: () -> Unit
        ): SignInComponent {
            return DefaultSignInComponent(
                componentContext = componentContext,
                onShowProjects = onShowProjects
            )
        }
    }
}

Koin module and version: koin-core:4.0.0 koin-compose:4.0.0 (but without koin compose everything is the same)

arnaudgiuliani commented 3 days ago

I don't see link to Koin library here 🤔 Do you have more details on stack trace?