一、背景
【前置条件】1.车辆正常上电
【问题现象】1.分屏界面,切换至全景泊车AVM界面,然后切换至车辆设置界面,打开音乐面板,点击副驾音乐面板,中控卡住,过几秒中控出现黑屏
【车机时间】
【软件版本】
【测试人员】
二、分析过程
ANR类型是input ANR,超时时间是5s
11-27 14:42:42.313079 1665 17599 I am_anr : [0,1933,com.android.systemui,952679951,Input dispatching timed out (6ea6054 BottomCarSystemBar (server) is not responding. Waited 5001ms for MotionEvent(deviceId=3, eventTime=1289247516000, source=TOUCHSCREEN, displayId=0, action=DOWN, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, classification=NONE, edgeFlags=0x00000000, xPrecision=1.0, yPrecision=1.0, xCursorPosition=nan, yCursorPosition=nan, pointers=[0: (2446.0, 1427.0)]), policyFlags=0x62000000)]
systemui main thread卡在了renderthread的drawFrame方法
systemui renderthread卡在了waitForFreeSlotThenRelock,在执行dequeueBuffer 超时了。
log如下:
11-27 14:42:40.314331 1933 2304 W OpenGLRenderer: dequeueBuffer failed, error = -110; switching to fallback
11-27 14:42:40.315848 1933 2172 W Looper : Slow dispatch took 4006ms wmshell.main h=android.view.Choreographer F r a m e H a n d l e r c = a n d r o i d . v i e w . C h o r e o g r a p h e r FrameHandler c=android.view.Choreographer FrameHandlerc=android.view.ChoreographerFrameDisplayEventReceiver@69241a5 m=0
error = -110:WOULD_BLOCK: -11, TIMED_OUT = -110根据定义是dequeueBuffer timeout导致的,dequeueBuffer 的timeout时间是4s。
通过不同的场景systrace分析:
-
异常情况下,可以看到dequeuBuffer比较耗时,长达10ms,原因是因为在waiting for GPU
-
正常情况下,dequeuBuffer非常快,500us内能执行完成,waiting for GPU用比较少。
-
通过加log debug
status_t BufferQueueProducer::waitForFreeSlotThenRelock(FreeSlotCaller caller,
std::unique_lock<std::mutex>& lock, int* found) const {
auto callerString = (caller == FreeSlotCaller::Dequeue) ?
"dequeueBuffer" : "attachBuffer";
bool tryAgain = true;
while (tryAgain) {
if (mCore->mIsAbandoned) {