【HarmonyOS】关于 Caused by java.lang.IllegalStateException The specified...
【问题描述】
线上收到大量手机的崩溃异常,以华为手机为主,崩溃如下
1.Caused by: java.lang.IllegalStateException: The specified message queue synchronization barrier token has not been posted or has already been removed.
2.at android.os.MessageQueue.removeSyncBarrier(MessageQueue.java:600)
3.at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2822)
4.at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10653)
5.at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1394)
6.at android.view.Choreographer.doCallbacks(Choreographer.java:1115)
7.at android.view.Choreographer.doFrame(Choreographer.java:1004)
8.at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1362)
9.at android.os.Handler.handleCallback(Handler.java:966)
10.at android.os.Handler.dispatchMessage(Handler.java:110)
11.at android.os.Looper.loopOnce(Looper.java:205)
12.at android.os.Looper.loop(Looper.java:293)
13.at android.app.ActivityThread.main(ActivityThread.java:9596)
14.at java.lang.reflect.Method.invoke(Native Method)
15.at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586)
16.at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1204)
【问题分析】
对于“The specified message queue synchronization barrier token has not been posted or has already been removed.”
该问题主要为多线程绘制UI导致的,UI绘制过程会在MessageQueue中设置synchronization barrier ,结束时释放。其中barrier是Android Handler中的同步屏障,不了解的同学可以看下这篇文章Handler消息机制深入解析| EasyLiu (easyliu-ly.github.io)
【解决方案】
所以这行报错的意思是消息队列中的同步屏障没有被设置或者同步屏障已经被移除,view刷新时一般时是在绘制前插入屏障,绘制后移出屏障,如果多线程同时绘制UI就会导致线程安全问题,MessageQueue中的synchronization barrier 消息可能被另一个线程绘制完成时释放,导致原始线程走到barrier释放流程时,无法找到该消息,最终导致该crash发生。
安卓原生在高版本已经屏蔽了原来在子线程刷新UI会报错的特性,所以发生这种情况需要检查工程中是否有多线程刷新绘制UI的情况,和子线程刷新UI的情况,并非系统问题。
【HarmonyOS】关于 Caused by java.lang.IllegalStateException The specified...的更多相关文章
- Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackO ...
- 【spring boot】【elasticsearch】spring boot整合elasticsearch,启动报错Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8
spring boot整合elasticsearch, 启动报错: Caused by: java.lang.IllegalStateException: availableProcessors ], ...
- Caused by: java.lang.IllegalStateException: Method has too many Body parameters
feign多参数问题1.1GET方式错误写法 @RequestMapping(value="/test", method=RequestMethod.GET) Model test ...
- Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)
使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下: Caused by: java.lang.IllegalStateExcepti ...
- Caused by: java.lang.IllegalStateException: Expected raw type form of org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$Match
spring 4.0.2,mybatis 3.2.6,aspectjweaver 1.8.10 使用的时候,报错: Caused by: java.lang.IllegalStateException ...
- Caused by java.lang.IllegalStateException Not allowed to start service Intent { cmp=com.x.x.x/.x.x.xService }: app is in background uid UidRecord(一)
Caused by java.lang.IllegalStateException Not allowed to start service Intent { cmp=com.x.x.x/.x.x.x ...
- Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.co ...
- Caused by: java.lang.IllegalStateException: duplicate key: datasource
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/applicatio ...
- Caused by: java.lang.IllegalStateException: Ambiguous mapping found
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...
- Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/Cppcc] due to a StackOverflowError. Possible root causes include a too low setting for -Xs
解决办法:(1)修改D:\Java\apache-tomcat-7.0.88\conf\catalina.properties (122line) (2)如org.apache.catalina.st ...
随机推荐
- 搭建react的架手架
1.回顾 cnpm i @vue/cli -g ----- 4的脚手架 ------ webpack 4 cnpm i @vue/cli@3 -g ----- 3的脚手架 ------ webpack ...
- 常用注解-SpringBoot请求
SpringBoot请求 常用注解及作用范围: @Controller :[类]需要返回一个视图(themleaf),加注解4@ResponseBody等于注解2 @RestController:[类 ...
- Redis读书笔记(一)
Redis数据结构 1 简单动态字符串 Simple dynamic string 的实现 // sds.h/sdshdr struct sdshdr { int len; //记录buf数组中已使用 ...
- windows安装telnet命令
1.打开控制面板 2.点击程序和功能 3.点击打开或关闭windows功能 4.等候一分钟左右 5.勾选telnet选项 6.测试telnet 7.如果通的话,弹出telnet窗口,按住"C ...
- 【Spring5】IOC
1 Spring概念 Spring是轻量级的开源JavaEE框架.可以解决企业开发的复杂性. Spring有两个核心部分:IOC和Aop ①IOC控制反转:把创建对象过程交给Spring管理 ②Aop ...
- Active Record Associations
The Types of Associations 在 Rails 中,可以通过 ActiveRecord 来定义不同类型的关联关系(Associations),包括以下几种: belongs_to: ...
- STM32下载ELF文件、最小可执行bin文件测试
1.STM32能下载ELF格式的文件吗? 答:可以.因为所谓的bin文件就是ELF文件的.text代码段. 当然前提是下载工具能识别ELF文件格式,STM32下载ELF文件并不意味着STM32可以把E ...
- Python_11 类的方法
一.查缺补漏 1. 实例方法必须用类实例化对象()来调用,用类来调用时会执行,但是self中不是实例化类地址而是传的字符串 二.类中的方法 1. 实例方法 1. 定义在类里面的普通方法(函数) 2. ...
- Android JAVA连接MQTT,以及常见问题
本文介绍如何使用Android(JAVA)客户机连接MQTT服务器 第一步先引入MQTT 在 build.gradle 添加以下: dependencies { implementation 'org ...
- 深度学习03-(图像梯度处理、图像轮廓、图像预处理在AI中的应用)
深度学习03-计算机视觉基本理论2 深度学习03-(计算机视觉基本理论2) 图像梯度处理 什么是图像梯度 模板运算 均值滤波 高斯滤波 中值滤波 边沿检测 锐化 图像轮廓 什么是图像轮廓 查找和绘制轮 ...