wendux / DSBridge-IOS

:earth_asia: A modern cross-platform JavaScript bridge, through which you can invoke each other's functions synchronously or asynchronously between JavaScript and native.
1.96k stars 305 forks source link

Fix: complete handler must be call before wkwebview dealloc. If not c… #104

Open gdxz123 opened 4 years ago

gdxz123 commented 4 years ago

…alled, webview will be crash. When H5 alert( comfirm/ promot) something, and webview dealloc, then the dwkwebview will crash.

gdxz123 commented 4 years ago

bugly crash report:

0 Thread

NSInternalInconsistencyException Completion handler passed to -[DWKWebView webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:] was not called

qianshou commented 4 years ago

赞,这样即使销毁后弹窗也不会导致crash了。不过还是会出现webview已经关闭,仍然弹出alert框的情况,最好加个标识位,webview不可见的情况下直接调用completionHandler

gdxz123 commented 4 years ago

赞,这样即使销毁后弹窗也不会导致crash了。不过还是会出现webview已经关闭,仍然弹出alert框的情况,最好加个标识位,webview不可见的情况下直接调用completionHandler

最好别做这样的逻辑,因为不可见的情况可能有些业务逻辑就是要弹aler弹窗,本身出现这样的奔溃主要是因为webview释放了,但还在执行alert动作,我们修复这个bug就好了,不应在不可见的时候执行completionHanler,因为这样就改变了webview的特性了

gdxz123 commented 4 years ago

赞,这样即使销毁后弹窗也不会导致crash了。不过还是会出现webview已经关闭,仍然弹出alert框的情况,最好加个标识位,webview不可见的情况下直接调用completionHandler

这个标记位可以加到业务层,库的层面没啥必要加吧

ryanZhange commented 3 years ago

方法可行,我也遇到这个问题了,希望能和入这个修改