title: crash in cordova app running on ios
body: <p>A year ago, we've developed an app running on IPad. User can edit and scroll through multiple page forms. Within each page there are several input fields, labels and images. Now we are porting the app to IOS 10. We are using cordova, ionic and AngularJS.</p>
  
  <p>Now we have some weird crashes also on IOS 9.3.5. After scrolling a while through the pages of the form, which means that a lot of input fields and labels are created and deleted, the Application crashes (sometimes it only freezes and shows white screen). </p>
  
  <p>Most of the time it crashes in Thread 0 (Dispatch queue: com.apple.main-thread) with a segmentation fault. A few time I had a crash in thread 3 (WebThread) with a similar stack trace.</p>
  
  <p>My idea is that one thread frees memory that is still used by the other thread. Can anybody give me a hint where to look for the problem? Does anybody have a similar problem and solved it? Since the crash happens deeply in the webKit code it might be a problem within cordova or ios?</p>
  
  <p>Versions of used components:</p>
  
  <pre><code>XCode: 8.0
  Cordova CLI: 5.4.1
  Gulp version:  CLI version 3.9.0
  Gulp local:   Local version 3.9.0
  Ionic Version: 1.1.1
  Ionic CLI Version: 1.7.13
  Ionic App Lib Version: 0.6.5
  OS: Distributor ID: Fedora Description: Fedora release 23 (Twenty Three) 
  Node Version: v0.10.42
  </code></pre>
  
  <p>The IOS crash log:</p>
  
  <pre><code>Incident Identifier: AAE0FFAD-F9BB-4D8D-AB30-1BCCE2BCB0EE
  CrashReporter Key:   9e09392dd3be7bec6a92955b1797ddd5a45bc167
  Hardware Model:      iPad2,4
  Process:             mobileforms [299]
  Path:                /private/var/containers/Bundle/Application/682882E8-F9E4-4CCA-BC7F-0AE8C18647FC/mobileforms.app/mobileforms
  Identifier:          de.skai-ms.mobileforms
  Version:             3.3.1 (3.3)
  Code Type:           ARM (Native)
  Parent Process:      launchd [1]
  
  Date/Time:           2016-11-16 21:13:28.28 +0100
  Launch Time:         2016-11-16 20:53:04.04 +0100
  OS Version:          iOS 9.3.5 (13G36)
  Report Version:      104
  
  Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
  Exception Subtype: KERN_INVALID_ADDRESS at 0xbbadbeef
  Triggered by Thread:  0
  
  Thread 0 name:
  Thread 0 Crashed:
  0   JavaScriptCore                  0x25c8ea22 WTFCrash + 54 (Assertions.cpp:321)
  1   WebCore                         0x25f471d0 WTF::StringAppend&lt;WTF::String, WTF::String&gt;::operator WTF::String() const + 104 (StringOperators.h:40)
  2   WebCore                         0x26926172 WebCore::TextResourceDecoder::decodeAndFlush(char const*, unsigned long) + 110 (TextResourceDecoder.cpp:676)
  3   WebCore                         0x25ebee90 WebCore::CachedScript::script() + 48 (CachedScript.cpp:75)
  4   JavaScriptCore                  0x25c7bcc4 std::__1::unique_ptr&lt;JSC::FunctionNode, std::__1::default_delete&lt;JSC::FunctionNode&gt; &gt; JSC::parse&lt;JSC::FunctionNode&gt;(JSC::VM*, JSC::SourceCode const&amp;, JSC::FunctionParameters*, JSC::Identifier const&amp;, JSC::JSParserBuiltinMode, JSC::JSParserStrictMode, JSC::JSParserCodeType, JSC::ParserError&amp;, JSC::JSTextPosition*, JSC::ConstructorKind, JSC::ThisTDZMode) + 28 (Parser.h:1069)
  5   JavaScriptCore                  0x25c7b49e JSC::UnlinkedFunctionExecutable::codeBlockFor(JSC::VM&amp;, JSC::SourceCode const&amp;, JSC::CodeSpecializationKind, JSC::DebuggerMode, JSC::ProfilerMode, JSC::ParserError&amp;) + 90 (UnlinkedCodeBlock.cpp:62)
  6   JavaScriptCore                  0x25ae5d62 JSC::ScriptExecutable::newCodeBlockFor(JSC::CodeSpecializationKind, JSC::JSFunction*, JSC::JSScope*, JSC::JSObject*&amp;) + 378 (Executable.cpp:240)
  7   JavaScriptCore                  0x25ae629a JSC::ScriptExecutable::prepareForExecutionImpl(JSC::ExecState*, JSC::JSFunction*, JSC::JSScope*, JSC::CodeSpecializationKind) + 98 (Executable.cpp:330)
  8   JavaScriptCore                  0x25932952 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;) + 162 (Executable.h:408)
  9   JavaScriptCore                  0x25a0ca86 JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;) + 62 (CallData.cpp:39)
  10  WebCore                         0x25fd91e2 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 490 (JSMainThreadExecState.h:56)
  11  WebCore                         0x262256b4 WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector&lt;WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul&gt;&amp;) + 532 (EventTarget.cpp:256)
  12  WebCore                         0x25f1f61c WebCore::EventTarget::fireEventListeners(WebCore::Event*) + 232 (EventTarget.cpp:208)
  13  WebCore                         0x2621d4b0 WebCore::EventContext::handleLocalEvents(WebCore::Event&amp;) const + 64 (EventContext.cpp:55)
  14  WebCore                         0x2621dd04 WebCore::EventDispatcher::dispatchEvent(WebCore::Node*, WTF::PassRefPtr&lt;WebCore::Event&gt;) + 732 (EventDispatcher.cpp:307)
  15  WebCore                         0x25f1f46c WebCore::Node::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;) + 20 (Node.cpp:2015)
  16  WebCore                         0x25fd8fbe WebCore::EventTarget::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;, int&amp;) + 78 (EventTarget.cpp:154)
  17  WebCore                         0x25ff59ae WebCore::jsNodePrototypeFunctionDispatchEvent(JSC::ExecState*) + 94 (JSNode.cpp:890)
  18  JavaScriptCore                  0x25beb41e llint_entry + 21374
  19  JavaScriptCore                  0x25beafe8 llint_entry + 20296
  20  JavaScriptCore                  0x25beafe8 llint_entry + 20296
  21  JavaScriptCore                  0x25beb038 llint_entry + 20376
  22  JavaScriptCore                  0x25beb038 llint_entry + 20376
  23  JavaScriptCore                  0x25be5e90 vmEntryToJavaScript + 336
  24  JavaScriptCore                  0x25b407da JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 102 (JITCode.cpp:81)
  25  JavaScriptCore                  0x25932a08 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;) + 344 (Interpreter.cpp:973)
  26  JavaScriptCore                  0x25a0ca86 JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;) + 62 (CallData.cpp:39)
  27  WebCore                         0x25fd91e2 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 490 (JSMainThreadExecState.h:56)
  28  WebCore                         0x262256b4 WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector&lt;WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul&gt;&amp;) + 532 (EventTarget.cpp:256)
  29  WebCore                         0x25f1f61c WebCore::EventTarget::fireEventListeners(WebCore::Event*) + 232 (EventTarget.cpp:208)
  30  WebCore                         0x2621d4b0 WebCore::EventContext::handleLocalEvents(WebCore::Event&amp;) const + 64 (EventContext.cpp:55)
  31  WebCore                         0x2621dd04 WebCore::EventDispatcher::dispatchEvent(WebCore::Node*, WTF::PassRefPtr&lt;WebCore::Event&gt;) + 732 (EventDispatcher.cpp:307)
  32  WebCore                         0x25f1f46c WebCore::Node::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;) + 20 (Node.cpp:2015)
  33  WebCore                         0x25fd8fbe WebCore::EventTarget::dispatchEvent(WTF::PassRefPtr&lt;WebCore::Event&gt;, int&amp;) + 78 (EventTarget.cpp:154)
  34  WebCore                         0x26221854 WebCore::EventHandler::dispatchTouchEvent(WebCore::PlatformTouchEvent const&amp;, WTF::AtomicString const&amp;, WTF::HashMap&lt;WebCore::EventTarget*, WTF::Vector&lt;WTF::RefPtr&lt;WebCore::Touch&gt;, 0ul, WTF::CrashOnOverflow, 16ul&gt;*, WTF::PtrHash&lt;WebCore::EventTarget*&gt;, WTF::HashTraits&lt;WebCore::EventTarget*&gt;, WTF::HashTraits&lt;WTF::Vector&lt;WTF::RefPtr&lt;WebCore::Touch&gt;, 0ul, WTF::CrashOnOverflow, 16ul&gt;*&gt; &gt; const&amp;, float, float) + 852 (EventHandlerIOSTouch.cpp:92)
  35  WebCore                         0x25fd72d8 WebCore::EventHandler::handleTouchEvent(WebCore::PlatformTouchEvent const&amp;) + 4844 (EventHandlerIOSTouch.cpp:449)
  36  WebCore                         0x25fd5850 WebCore::EventHandler::touchEvent(WebEvent*) + 236 (EventHandlerIOS.mm:120)
  37  WebKitLegacy                    0x26b15008 -[WebHTMLView touch:] + 136 (WebHTMLView.mm:3886)
  38  WebCore                         0x25fd5760 -[WAKView _selfHandleEvent:] + 136 (WAKView.mm:165)
  39  WebCore                         0x25fd56bc -[WAKView handleEvent:] + 48 (WAKView.mm:125)
  40  WebCore                         0x25fd5488 -[WAKWindow sendEventSynchronously:] + 332 (WAKWindow.mm:336)
  41  UIKit                           0x2743a522 -[UIWebBrowserView _dispatchWebEvent:] + 78 (UIWebBrowserView.m:1357)
  42  UIKit                           0x2743a948 -[UIWebBrowserView _webTouchEventsRecognized:] + 512 (UIWebBrowserView.m:1464)
  43  UIKit                           0x27215a34 -[UIWebTouchEventsGestureRecognizer _processTouches:withEvent:type:] + 356 (UIWebTouchEventsGestureRecognizer.m:329)
  44  UIKit                           0x27215ce2 -[UIWebTouchEventsGestureRecognizer touchesEnded:withEvent:] + 78 (UIWebTouchEventsGestureRecognizer.m:393)
  45  UIKit                           0x27315646 -[UIGestureRecognizer _touchesEnded:withEvent:] + 146 (UIGestureRecognizer.m:1812)
  46  UIKit                           0x26de2d84 -[UIWindow _sendGesturesForEvent:] + 580 (UIWindow.m:2047)
  47  UIKit                           0x26de267a -[UIWindow sendEvent:] + 622 (UIWindow.m:2256)
  48  UIKit                           0x26db3124 -[UIApplication sendEvent:] + 204 (UIApplication.m:12647)
  49  UIKit                           0x26db16d2 _UIApplicationHandleEventQueue + 5010 (UIApplication.m:10454)
  50  CoreFoundation                  0x227f9dfe __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14 (CFRunLoop.c:1761)
  51  CoreFoundation                  0x227f99ec __CFRunLoopDoSources0 + 452 (CFRunLoop.c:1807)
  52  CoreFoundation                  0x227f7d5a __CFRunLoopRun + 794 (CFRunLoop.c:2536)
  53  CoreFoundation                  0x22747228 CFRunLoopRunSpecific + 520 (CFRunLoop.c:2814)
  54  CoreFoundation                  0x22747014 CFRunLoopRunInMode + 108 (CFRunLoop.c:2844)
  55  GraphicsServices                0x23d37ac8 GSEventRunModal + 160 (GSEvent.c:2245)
  56  UIKit                           0x26e1b188 UIApplicationMain + 144 (UIApplication.m:3772)
  57  mobileforms                     0x000b2e82 main + 34 (main.m:32)
  58  libdyld.dylib                   0x223ef872 start + 2 (start_glue.s:64)
  </code></pre>
  
  <p>We've made some investigations and found on <a href="https://developer.apple.com/reference/webkit/wkwebview" rel="nofollow noreferrer">https://developer.apple.com/reference/webkit/wkwebview</a> that Apps should use WKWebView instead of UIWebView. By default cordova uses UIWebView but offers a plugin for WKWebView.</p>
  
  <p>Our next step would be to port the app to the new cordova and the WKWebView plugin. Does anybody has experience with that?</p>