Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发现问题 #4

Open
brucewuu520 opened this issue Nov 21, 2014 · 7 comments
Open

发现问题 #4

brucewuu520 opened this issue Nov 21, 2014 · 7 comments

Comments

@brucewuu520
Copy link

发现一问题,JsCallback回调时报空指针错误:
Caused by: java.lang.NullPointerException
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2678)
at android.webkit.WebViewClassic.loadUrlImpl(WebViewClassic.java:2694)
at android.webkit.WebViewClassic.loadUrl(WebViewClassic.java:2687)
at android.webkit.WebView.loadUrl(WebView.java:804)
at cn.pedant.SafeWebViewBridge.JsCallback.apply(JsCallback.java:42)
at com.jidian.android.edo.util.HostJsScope$2.onComplete(HostJsScope.java:137)

我猜测可能是这样的,因为回调有延迟,callback.apply()的时候可能webview已经被关闭,导致的这个错误

@brucewuu520
Copy link
Author

@pedant 收到了吗

@pedant
Copy link
Owner

pedant commented Nov 27, 2014

我这边destory webview关联的activity也无法重现你的异常。不过从你的异常日志上看来,应该不是webview已经被回收的问题。因为如果是那样,会直接在android.webkit.WebView.loadUrl这里报空指针。另外每个JsCallback中强引用了相关联的WebView,即使activity退出销毁后也能正常执行回调JS,但如果回调的js涉及更新UI,则会有下面的异常。

11-27 10:46:45.992  22168-22168/cn.pedant.SafeWebViewBridge.sample E/Web Console﹕ Uncaught HostApp call error, code:500, message:method execute error:Unable to add window -- token android.os.BinderProxy@416894a0 is not valid; is your activity running? at null:1

但这里强引用引出个了新问题,就是可能造成内存泄漏。所以我更新下代码,使用SoftReference来包装JsCallback引用的WebView。

@brucewuu520
Copy link
Author

ok

@pedant
Copy link
Owner

pedant commented Nov 27, 2014

提交 23fed5d

@brucewuu520
Copy link
Author

Gradle部署下吧?我也测测看

@pedant
Copy link
Owner

pedant commented Nov 27, 2014

已部署

repositories {
    mavenCentral()
}

dependencies {
    compile 'cn.pedant.safewebviewbridge:library:1.4'
}

@guofeng007
Copy link

看下出现这个crash的手机系统是不是4.1.2,这个版本上的webview的问题,参见下面的链接
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/tjqDzFJk98w

sorry这个可能不准,在其他地方也看到这个类似的bug,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants