Skip to content

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

Open
gdxz123 wants to merge 2 commits into
wendux:masterfrom
gdxz123:develop
Open

Fix: complete handler must be call before wkwebview dealloc. If not c…#104
gdxz123 wants to merge 2 commits into
wendux:masterfrom
gdxz123:develop

Conversation

@gdxz123

@gdxz123 gdxz123 commented Sep 17, 2019

Copy link
Copy Markdown

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

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

gdxz123 commented Sep 17, 2019

Copy link
Copy Markdown
Author

bugly crash report:

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

@qianshou

Copy link
Copy Markdown

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

@gdxz123

gdxz123 commented Jan 21, 2020

Copy link
Copy Markdown
Author

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

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

@gdxz123 gdxz123 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix: complete handler must be call before wkwebview dealloc

@gdxz123

gdxz123 commented Jan 21, 2020

Copy link
Copy Markdown
Author

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

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

@ryanZhange

Copy link
Copy Markdown

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

@gdxz123 gdxz123 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix(webview):解决H5异步延时事件触发且webview销毁时奔溃问题

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

Successfully merging this pull request may close these issues.

3 participants