gpt4 book ai didi

ios - Swift JavaScriptCore 有时会崩溃(bmalloc::VMHeap::grow())

转载 作者:可可西里 更新时间:2023-10-31 23:13:40 37 4
gpt4 key购买 nike

我在我的swift项目中使用javaScriptCore,webview上有两张图片,我想点击图片来呈现我的swift viewController,在html中,点击图片的功能名为“scanImgs”,这是我的代码

func webViewDidFinishLoad(webView: UIWebView) {

guard let context = webView.valueForKeyPath("documentView.webView.mainFrame.javaScriptContext") as? JSContext else {
return
}

let scanImgs: @convention(block) (String, String, Int) -> Void = { (image1: String, image2: String, index: Int) in

let photosVC: UIViewController = SpursPhotoBrowserViewController.getPhotoBrowser(image1, secondImageURL: image2, selectIndex: UInt(index))

dispatch_async(dispatch_get_main_queue(), {
self.presentViewController(photosVC, animated: true, completion: nil)
})
}

context.setObject(unsafeBitCast(scanImgs, AnyObject.self), forKeyedSubscript: "scanImgs")

}

此代码大部分时间都可以正常运行,但有时我会在 JavaScriptCore 中崩溃,这是崩溃日志

 0 JavaScriptCore   bmalloc::VMHeap::grow() + 132
1 JavaScriptCore bmalloc::VMHeap::grow() + 56
2 JavaScriptCore bmalloc::Heap::allocateSmallPage(std::__1::lock_guard<bmalloc::StaticMutex>&, unsigned long) + 244
3 JavaScriptCore bmalloc::Heap::refillSmallBumpRangeCache(std::__1::lock_guard<bmalloc::StaticMutex>&, unsigned long, bmalloc::FixedVector<bmalloc::BumpRange, 32ul>&) + 36
4 JavaScriptCore bmalloc::Allocator::allocateBumpRangeSlowCase(unsigned long) + 128
5 JavaScriptCore bmalloc::Allocator::allocateSlowCase(unsigned long) + 180
6 WebCore cssyyparse(WebCore::CSSParser*) + 1232
7 WebCore WebCore::CSSParser::parseSheet(WebCore::StyleSheetContents*, WTF::String const&, WTF::TextPosition const&, WTF::Vector<WTF::RefPtr<WebCore::CSSRuleSourceData>, 0ul, WTF::CrashOnOverflow, 16ul>*, bool) + 488
8 WebCore WebCore::StyleSheetContents::parseAuthorStyleSheet(WebCore::CachedCSSStyleSheet const*, WebCore::SecurityOrigin const*) + 164
9 WebCore WebCore::HTMLLinkElement::setCSSStyleSheet(WTF::String const&, WebCore::URL const&, WTF::String const&, WebCore::CachedCSSStyleSheet const*) + 996
10 WebCore WebCore::CachedCSSStyleSheet::didAddClient(WebCore::CachedResourceClient*) + 116
11 WebCore WebCore::HTMLLinkElement::process() + 2064
12 WebCore WebCore::HTMLLinkElement::insertedInto(WebCore::ContainerNode&) + 80
13 WebCore WebCore::ChildNodeInsertionNotifier::notify(WebCore::Node&, WTF::Vector<WTF::Ref<WebCore::Node>, 11ul, WTF::CrashOnOverflow, 16ul>&) + 164
14 WebCore WebCore::ContainerNode::notifyChildInserted(WebCore::Node&, WebCore::ContainerNode::ChildChangeSource) + 172
15 WebCore WebCore::ContainerNode::parserAppendChild(WTF::PassRefPtr<WebCore::Node>) + 240
16 WebCore WebCore::insert(WebCore::HTMLConstructionSiteTask&) + 228
17 WebCore WebCore::HTMLConstructionSite::executeQueuedTasks() + 148
18 WebCore WebCore::HTMLDocumentParser::constructTreeFromHTMLToken(WebCore::HTMLTokenizer::TokenPtr&) + 156
19 WebCore WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode) + 352
20 WebCore WebCore::HTMLDocumentParser::append(WTF::PassRefPtr<WTF::StringImpl>) + 608
21 WebCore WebCore::DecodedDataDocumentParser::appendBytes(WebCore::DocumentWriter&, char const*, unsigned long) + 116
22 WebCore WebCore::DocumentLoader::commitData(char const*, unsigned long) + 596
23 WebKitLegacy -[WebHTMLRepresentation receivedData:withDataSource:] + 112
24 WebKitLegacy -[WebDataSource(WebInternal) _receivedData:] + 68
25 WebKitLegacy WebFrameLoaderClient::committedLoad(WebCore::DocumentLoader*, char const*, int) + 112
26 WebCore WebCore::DocumentLoader::commitLoad(char const*, int) + 172
27 WebCore WebCore::CachedRawResource::didAddClient(WebCore::CachedResourceClient*) + 828
28 WebCore WebCore::ThreadTimers::sharedTimerFiredInternal() + 148
29 WebCore WebCore::timerFired(__CFRunLoopTimer*, void*) + 36
30 CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
31 CoreFoundation ___CFRunLoopDoTimer + 884
32 CoreFoundation ___CFRunLoopRun + 1520
33 CoreFoundation CFRunLoopRunSpecific + 384
34 WebCore RunWebThread(void*) + 456
35 libsystem_pthread.dylib __pthread_body + 156
36 libsystem_pthread.dylib __pthread_body

这个bug有什么问题...

最佳答案

我最近遇到了同样的问题,可能是webkit的bug您可以在 viewWillDisappear 时尝试 [webview stopLoading]。修复这个崩溃会很有帮助

关于ios - Swift JavaScriptCore 有时会崩溃(bmalloc::VMHeap::grow()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41116172/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com