一、无锁状态下,灭屏后亮屏设置界面滑动无效。
问题分析:
(1)可在其他应用界面复现,非应用问题。
(2)问题必现,点击动作有效但无动画效果,滑动后界面不刷新但可确认对应位置在后台已发生变化,非输入系统错误。
(3)滑动后界面没有刷新,截图后与当前设备显示相同,排除显示系统的硬件问题,为显示系统的软件问题。
问题排查:
(1)根据绘制流程添加log分析。performTraversals(performMeasure,performlayout,performDraw),此处没有问题。
(2)分析performDraw流程添加log分析。performDraw(VIEwTreeObserver.draw()/drawSoftware),发现performDraw正常运行,VIEwTreeObserver.draw()在出现问题后不再调用。
(3)根据(2),继续追查问题发现VIEwRootImpl.draw()中[surface.isValID()=true],进而追踪surface无效的原因。
(4)根据代码发现每次灭屏后会调用VIEwRootImpl.setwindowstopped(true)进而都会mSurface.release()。
(5)亮屏由于没有锁屏界面,灭屏时的界面没有发生任何变化且非第一绘制,不会重新使能surface。
voID setwindowstopped(boolean stopped) { if (mStopped != stopped) { mStopped = stopped; final ThreadedRenderer renderer = mAttachInfo.mThreadedRenderer; if (renderer != null) { if (DEBUG_DRAW) Log.d(mTag, "windowstopped on " + getTitle() + " set to " + mStopped); renderer.setStopped(mStopped); } if (!mStopped) { scheduleTraversals(); } else { if (renderer != null) { renderer.destroyHarDWareResources(mVIEw); } } for (int i = 0; i < mwindowstoppedCallbacks.size(); i++) { mwindowstoppedCallbacks.get(i).windowstopped(stopped); } if (mStopped) { mSurface.release(); } } }
问题总结:
此问题是由于灭屏后mSurface.release(),而亮屏时没有触发重现使能surface而导致的。
二、桌面有手势按键(quickstep)的时候,出现桌面anr事件:
----- pID 10005 at 2019-01-01 12:22:46 -----Cmd line: com.androID.launcher3"main" prio=5 tID=1 Blocked | group="main" sCount=1 dsCount=0 flags=1 obj=0x75e5fab0 self=0x70f3a14c00 | sysTID=10005 nice=-10 cgrp=default sched=0/0 handle=0x717a1b5548 | state=S schedstat=( 481187776 24084236 354 ) utm=39 stm=8 core=1 HZ=100 | stack=0x7ffbeae000-0x7ffbeb0000 stackSize=8MB | held mutexes= at com.androID.quickstep.normalizedIconLoader.getBitmAPInfo(normalizedIconLoader.java:-1) - waiting to lock <0x0b405da7> (a com.androID.quickstep.normalizedIconLoader) held by thread 10 at com.androID.quickstep.normalizedIconLoader.getDefaultIcon(normalizedIconLoader.java:58) - locked <0x0d1af254> (a androID.util.SparseArray) at com.androID.systemUI.shared.recents.model.RecentsTaskLoader.loadTaskData(RecentsTaskLoader.java:185) at com.androID.quickstep.vIEws.RecentsVIEw.loadVisibleTaskData(RecentsVIEw.java:672) at com.androID.quickstep.vIEws.RecentsVIEw.resetTaskVisuals(RecentsVIEw.java:567) at com.androID.quickstep.vIEws.RecentsVIEw.applyLoadplan(RecentsVIEw.java:543) at com.androID.quickstep.vIEws.RecentsVIEw.lambda$w02bBzSWizaR4dIzSj9kQ73I7BA(RecentsVIEw.java:-1) at com.androID.quickstep.vIEws.-$$Lambda$RecentsVIEw$w02bBzSWizaR4dIzSj9kQ73I7BA.accept(lambda:-1) at com.androID.quickstep.RecentsModel.lambda$loadTasks(RecentsModel.java:142) at com.androID.quickstep.-$$Lambda$RecentsModel$rZAN1-eRHSYycmOWL-UzK9dzJ1Q.run(lambda:-1) at com.androID.launcher3.util.LooperExecutor.execute(LooperExecutor.java:43) at com.androID.quickstep.RecentsModel.loadTasks(RecentsModel.java:142) at com.androID.quickstep.vIEws.RecentsVIEw.setCurrentTask(RecentsVIEw.java:775) at com.androID.quickstep.vIEws.RecentsVIEw.showTask(RecentsVIEw.java:745) at com.androID.quickstep.WindowtransformSwipeHandler.onLauncherStart(WindowtransformSwipeHandler.java:409) at com.androID.quickstep.WindowtransformSwipeHandler.lambda$oTmdTx9KEnt4AhNDszi5oKfUOY4(WindowtransformSwipeHandler.java:-1) at com.androID.quickstep.-$$Lambda$WindowtransformSwipeHandler$oTmdTx9KEnt4AhNDszi5oKfUOY4.onActivityStart(lambda:-1) at com.androID.launcher3.BaseDraggingActivity.onStart(BaseDraggingActivity.java:235) at com.androID.launcher3.Launcher.onStart(Launcher.java:848) at androID.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391) at androID.app.Activity.performStart(Activity.java:7157) at androID.app.ActivityThread.handleStartActivity(ActivityThread.java:2968) at androID.app.servertransaction.TransactionExecutor.performlifecycleSequence(TransactionExecutor.java:180) at androID.app.servertransaction.TransactionExecutor.cycletoPath(TransactionExecutor.java:165) at androID.app.servertransaction.TransactionExecutor.executelifecycleState(TransactionExecutor.java:142) at androID.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1836) at androID.os.Handler.dispatchMessage(Handler.java:106) at androID.os.Looper.loop(Looper.java:193) at androID.app.ActivityThread.main(ActivityThread.java:6702) at java.lang.reflect.Method.invoke(Native method) at com.androID.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:911)"Binder:10005_3" prio=5 tID=10 Waiting | group="main" sCount=1 dsCount=0 flags=1 obj=0x12e04f78 self=0x70ed23c000 | sysTID=10018 nice=0 cgrp=default sched=0/0 handle=0x70debee4f0 | state=S schedstat=( 51705932 1946846 88 ) utm=2 stm=2 core=2 HZ=100 | stack=0x70deaf3000-0x70deaf5000 stackSize=1009KB | held mutexes= at java.lang.Object.wait(Native method) - waiting on <0x095edfc0> (a java.lang.Object) at java.lang.Thread.parkFor$(Thread.java:2137) - locked <0x095edfc0> (a java.lang.Object) at sun.misc.Unsafe.park(Unsafe.java:358) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190) at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:450) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at com.androID.launcher3.LauncherAppState.getInstance(LauncherAppState.java:66) at com.androID.launcher3.LauncherAppState.getIDP(LauncherAppState.java:174) at com.androID.launcher3.graphics.LauncherIcons.<init>(LauncherIcons.java:133) at com.androID.launcher3.graphics.LauncherIcons.obtain(LauncherIcons.java:91) at com.androID.quickstep.normalizedIconLoader.getBitmAPInfo(normalizedIconLoader.java:76) - locked <0x0b405da7> (a com.androID.quickstep.normalizedIconLoader) at com.androID.quickstep.normalizedIconLoader.getBadgedActivityIcon(normalizedIconLoader.java:88) at com.androID.systemUI.shared.recents.model.IconLoader.createNewIconForTask(IconLoader.java:134) at com.androID.systemUI.shared.recents.model.IconLoader.getAndInvalIDateIfModifIEd(IconLoader.java:94) at com.androID.systemUI.shared.recents.model.RecentsTaskLoader.getAndUpdateActivityIcon(RecentsTaskLoader.java:325) at com.androID.systemUI.shared.recents.model.RecentsTaskLoadplan.executePlan(RecentsTaskLoadplan.java:182) at com.androID.systemUI.shared.recents.model.RecentsTaskLoader.loadTasks(RecentsTaskLoader.java:173) - locked <0x0411f4f9> (a com.androID.quickstep.RecentsModel) at com.androID.quickstep.RecentsModel.onTaskStackChangedBackground(RecentsModel.java:214) at com.androID.systemUI.shared.system.TaskStackchangelisteners.onTaskStackChanged(TaskStackchangelisteners.java:79) at androID.app.ITaskStackListener$Stub.onTransact(ITaskStackListener.java:50) at androID.os.Binder.execTransact(Binder.java:731)
问题分析:
从anr文件上来看是
(1)线程"Binder:10005_3" locked <0x0b405da7> (a com.androID.quickstep.normalizedIconLoader)
(2)主线程"main" waiting to lock <0x0b405da7> (a com.androID.quickstep.normalizedIconLoader) held by thread 1
那么可以确认是由于线程"Binder:10005_3"运行时间过长而导致的UI线程出现ANR的。
进一步分析"Binder:10005_3"发现,"Binder:10005_3"是在运行LauncherAppState.getInstance耗时太长造成的,而耗时太长的原因是由于线程使用FutureTask属性在阻塞等待其他线程的唤醒,而等待的线程是那个呢?我们看下LauncherAppState.getInstance的代码:
public static LauncherAppState getInstance(final Context context) { if (INSTANCE == null) { if (Looper.myLooper() == Looper.getMainLooper()) { INSTANCE = new LauncherAppState(context.getApplicationContext()); } else { try { return new MainThreadExecutor().submit(new Callable<LauncherAppState>() { @OverrIDe public LauncherAppState call() throws Exception { return LauncherAppState.getInstance(context); } }).get(); } catch (InterruptedException|ExecutionException e) { throw new RuntimeException(e); } } } return INSTANCE; }
从上面函数可以看到LauncherAppState是一个典型的单例模式,而它的创建被限制在了UI线程中,也就是说只有UI线程才能创建这个单例模式的LauncherAppState,而线程"Binder:10005_3"创建时需要用到MainThreadExecutor去阻塞的等待主线程"main"创建完成之后才能继续运行(此处使用了Future类并发编程模型)。而主线程"main"此时却在等待着线程"Binder:10005_3"一直locked的锁 <0x0b405da7>,而此行为也导致了主线程"main"的Loop流程阻塞,进而导致线程"Binder:10005_3"永远无法拿到LauncherAppState的实现。
问题流程图如下:
总结
以上是内存溢出为你收集整理的android P版本 系统稳定性问题案例分析(一)全部内容,希望文章能够帮你解决android P版本 系统稳定性问题案例分析(一)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)