HarmonyOS 鸿蒙Next NAPI调用napi_create_async_work创建的异步任务BlurExecuteCB,执行报function occupies worker for more than [1]s错误
HarmonyOS 鸿蒙Next NAPI调用napi_create_async_work创建的异步任务BlurExecuteCB,执行报function occupies worker for more than [1]s错误
17:03:30.292 29076 29466 I C03F00/MUSL: =================================================================
17:03:30.292 29076 29466 I C03F00/MUSL: appspawn29076==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x007c4bacde38 at pc 0x007c4881e25c bp 0x007c45fd91d0 sp 0x007c45fd91c8
17:03:30.292 29076 29466 I C03F00/MUSL: READ of size 16 at 0x007c4bacde38 thread T27
17:03:30.301 29076 29174 W C01719/appspawn/ffrt: 161:RecordSymbolAndBacktrace:221 Tid[29466] function occupies worker for more than [1]s.
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: 162:RecordSymbolAndBacktrace:226 Backtrace:
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: Tid:29466, Name:OS_FFRT_2_2
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #00 pc 0000000000054848 /system/asan/lib64/libclang_rt.asan.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #01 pc 000000000005cb20 /system/asan/lib64/libclang_rt.asan.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #02 pc 00000000000d95b8 /system/asan/lib64/libclang_rt.asan.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #03 pc 000000000005e25c /data/storage/el1/bundle/libs/arm64/libentry.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #04 pc 00000000000604a4 /data/storage/el1/bundle/libs/arm64/libentry.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #05 pc 000000000004e438 /data/storage/el1/bundle/libs/arm64/libentry.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #06 pc 00000000000e1df0 /system/asan/lib64/platformsdk/libace_napi.z.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #07 pc 000000000001fac4 /system/asan/lib64/platformsdk/libuv.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #08 pc 00000000000c4170 /system/asan/lib64/ndk/libffrt.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #09 pc 00000000000c598c /system/asan/lib64/ndk/libffrt.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #10 pc 00000000000c64b4 /system/asan/lib64/ndk/libffrt.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #11 pc 00000000000c50dc /system/asan/lib64/ndk/libffrt.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #12 pc 00000000000c4e40 /system/asan/lib64/ndk/libffrt.so
17:03:30.307 29076 29174 W C01719/appspawn/ffrt: #13 pc 000000000010ee20 /lib/ld-musl-aarch64-asan.so.1
代码之前是可以正常运行的,最近切到Openharmony-5.0.0上执行报以上错误并出现闪退。
更多关于HarmonyOS 鸿蒙Next NAPI调用napi_create_async_work创建的异步任务BlurExecuteCB,执行报function occupies worker for more than [1]s错误的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
针对帖子标题中提到的HarmonyOS鸿蒙Next NAPI调用napi_create_async_work
创建的异步任务BlurExecuteCB
,执行报错“function occupies worker for more than [1]s”的问题,这通常意味着异步任务在指定的worker线程中执行时间超过了系统允许的最大阈值(本例中为1秒)。
在鸿蒙系统中,NAPI(Native Abstraction Interface)的异步工作项(async work)设计用于在后台线程执行耗时操作,以避免阻塞主线程。当某个异步任务执行时间过长时,系统会抛出超时错误,以防止worker线程被单个任务长时间占用,影响系统整体性能。
解决此问题的方法通常包括:
- 优化
BlurExecuteCB
函数的执行逻辑,减少其运行时间。 - 如果任务确实需要较长时间完成,考虑将其拆分为多个小任务,或者调整系统对异步工作项的超时限制(但这通常不推荐,除非有充分理由)。
请检查并调整BlurExecuteCB
函数的实现,确保其能在合理时间内完成。如果任务涉及复杂计算或I/O操作,考虑使用更高效的算法或异步I/O方式。
如果问题依旧没法解决请联系官网客服,官网地址是 https://www.itying.com/category-93-b0.html,