简体   繁体   English

Android 应用程序从断点恢复后运行非常缓慢

[英]Android app runs very slowly after resuming from breakpoint

My Android app runs dead slow (almost frozen) after resuming from a Java breakpoint, even if I disconnect from the debugger or even unplug the USB cable.从 Java 断点恢复后,我的 Android 应用程序运行速度非常慢(几乎冻结),即使我与调试器断开连接甚至拔下 USB 电缆也是如此。 I get the same behavior on every device and emulator I've tried.我在我尝试过的每个设备和模拟器上都得到了相同的行为。 Performance is great until it hits the first breakpoint, but it's unusable after I resume and I have to kill it.在达到第一个断点之前性能很好,但是在我恢复后它无法使用,我必须杀死它。 It's very frustrating.这很令人沮丧。

It used to work great but it started with Android Studio 3.1.x and it's still happening after I upgraded to 3.2.1, then 3.3.2, the latest stable release at this time.它曾经运行良好,但它从 Android Studio 3.1.x 开始,在我升级到 3.2.1,然后是 3.3.2(此时最新的稳定版本)后,它仍在发生。 None of my colleagues who work on the same app have this problem so it's probably not the code.我在同一个应用程序上工作的同事都没有这个问题,所以可能不是代码。 I suspect I have a configuration issue somewhere.我怀疑我在某处有配置问题。

I have no idea what changed when it started.我不知道它开始时发生了什么变化。 It happens no matter where the breakpoint is.无论断点在哪里,它都会发生。 I don't see any errors in LogCat.我在 LogCat 中没有看到任何错误。

I'm using a MacBook Pro (15-inch, 2017) running OSX 10.13.6, Android Studio 3.3.2 (current stable release) and a Pixel XL running P. Also various emulators running P.我正在使用运行 OSX 10.13.6、Android Studio 3.3.2(当前稳定版本)的 MacBook Pro(15 英寸,2017 年)和运行 P 的 Pixel XL。还有各种运行 P 的模拟器。

Any ideas or suggestions are much appreciated.任何想法或建议都非常感谢。

NOTE: It happens on Java breakpoints but not Kotlin.注意:它发生在 Java 断点上,而不是 Kotlin。

NOTE: I cannot repro with a simple default app, so it's project specific, but only on my machine.注意:我无法使用简单的默认应用程序进行重现,因此它是特定于项目的,但仅限于我的机器上。

在此处输入图片说明

make sure your debugger is ok .确保你的调试器没问题。

Don't add breakpoint in the method definition.不要在方法定义中添加断点。 Method breakpoint will decrese the performance.方法断点会降低性能。 Go with line breakpoint.使用行断点。 That is better.那比较好。

Please go through the difference b/w method breakpoint and line breakpoint if you are not aware.如果您不知道,请查看黑白方法断点和行断点的差异。

Try to remove all the previous breakpoints that you might have added in Android Studio.尝试删除您可能在 Android Studio 中添加的所有先前断点。

Go to the debugger window and select the View Breakpoints option and then disable all the old breakpoints and only add the new one which you want to use.转到调试器窗口并选择“查看断点”选项,然后禁用所有旧断点,仅添加您要使用的新断点。

调试器部分

禁用所有旧断点

As @Magudesh stated, method breakpoints are very slow for the android debugger.正如@Magudesh 所说,android 调试器的方法断点非常慢。

It's a lot more useful to just add a line breakpoint in the first line of your method and then (if it's necessary) in the last line.在方法的第一行然后(如果有必要)在最后一行添加一个行断点会更有用。

That will greatly increase performance.这将大大提高性能。 If you then want to jump to the next breakpoint you can just hit the green play button in your debugger window.如果您想跳转到下一个断点,您只需点击调试器窗口中的绿色播放按钮即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM