Lucas Schiavini

    Lucas Schiavini

    5 months ago
    Anyone had problems using kotlin classes on a thread in swift, and having errors like : Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@27c0f38 from other thread And after trying to annotate the class with either SharedImmutable or ThreadLocal getting -> @ThreadLocal is applicable only to property with backing field, to property with delegation or to objects
    https://github.com/lschiavini/KmmKlibError check the concurrent branch to generate the problem
    kpgalligan

    kpgalligan

    5 months ago
    You need to freeze the class before passing it around threads outside of Kotlin.
    Lucas Schiavini

    Lucas Schiavini

    5 months ago
    As in calling freeze() directly on Kotlin?
    p

    pguardiola

    5 months ago
    You can also use coroutines and the new memory model and forget about freezing objects manually