I'm trying to include a UIWebView based browser in my iPad application. It takes some time, which makes it hard to debug, but the app finally crashes, always on the same spot: the WebThread, on the JavaScriptCore WTF::StringImpl::hash() function. It produces EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS at 0x00000001.
The UIWebView is inside a view controller managed by another view controller (container) in a stack-like fashion. I'm only keeping four or less of those browsers in memory.
Anything about the crash log, or about what might be causing the crash?
This is the crash log of the web thread:
Thread 2 name: WebThread
Thread 2 Crashed:
0 JavaScriptCore 0x32a97d46 WTF::StringImpl::hash() const + 42
1 JavaScriptCore 0x32a97c6a WTF::HashTable<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityExtractor<WTF::StringImpl*>, WTF::StringHash, WTF::HashTraits<WTF::StringImpl*>, WTF::HashTraits<WTF::StringImpl*> >::lookupForWriting(WTF::StringImpl* const&) + 18
2 JavaScriptCore 0x32a9b028 std::pair<WTF::HashTableIterator<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityExtractor<WTF::StringImpl*>, WTF::StringHash, WTF::HashTraits<WTF::StringImpl*>, WTF::HashTraits<WTF::StringImpl*> >, bool> WTF::HashTable<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityExtractor<WTF::StringImpl*>, WTF::StringHash, WTF::HashTraits<WTF::StringImpl*>, WTF::HashTraits<WTF::StringImpl*> >::add<WTF::StringImpl*, WTF::StringImpl*, WTF::IdentityHashTranslator<WTF::StringImpl*, WTF::StringImpl*, WTF::StringHash> >(WTF::StringImpl* const&, WTF::StringImpl* const&) + 448
3 JavaScriptCore 0x32a9ae30 WTF::AtomicString::addSlowCase(WTF::StringImpl*) + 96
4 WebCore 0x31bade0c WebCore::AtomicHTMLToken::initializeAttributes(WTF::Vector<WebCore::HTMLToken::Attribute, 10ul> const&) + 232
5 WebCore 0x31b88076 WebCore::AtomicHTMLToken::AtomicHTMLToken(WebCore::HTMLToken&) + 302
6 WebCore 0x31b87eae WebCore::HTMLTreeBuilder::constructTreeFromToken(WebCore::HTMLToken&) + 14
7 WebCore 0x31b7d07e WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode) + 150
8 WebCore 0x31bee29a WebCore::HTMLDocumentParser::resumeParsingAfterScriptExecution() + 50
9 WebCore 0x31bc87e6 WebCore::HTMLDocumentParser::notifyFinished(WebCore::CachedResource*) + 78
10 WebCore 0x31bc7448 WebCore::CachedResource::checkNotify() + 40
11 WebCore 0x31bc7308 WebCore::CachedScript::data(WTF::PassRefPtr<WebCore::SharedBuffer>, bool) + 84
12 WebCore 0x31bc7240 WebCore::CachedResourceRequest::didFinishLoading(WebCore::SubresourceLoader*, double) + 120
13 WebCore 0x31bc715e WebCore::SubresourceLoader::didFinishLoading(double) + 158
14 WebCore 0x31bc58c2 _ZN7WebCoreL16didFinishLoadingEP16_CFURLConnectionPKv + 46
15 CFNetwork 0x347737ee URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 186
16 CFNetwork 0x3476849e URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 418
17 CFNetwork 0x3476819c URLConnectionClient::processEvents() + 100
18 CFNetwork 0x347680d2 MultiplexerSource::perform() + 150
19 CoreFoundation 0x313d2acc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
20 CoreFoundation 0x313d2298 __CFRunLoopDoSources0 + 208
21 CoreFoundation 0x313d103e __CFRunLoopRun + 646
22 CoreFoundation 0x3135449e CFRunLoopRunSpecific + 294
23 CoreFoundation 0x31354366 CFRunLoopRunInMode + 98
24 WebCore 0x31b74c9c _ZL12RunWebThreadPv + 396
25 libsystem_c.dylib 0x33bca72e _pthread_start + 314
26 libsystem_c.dylib 0x33bca5e8 thread_start + 0
I had the same problem, spent the whole day... There were a LOT of different WebKit errors like these. Finally, I got it: this was a multi-threaded issue! I created the WebView from thread 1, then tried to modify its contents by means of JS functions in thread 2...
The simple performSelectorOnMainThread:withObject:waitUntilDone: fixed the problem!
Maybe this will help someone.
As the crash log suggests, it looks like it might be a JavaScript related problem. I assume the page you're loading has JavaScript on it? Out of interest, does the webpage run fine in Mobile Safari - is it just in a UIWebView that you have problems?
If you're unable to modify the JS, or web page seems to run fine on other mobile/desktop browsers or devices , I would suggest filing a bug with Apple along with the JavaScript used to reproduce the problem.
Related
We encountered an OpenGL related crash on ios14. It has nothing to do with the application background. The vast majority of crashes occurred on IOS 14 low-end devices, and it is not clear how to solve them.
The only possible clue is that the crash may have something to do with opening the WebView.
Monitor Type: Unix Signal
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x00000001c7517414
Crashed Thread: 0
Pthread id: 10322737
Thread 0 Crashed:
0 libsystem_kernel.dylib __pthread_kill + 8
1 libsystem_pthread.dylib pthread_kill + 272
2 libsystem_c.dylib abort + 104
3 AppleMetalGLRenderer GLDContextRec::flushContextInternal() + 852
4 GLEngine gliPresentViewES_Exec + 188
5 OpenGLES -[EAGLContext presentRenderbuffer:] + 76
6 myapp -[EJCanvasContextWebGLScreen present] (EJCanvasContextWebGLScreen.m:142)
7 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 664
8 QuartzCore display_timer_callback(__CFMachPort*, void*, long, void*) + 280
9 CoreFoundation __CFMachPortPerform + 176
10 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
11 CoreFoundation __CFRunLoopDoSource1 + 596
12 CoreFoundation __CFRunLoopRun + 2360
13 CoreFoundation CFRunLoopRunSpecific + 600
14 GraphicsServices GSEventRunModal + 164
15 UIKitCore -[UIApplication _run] + 1072
16 UIKitCore UIApplicationMain + 168
17 myapp main (main.m:36)
18 libdyld.dylib start + 4
I'm 100% sure presentRenderBuffer works fine in iOS14.
According to the error message, it seems like a thread issue.
In my case, I use a queue to detail with all of the OpenGL things.
dispatch_sync(queue, ^{
// All of the OpenGL things
[self bindCurrentRenderBuffer];
[self presentRenderBuffer];
});
You can see my OpenGL project in Github: IRPlayer
As iOS13 release, there are more and more mapKit VectorKit crashes on the app which we are working on. We can not reproduce the crash internally and there are over 200 crashes collected by our own crash reporter everyday.
From all the information we have got, the crash always happens when the application come to active from background, and at that time, the ViewController view has a MKMapView subview. Maybe something wrong when the system rendering the map UI.
This problem seems a long-lasting iOS problem since iOS11 or even earlier. Now, The crash related iOS13 system version includes 13.0, 13.1, 13.1.1, 13.1.2. I have reported the problem on the Apple bug report system, but no any response from Apple until now.
Any advice or hint will be greatly appreciated.
FYI. The crash stack as below.
Exception Type: SIGABRT
Exception Codes: #0 at 0x1a8530ebc
Crashed Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib __pthread_kill + 8
1 libsystem_c.dylib abort + 100
2 libsystem_c.dylib __assert_rtn + 204
3 Metal MTLIOAccelCommandBufferStorageGrowSegmentList.cold.1 + 0
4 Metal MTLReportFailure + 476
5 Metal -[MTLTextureDescriptorInternal validateWithDevice:] + 2124
6 AGXMetalA11 0x00000001a85f93e8 + 64
7 VectorKit ggl::MetalResourceManager::newTexture(ggl::Texture const*) + 596
8 VectorKit ggl::MetalRenderer::prepareTexture(ggl::MetalResourceManager*, ggl::Texture const*) + 44
9 VectorKit ggl::MetalRenderer::_processQueue(ggl::RenderTarget*, ggl::RenderQueue*, id<MTLCommandBuffer>) + 3220
10 VectorKit ggl::MetalRenderer::_processQueue(ggl::RenderTarget*, ggl::RenderQueue*, id<MTLCommandBuffer>) + 96
11 VectorKit invocation function for block in ggl::MetalRenderer::frame(ggl::RenderTarget*, ggl::RenderQueue*, std::__1::function<void ()>, std::__1::function<void ()>) + 56
12 VectorKit invocation function for block in geo::TaskQueue::sync(std::__1::function<void ()>) + 60
13 libdispatch.dylib _dispatch_client_callout + 16
14 libdispatch.dylib _dispatch_async_and_wait_invoke_and_complete_recurse + 228
15 libdispatch.dylib _dispatch_async_and_wait_f + 100
16 VectorKit ggl::MetalRenderer::frame(ggl::RenderTarget*, ggl::RenderQueue*, std::__1::function<void ()>, std::__1::function<void ()>) + 544
17 VectorKit ggl::RenderFrame::execute(ggl::RenderTarget*, ggl::RenderQueue*, std::__1::function<void ()>, std::__1::function<void ()>) + 120
18 VectorKit -[MDDisplayLayer drawToTexture:withRenderQueue:completionHandler:] + 348
19 VectorKit -[MetalLayer _onTimerFired:withPresent:] + 280
20 VectorKit md::MapEngine::renderScene(double, std::__1::function<void ()>) + 104
21 VectorKit md::MapEngine::onRenderTimerFired(double) + 328
22 VectorKit ggl::DisplayLink::onTimerFired(double) + 40
23 VectorKit -[_GGLDisplayLinkTarget displayLinkFired:] + 84
24 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 632
25 QuartzCore display_timer_callback(__CFMachPort*, void*, long, void*) + 264
26 CoreFoundation __CFMachPortPerform + 172
27 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
28 CoreFoundation __CFRunLoopDoSource1 + 444
29 CoreFoundation __CFRunLoopRun + 2168
30 CoreFoundation CFRunLoopRunSpecific + 464
31 GraphicsServices GSEventRunModal + 104
32 UIKitCore UIApplicationMain + 1936
33 homebrew main (main.m:16)
34 libdyld.dylib start + 4
Check your CPU utilization on iOS12 vs iOS13.
I noticed that my app was crashing because I was adding and removing polylines to the map too frequently (although this problem only manifested in iOS13, not iOS12).
See my SO post about this here.
Look at your crash logs and see if you spot something like this:
Event: cpu usage
Action taken: Process killed
CPU: 48 seconds cpu time over 54 seconds (88% cpu average), exceeding limit of 80% cpu over 60 seconds
CPU limit: 48s
Limit duration: 60s
CPU used: 48s
Duration: 54.45s
Steps: 15
My app stopped crashing in iOS13 if I reduced the frequency for redrawing the map overlays.
I am using UIWebViews in some of the screens, because I need a perfect Html text parsing.
According to crash reports a huge number of crashes, called WTF Crash, occur on these screens. Here is a trace of that crash
Crashed: WebThread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000bbadbeef
Thread : Crashed: WebThread
0 JavaScriptCore 0x184fd2710 WTFCrash + 72
1 JavaScriptCore 0x184fd2708 WTFCrash + 64
2 WebCore 0x1852b7d78 <redacted> + 362
3 WebCore 0x1852b7bec <redacted> + 44
4 CoreFoundation 0x1817d8588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
5 CoreFoundation 0x1817d632c __CFRunLoopDoObservers + 372
6 CoreFoundation 0x1817d6674 __CFRunLoopRun + 696
7 CoreFoundation 0x181705680 CFRunLoopRunSpecific + 384
8 WebCore 0x1852b5998 <redacted> + 456
9 libsystem_pthread.dylib 0x18148bb28 <redacted> + 156
10 libsystem_pthread.dylib 0x18148ba8c _pthread_start + 154
11 libsystem_pthread.dylib 0x181489028 thread_start + 4
There is no OS version, or device relation on this crash.
I am not doing anything fancy on using UIWebView as well. It is added to nib like every other component, and in the implementation file I use it like the following
self.webView.scrollView.scrollEnabled = NO;
self.webView.scrollView.bounces = NO;
self.webView.opaque = NO;
self.webView.backgroundColor = [UIColor clearColor];
self.webView.delegate = self;
[self.webView loadHTMLString:htmlString baseURL:nil];
Any suggestions on how to solve WTF Crash?
Edit: Here is how htmlString looks like
Printing description of htmlString:
<html><body style="font-family:HelveticaNeue; font-size:10; background-color:#E5E4E4; text-align:left; color:#696969 ">test string</body></html>
I don't know how you are creating your UIWebView. But I was having a similiar issue with a WTFCrash and I was able to solve it by making sure that the UIWebView was being created on the main thread:
- (void)createWebView{
if (![NSThread isMainThread]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self createWebView];
});
return;
}
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
//Rest of my code
}
Are you debugging your web view with Safari? If yes, the crash should be gone after you quit Safari.
I was facing a similar crash with WKWebView, and I was sure the same code worked happily 3 days ago. hlung's comments saved me, you can find it HERE.
For your reference, following is a piece of the crash log in my case.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000dbbdfb10
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 Crashed:
0 JavaScriptCore 0x225d74c6 WTF::HashSet<JSC::MarkedArgumentBuffer*, WTF::PtrHash<JSC::MarkedArgumentBuffer*>, WTF::HashTraits<JSC::MarkedArgumentBuffer*> >::remove(JSC::MarkedArgumentBuffer* const&) + 54
1 JavaScriptCore 0x22620b41 JSC::VM::~VM() + 211
2 JavaScriptCore 0x22197e57 JSC::JSLockHolder::~JSLockHolder() + 73
3 JavaScriptCore 0x2248defd JSContextGroupRelease + 61
4 JavaScriptCore 0x2250e37d -[JSVirtualMachine dealloc] + 27
5 libobjc.A.dylib 0x1dac5195 objc_object::sidetable_release(bool) + 239
6 JavaScriptCore 0x2248d261 -[JSContext dealloc] + 125
7 libobjc.A.dylib 0x1dac5195 objc_object::sidetable_release(bool) + 239
8 JavaScriptCore 0x226470af WTF::RunLoop::TimerBase::timerFired(__CFRunLoopTimer*, void*) + 25
9 CoreFoundation 0x1e807357 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15
10 CoreFoundation 0x1e807029 __CFRunLoopDoTimer + 897
11 CoreFoundation 0x1e8069e1 __CFRunLoopDoTimers + 221
12 CoreFoundation 0x1e804cc5 __CFRunLoopRun + 1365
13 CoreFoundation 0x1e754073 CFRunLoopRunSpecific + 487
14 CoreFoundation 0x1e753e81 CFRunLoopRunInMode + 105
15 GraphicsServices 0x1ff00bfd GSEventRunModal + 157
16 UIKit 0x2390e82f -[UIApplication _run] + 575
17 UIKit 0x23908f61 UIApplicationMain + 151
18 MyApp 0x00488b29 0x2c000 + 4573993
19 libdyld.dylib 0x1df1e50b start + 3
WebKit, the engine behind Web Views, can raise a crash when it sees a memory problem.
These are identified by the special Hex Word 0x00000000bbadbeef as you have found.
The web page you are visiting seems trivial, so it is a surprise that you are having problems. I recommend you follow the WebKit debugging facilities described at:
https://webkit.org/debugging-webkit/#ios-simulator
Please update your question with any logs or insights this reveals.
It was a Google Ads issue, already fixed for sure on version 7.35.0 of October, 17 and newer versions.
You should be able to fix the issue updating your pod.
From the Google Mobile Ads SDK Developers Team mailing:
"The issue has been fixed by the team and it should go live in an upcoming SDK release (release notes)." (August, 20)
"Issue has been fixed and live already." (October, 17)
Source: https://groups.google.com/d/msg/google-admob-ads-sdk/XL35wo6mQts/R2LlGZDxBwAJ
Release Notes: https://developers.google.com/admob/ios/rel-notes
I'm experiencing multiple crashes where it appears that a native iOS method is calling functions from a third-party library. Here's an example:
Thread: Unknown Name (Crashed)
0 libsystem_kernel.dylib 0x33222350 __pthread_kill + 8 + 8
1 libsystem_c.dylib 0x3500f973 abort + 95 + 94
2 libsystem_c.dylib 0x34ff04d1 basename + 1
3 FireChat 0x00036489 -[OTOverlayButton drawRect:] + 1
4 Foundation 0x37a4a5a9 -[NSDictionary(NSKeyValueCoding) valueForKey:] + 33 + 32
5 FireChat 0x709d -[NetworkModel getUserForUid:] (NetworkModel.m:150)
6 FireChat 0x0001c42f -[OpenTokController session:didReceiveStream:] (OpenTokController.m:258)
7 libdispatch.dylib 0x32da011f _dispatch_call_block_and_release + 11 + 10
8 libdispatch.dylib 0x32d9f4b7 _dispatch_client_callout + 23 + 22
9 libdispatch.dylib 0x32da41bd _dispatch_main_queue_callback_4CF$VARIANT$mp + 225 + 224
10 CoreFoundation 0x37dbbf3b __CFRunLoopRun + 1291 + 1290
11 CoreFoundation 0x37d2eebd CFRunLoopRunSpecific + 357 + 356
12 CoreFoundation 0x37d2ed49 CFRunLoopRunInMode + 105 + 104
13 GraphicsServices 0x358e22eb GSEventRunModal + 75 + 74
14 UIKit 0x3a1b42f9 UIApplicationMain + 1121 + 1120
15 FireChat 0x43b3 main (main.m:8)
To me, it appears that the [NSDictionary valueForKey:] method is invoking [OTOverlayButton drawRect:] which comes from a third-party library. This shouldn't be possible -- am I reading the crash report wrong?
[OTOverlayButton drawRect:] isn't called anywhere in my code. Note that the dictionary contains (my) objects which contain pointers to objects from the third-party library.
The library vendor and I are both baffled.
Thanks.
I believe the cause of this crash was memory corruption resulting from calling performSelector: on a method that returned a struct. See this blog post for more details:
Why performSelector is more dangerous than I thought
My app crashed in the thread named com.apple.CFURLCACHE_work_queue and the crash logs doesn't seem to provide any clues for me to find a bug or mistake =(
Thread 10 name: Dispatch queue: com.apple.CFURLCACHE_work_queue
Thread 10 Crashed:
0 libsystem_kernel.dylib 0x32e93350 __pthread_kill + 8
1 libsystem_c.dylib 0x3b04011e pthread_kill + 54
2 libsystem_c.dylib 0x3b07c96e abort + 90
3 libc++abi.dylib 0x343ebd4a abort_message + 70
4 libc++abi.dylib 0x343e8ff4 default_terminate() + 20
5 libobjc.A.dylib 0x3559fa74 _objc_terminate() + 144
6 libc++abi.dylib 0x343e9078 safe_handler_caller(void (*)()) + 76
7 libc++abi.dylib 0x343e9110 std::terminate() + 16
8 libc++abi.dylib 0x343ea50e __cxa_throw + 118
9 libobjc.A.dylib 0x3559f9ba objc_exception_throw + 90
10 Foundation 0x34d42b60 _NSOutOfMemoryErrorHandler + 56
11 CoreFoundation 0x3725130a __CFDataHandleOutOfMemory + 90
12 CoreFoundation 0x37251458 __CFDataGrow + 288
13 CoreFoundation 0x371d6134 CFDataReplaceBytes + 360
14 CoreFoundation 0x371e3a9a CFDataAppendBytes + 82
15 CFNetwork 0x33150438 CopyAllDataFromDataArray(__CFArray const*) + 104
16 CFNetwork 0x331509ae __CFURLCache::ExecuteSQLInsert(_CFCachedURLResponse const*, __CFString const*, _CFURLRequest const*) + 370
17 CFNetwork 0x3314ec62 __CFURLCache::AddCachedResponseForRequest(__CFURLCacheNode*, _CFCachedURLResponse const*, _CFURLRequest const*) + 58
18 CFNetwork 0x3314eab8 __CFURLCache::ProcessCacheTasks0(bool) + 140
19 CFNetwork 0x3314ea1c __CFURLCache::ProcessCacheTasks(bool) + 32
20 CFNetwork 0x3314e8f0 __CFURLCache::_CFURLCacheTimerCallback0() + 280
21 CFNetwork 0x3314e7c8 __CFURLCache::_CFURLCacheTimerCallback(void*) + 28
22 libdispatch.dylib 0x35f86134 _dispatch_source_invoke$VARIANT$mp + 248
23 libdispatch.dylib 0x35f83e8e _dispatch_queue_drain$VARIANT$mp + 78
24 libdispatch.dylib 0x35f83dbc _dispatch_queue_invoke$VARIANT$mp + 36
25 libdispatch.dylib 0x35f8491a _dispatch_root_queue_drain + 182
26 libdispatch.dylib 0x35f84abc _dispatch_worker_thread2 + 80
27 libsystem_c.dylib 0x3b017a0e _pthread_wqthread + 358
28 libsystem_c.dylib 0x3b0178a0 start_wqthread + 4
any idea or clue of why this happens?
I guess it has something to do with NSURLCache, but I don't manipulate or even create that object in my app.
I'm using Xcode 4.5 GM - I know it's not publicly released yet - and AFNetworking 1.0RC3 for network communication and downloading image data
From the look of things in numbers 10 and 11, it ran out of memory and threw an exception, maybe as part of some kind of assertion.
You will probably find exception information in the console log for the device. If you can connect your device to your Mac, you can access this data in Xcode. Devices don't keep much console data, so it is best to get the log very soon after encountering the error.