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

异步调用可能产生内存泄露 #69

Closed
Leon0317 opened this issue Oct 17, 2018 · 3 comments
Closed

异步调用可能产生内存泄露 #69

Leon0317 opened this issue Oct 17, 2018 · 3 comments

Comments

@Leon0317
Copy link

目前在使用的是3.0.2版本。
在DWKWebView中执行到
-(NSString *)call:(NSString*) method :(NSString*) argStr
这一方法时,在266行定义completionHandler时,block中使用了self,而后把这个completionHandler作为用户自定义的异步方法的参数传给了JavascriptInterfaceObject对象。这个情况可能会造成DWKWebView对象长时间被强引用不能释放,导致一些内存检测机制告警。
我在定义这个completionHandler使用weak-strong dance处理了一下,检测不到内存泄露了。
希望在新版本中能评估一下这个问题。

@wendux
Copy link
Owner

wendux commented Nov 2, 2018

如果需要改库源码得话,可以提个PR;如果是使用方式上该注意的问题,可以贴出你的代码供大家参考。

@wendux wendux closed this as completed in f0e3c72 Nov 19, 2018
@GuoMingJian
Copy link

用了这个sdk,线上包一直闪退报错,大神能解决下么?

SEGV_ACCERR

出错堆栈
0
??? 000000000000000000

  • 0
    1
    Foundation
    +[_NSJSONReader validForJSON:depth:allowFragments:] + 72
    2
    Foundation
    ___51+[_NSJSONReader validForJSON:depth:allowFragments:]_block_invoke + 96
    3
    CoreFoundation
    _NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 16
    4
    CoreFoundation
    -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 208
    5
    Foundation
    +[_NSJSONReader validForJSON:depth:allowFragments:] + 172
    6
    dsBridge
    +[JSBUtil objToJsonString:] + 100
    7
    dsBridge
    -[DWKWebView call::] + 1700
    8
    dsBridge
    -[DWKWebView webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:] + 640
    9
    WebKit
    WebKit::UIDelegate::UIClient::runJavaScriptPrompt(WebKit::WebPageProxy*, WTF::String const&, WTF::String const&, WebKit::WebFrameProxy*, WebCore::SecurityOriginData const&, WTF::Function<void (WTF::String const&)>&&) + 492
    10
    WebKit
    WebKit::WebPageProxy::runJavaScriptPrompt(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::String const&, WTF::CompletionHandler<void (WTF::String const&)>&&) + 172
    11
    WebKit
    void IPC::handleMessageSynchronous<Messages::WebPageProxy::RunJavaScriptPrompt, WebKit::WebPageProxy, void (WebKit::WebPageProxy::)(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::String const&, WTF::CompletionHandler<void (WTF::String const&)>&&)>(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_deleteIPC::Encoder >&, WebKit::WebPageProxy, void (WebKit::WebPageProxy::)(unsigned long long, WebCore::SecurityOriginData const&, WTF::String const&, WTF::String const&, WTF::CompletionHandler<void (WTF::String const&)>&&)) + 180
    12
    WebKit
    IPC::MessageReceiverMap::dispatchSyncMessage(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_deleteIPC::Encoder >&) + 112
    13
    WebKit
    WebKit::WebProcessProxy::didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::__1::unique_ptr<IPC::Encoder, std::__1::default_deleteIPC::Encoder >&) + 36
    14
    WebKit
    IPC::Connection::dispatchSyncMessage(IPC::Decoder&) + 196
    15
    WebKit
    IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_deleteIPC::Decoder >) + 192
    16
    WebKit
    IPC::Connection::SyncMessageState::dispatchMessages(IPC::Connection
    ) + 264
    17
    WebKit
    IPC::Connection::SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesForConnection(IPC::Connection&) + 168
    18
    JavaScriptCore
    WTF::RunLoop::performWork() + 276
    19
    JavaScriptCore
    WTF::RunLoop::performWork(void*) + 36

@sjustfly
Copy link

SEGV_ACCERR

出错堆栈
0
??? 000000000000000000

0
1
Foundation
+[_NSJSONReader validForJSON:depth:allowFragments:] + 72
2
Foundation
___51+[_NSJSONReader validForJSON:depth:allowFragments:]_block_invoke + 96
3
CoreFoundation
_NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 16
这个问题有解决么,我这边也是一直报错

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

4 participants