【问题描述】

线上收到大量手机的崩溃异常,以华为手机为主,崩溃如下

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...的更多相关文章

  1. 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 ...

  2. 【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 ], ...

  3. Caused by: java.lang.IllegalStateException: Method has too many Body parameters

    feign多参数问题1.1GET方式错误写法 @RequestMapping(value="/test", method=RequestMethod.GET) Model test ...

  4. Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)

    使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下: Caused by: java.lang.IllegalStateExcepti ...

  5. 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 ...

  6. 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 ...

  7. Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

    java.lang.IllegalStateException: Failed to load ApplicationContext    at org.springframework.test.co ...

  8. Caused by: java.lang.IllegalStateException: duplicate key: datasource

    java.lang.IllegalStateException: Failed to load property source from location 'classpath:/applicatio ...

  9. Caused by: java.lang.IllegalStateException: Ambiguous mapping found

    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...

  10. 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 ...

随机推荐

  1. iOS 深色模式适配

    要求:iOS13.0以上 重点:需要所有界面进行适配,工作量巨大,需要从项目开始就进行适配:H5界面无法进行适配 实现方式:System Colors(常用).Semantic Colors(常用). ...

  2. Rancher 系列文章-Rancher 对接 Active Directory 实战

    概述 只要是个公司,基本上都有邮箱和 AD(Active Directory). 在 AD 里,已经有了: 用户 账号密码 邮箱 用户组 组织架构 所以对于一些仅限于本公司一定范围内人员使用的管理或后 ...

  3. Vue 路由导航守卫

    Vue 路由导航守卫 一:全局守卫 (1) router.beforeEach beforeEach((to, from, next) => {}) 接收三个参数,在路由切换成功之前调用 to ...

  4. python之PySimpleGUI(一)元素

    1themesg.theme_previewer()获取所有主题颜色sg.preview_all_look_and_feel_themes()同上theme_name_list = sg.theme_ ...

  5. ChatGPT 和 Midjourney 初体验

    ChatGPT 和 Midjourney 这两个系统这些天红的发紫,自己也尝试着注册和使用了一下. 一.ChatGPT 我在上周才刚刚注册 OpenAI,注册过程也比较麻烦. 国内的 IP 是无法访问 ...

  6. PyInstaller打包的文件闪退

    问题描述:使用PyInstaller打包的pycharm写的python程序,打包好后从windows上打开一直闪退 一.双击exe文件闪退,从cmd命令行中与加载程序,可以看到具体的报错 D:\di ...

  7. ubuntu容器的远程xface桌面环境搭建

    一.container: ubuntu20.04 二.commands: apt install xfce4 tigervnc-standalone-server  # xface使用gdm3启动器 ...

  8. XSS的攻击

    https://blog.csdn.net/m0_55854679/article/details/123028852

  9. 聊聊Redis sentinel 机制

    Redis 的哨兵机制自动完成了以下三大功能,从而实现了主从库的自动切换,可以降低 Redis 集群的运维开销: 监控主库运行状态,并判断主库是否客观下线: 在主库客观下线后,选取新主库: 选出新主库 ...

  10. 在web浏览器中如何操作复合IC卡

    在web浏览器中如何操作复合IC卡呢, 对于使用javascript的工程师而言,非常简单,只需要几行代码即可实现.当然在写代码之前, 需要安装友我NFC读写器web插件, 然后插上NFC读写器YW- ...