AndroidPerformanceMonitor icon indicating copy to clipboard operation
AndroidPerformanceMonitor copied to clipboard

add append mode to avoid conflicted getMainLooper().setMessageLogging()

Open markzhai opened this issue 9 years ago • 11 comments

Currently BlockCanary directly calls getMainLooper().setMessageLogging() to do monitor, which may conflicts with the original logging set by app, we can add a append mode for those situation.

markzhai avatar Jan 28 '16 09:01 markzhai

@huangqichao currently BlockCanary directly calls getMainLooper().setMessageLogging() to do monitor, if developer's app already used main looper's messageLogging to do something, this will overwrite the original one, thus we need append the MessageLoggin instead of set it.

markzhai avatar Feb 18 '17 04:02 markzhai

my trouble is : the webview constructor will reset the mainlooper.logging null ,is that means i can't use blockcanary if my project used webview?

YellowQC avatar Feb 18 '17 05:02 YellowQC

why does your webview constructor do this?

markzhai avatar Feb 18 '17 06:02 markzhai

Not my webview, that's sdk source code. Prehaps google's engineer also did something like monitor the mainlooper performance by this way.

YellowQC avatar Feb 18 '17 07:02 YellowQC

我提出的问题,解决方式是可以在 Application onCreate方法里,在初始化BlockCanary之前,初始化一个WebView,即可。

YellowQC avatar Feb 20 '17 07:02 YellowQC

@huangqichao Did you fixed the issue about Webview ?

suntzu93 avatar Jun 13 '17 03:06 suntzu93

@thanhlv93 I think he solved it by creating a webview before initialize BlockCanary, maybe you can try this, while I still cannot find where WebView set main thread's looper logging, I still cannot solve this problem, I will appreciate if you can help provide where WebView do this.

markzhai avatar Jun 13 '17 03:06 markzhai

@markzhai I'm running as you said set initialize BlockCanary after create a webview. If I find out where does the webview do this , I will let you know .

suntzu93 avatar Jun 13 '17 07:06 suntzu93

The webview set the logging null in the native code, and only once! You can add a breakpoint in setMessageLogging and read the trace ,you'll find out where does the webview do this.

YellowQC avatar Aug 14 '17 03:08 YellowQC

大佬,我们项目使用了setMessageLogging是 Looper.getMainLooper().setMessageLogging主线程的 Looper 设置进去的,但是另外一个库也使用了Looper.getMainLooper().setMessageLogging。这钟冲突你说的追加MessageLoggin是什么意思呢,求指导下

valiantyan avatar Sep 25 '23 03:09 valiantyan

您发给我的信件已经收到。 谢谢!

ideav5 avatar Sep 25 '23 03:09 ideav5