Gank.io icon indicating copy to clipboard operation
Gank.io copied to clipboard

WebActivity中存在泄露问题

Open basti-shi031 opened this issue 9 years ago • 5 comments

复现步骤是这样的,进入MainActivity后点击Fab进入BatteryActivity,然后RecyclerView中的任意一个item进入WebActivity,按返回键返回,这时LogCat中会报这样的日志 1973-1973/com.smartalk.gank E/ActivityThread: Activity com.smartalk.gank.ui.activity.WebActivity has leaked ServiceConnection com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient$Connection@8899edf that was originally bound here android.app.ServiceConnectionLeaked: Activity com.smartalk.gank.ui.activity.WebActivity has leaked ServiceConnection com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient$Connection@8899edf that was originally bound here at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:1072) at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:966) at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1776) at android.app.ContextImpl.bindService(ContextImpl.java:1759) at android.content.ContextWrapper.bindService(ContextWrapper.java:538) at android.content.ContextWrapper.bindService(ContextWrapper.java:538) at com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient.doBindService(SelfBrailleClient.java:125) at com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient.access$1000(SelfBrailleClient.java:43) at com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient$SelfBrailleHandler.handleRebindService(SelfBrailleClient.java:260) at com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient$SelfBrailleHandler.handleMessage(SelfBrailleClient.java:245) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

我在项目中添加LeakCanary依赖,重复以上步骤时也会报存泄露的问题,个人猜测是使用WebView的问题,因为我之前对WebView了解的不多,网上也没有找到对这个log的详细说明和解决方案,请问该如何解决?谢谢!

basti-shi031 avatar Feb 03 '16 05:02 basti-shi031

我集成LeakCanary并没有发现这个问题,具体问题我也不太清楚。

Panl avatar Feb 12 '16 15:02 Panl

在OnDestroy()里面添加 webView = null应该就好了

Panl avatar Feb 13 '16 16:02 Panl

webview内部有service,在布局文件实例后会传入activity的context,内部会bindservice

royorange avatar Sep 30 '16 02:09 royorange

@Panl ,试了一下webview=null,还是有这问题(Sony L55u Android4.4.4)

OsBelief avatar Nov 08 '16 11:11 OsBelief

setJavaScriptEnabled(true)就会有这个问题

Allen-Guof avatar May 05 '17 01:05 Allen-Guof