gpt4 book ai didi

ios - 卡住函数时 kotlin-native freeze() 方法崩溃

转载 作者:行者123 更新时间:2023-11-28 23:26:53 25 4
gpt4 key购买 nike

我正在尝试卡住一个函数以便能够传递给工作人员。在与函数相同的类中,我有一个标有 ensureNeverFrozen 的变量。我试图卡住的函数中没有使用该变量,事实上,该函数没有执行任何操作。

不过,当我尝试卡住该函数时,我收到以下错误

最小崩溃重现 code -

Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren't propagated from Kotlin to Objective-C/Swift.
Other exceptions can be propagated as NSError if method has or inherits @Throws annotation.
Uncaught Kotlin exception: kotlin.native.concurrent.FreezingException: freezing of function performWork (Kotlin reflection is not available) has failed, first blocker is []
at 0 lib 0x0000000102502a45 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85
at 1 lib 0x0000000102502125 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85
at 2 lib 0x00000001025265c1 kfun:kotlin.native.concurrent.FreezingException.<init>(kotlin.Any;kotlin.Any)kotlin.native.concurrent.FreezingException + 641
at 3 lib 0x0000000102526a2e ThrowFreezingException + 222
at 4 lib 0x0000000102575833 FreezeSubgraph + 2611
at 5 lib 0x000000010258bcfb Kotlin_Worker_freezeInternal + 27
at 6 lib 0x000000010252673b kfun:kotlin.native.concurrent.freeze@#GENERIC.()Generic + 59
at 7 lib 0x000000010253e310 kfun:com.prateekgrover.lib.KNDispatchQueue.performWorkAsync() + 208
at 8 lib 0x000000010253de1a kfun:com.prateekgrover.lib.Greeting.start() + 186
at 9 lib 0x000000010254168d blockCopyHelper + 573
at 10 ios_kn_sample 0x000000010215471d $sIeg_IeyB_TR + 45 (/Users/prateek.grover/Documents/code/KotlinNative/KotlinNativeSample/core_lib_dup/ios_kn_sample/<compiler-generated>:<unknown>)
at 11 libdispatch.dylib 0x0000000104156d7f _dispatch_call_block_and_release + 12
at 12 libdispatch.dylib 0x0000000104157db5 _dispatch_client_callout + 8
at 13 libdispatch.dylib 0x000000010415a7b9 _dispatch_queue_override_invoke + 1022
at 14 libdispatch.dylib 0x0000000104168632 _dispatch_root_queue_drain + 351
at 15 libdispatch.dylib 0x0000000104168fca _dispatch_worker_thread2 + 130
at 16 libsystem_pthread.dylib 0x00000001045406b3 _pthread_wqthread + 583
at 17 libsystem_pthread.dylib 0x00000001045403fd start_wqthread + 13

对上述行为有什么解释吗?

最佳答案

我猜你指的是这个

actual class KNDispatchQueue {
@ThreadLocal
actual companion object Singleton {
actual val sharedInstance: KNDispatchQueue = KNDispatchQueue()
}

private var workQueue: MutableList<KNWork> = mutableListOf()

init {
workQueue.ensureNeverFrozen()
}

actual fun performWorkAsync() {
::performWork.freeze()
}

fun performWork() {

}
}

函数是类的一部分。假设它试图卡住自身的那个实例,它也会卡住图形的其余部分。我注释掉了 ensureNeverFrozen 并且它卡住了。

您的语法 ::performWork 指向实例引用。

https://kotlinlang.org/docs/reference/reflection.html#bound-function-and-property-references-since-11

关于ios - 卡住函数时 kotlin-native freeze() 方法崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58389350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com