markzhai/AndroidPerformanceMonitor

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

markzhai opened this issue · 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.

@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.

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?

why does your webview constructor do this?

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

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

@huangqichao Did you fixed the issue about Webview ?

@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 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 .

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.

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

ideav5 commented