HarmonyOS 鸿蒙Next App main thread is not response

HarmonyOS 鸿蒙Next App main thread is not response

DevEco编写代码,重新Run之后,新的代码没有更新到手机。

环境:
- DevEco Studio 3.1.1 Release
- MacBook Pro Ventura 13.5
- Api 9

Log如下:

Device info:OpenHarmony 3.2 Build info:OpenHarmony 3.2.9.1 Module name:com.xx Version:1.0.0 Pid:20959 Uid:20040005 Reason:THREAD_BLOCK_6S appfreeze: com.xx THREAD_BLOCK_6S at 20240105125803

DOMAIN:AAFWK STRINGID:THREAD_BLOCK_6S TIMESTAMP:2024/01/05-12:58:03:304 PID:20959 UID:20040005 PACKAGE_NAME:com.xx PROCESS_NAME:com.xx MSG:App main thread is not response! EventHandler dump begain curTime:20240105 12:58 PM Event runner (Thread name = , Thread ID = 486153168136) is running Immediate priority event queue information: Total size of Immediate events : 0 High priority event queue information: Total size of High events : 0 Low priority event queue information: No.1 : Event { task name = [idle_time.cpp(OnVSync:74)] } No.2 : Event { id = 1 } No.3 : Event { id = 1 } Total size of Low events : 3 Idle priority event queue information: No.1 : Event { task name = [idle_time.cpp(PostTask:159)] } Total size of Idle events : 1 Total event size : 4


更多关于HarmonyOS 鸿蒙Next App main thread is not response的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

这个问题通过在线提单进一步解决:https://developer.huawei.com/consumer/cn/support/feedback/#/,感谢您的反馈和支持

更多关于HarmonyOS 鸿蒙Next App main thread is not response的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


你好,楼主,知道是什么原因造成的吗?

给你分享下最终解决方法:重启手机!

删除项目新建、重启电脑、换别的电脑等都没用。

在HarmonyOS(鸿蒙)中,如果主线程(UI线程)无响应,通常是由于在主线程中执行了耗时操作,导致UI无法及时更新或响应。鸿蒙系统的主线程负责处理UI更新和事件响应,因此任何阻塞主线程的操作都会导致应用无响应。

要解决这个问题,可以将耗时操作(如网络请求、文件读写、复杂计算等)移到工作线程中执行,避免阻塞主线程。鸿蒙提供了TaskDispatcherEventHandler等机制来管理线程和任务调度。例如,使用TaskDispatcher可以将任务分发到不同的线程池中执行,确保主线程不被阻塞。

此外,可以使用EventHandler在主线程和工作线程之间进行通信,确保UI更新在主线程中执行。通过合理使用这些机制,可以避免主线程无响应的问题,提升应用的性能和用户体验。

回到顶部