使用
在要调试的地方调用以下语句,就能看得到系统调用栈
Log.d("fasfafa",Log.getStackTraceString(new Throwable()));
举例
例如我要
debug
开启硬件加速和不开启硬件加速调用invalidate
有什么区别
1、在Manifest对应Activity添加android:hardwareAccelerated="false"
2、在onDraw
添加Log
语句
3、结果如下:
不开启硬件加速
2021-07-11 14:17:29.712 17763-17763/com.test.test D/fasfafa: java.lang.Throwable
at com.test.test.AView.onDraw(AView.java:52)
at android.view.View.draw(View.java:21651)
at android.view.View.draw(View.java:21520)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21654)
at android.view.View.draw(View.java:21520)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21518)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21518)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21518)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21518)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21654)
at com.android.internal.policy.DecorView.draw(DecorView.java:1005)
at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:4016)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3920)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3700)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2989)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1876)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8167)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1057)
at android.view.Choreographer.doCallbacks(Choreographer.java:875)
at android.view.Choreographer.doFrame(Choreographer.java:776)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1042)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
开启硬件加速
2021-07-11 14:21:02.582 18877-18877/com.test.test D/fasfafa: java.lang.Throwable
at com.test.test.AView.onDraw(AView.java:52)
at android.view.View.draw(View.java:21651)
at android.view.View.updateDisplayListIfDirty(View.java:20511)
at android.view.View.draw(View.java:21378)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21654)
at android.view.View.updateDisplayListIfDirty(View.java:20511)
at android.view.View.draw(View.java:21378)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.updateDisplayListIfDirty(View.java:20502)
at android.view.View.draw(View.java:21378)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.updateDisplayListIfDirty(View.java:20502)
at android.view.View.draw(View.java:21378)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.updateDisplayListIfDirty(View.java:20502)
at android.view.View.draw(View.java:21378)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.updateDisplayListIfDirty(View.java:20502)
at android.view.View.draw(View.java:21378)
at android.view.ViewGroup.drawChild(ViewGroup.java:4605)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4364)
at android.view.View.draw(View.java:21654)
at com.android.internal.policy.DecorView.draw(DecorView.java:1005)
at android.view.View.updateDisplayListIfDirty(View.java:20511)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:584)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:590)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:668)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3892)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3700)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2989)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1876)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8167)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1057)
at android.view.Choreographer.doCallbacks(Choreographer.java:875)
at android.view.Choreographer.doFrame(Choreographer.java:776)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1042)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)