UIWebView crashed in iOS 10 - swift
I am implementing the LinkedIn sign in using UIWebView
Here is my code
import UIKit
typealias LinkedInLoginCallBack = ([String:String]?,String,Error?) -> Void
class LinkedInWebViewController: UIViewController,UIWebViewDelegate {
#IBOutlet weak var linkedinWebView: UIWebView!
#IBOutlet weak var indicator: UIActivityIndicatorView!
var userDidLogin:LinkedInLoginCallBack!
let linkedInKey = "xxxx"
let linkedInSecret = "xxxx"
let authorizationEndPoint = "https://www.linkedin.com/uas/oauth2/authorization"
let accessTokenEndPoint = "https://www.linkedin.com/uas/oauth2/accessToken"
override func viewDidLoad() {
super.viewDidLoad()
linkedinWebView.delegate = self
self.startAuthorization()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func startAuthorization() {
let responseType = "code"
let redirectURL = "https://example.com/login/check-linkedin".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
let state = "xxxxx"
let scope = "r_basicprofile,r_emailaddress"
var authorizationURL = "\(authorizationEndPoint)?"
authorizationURL += "response_type=\(responseType)&"
authorizationURL += "client_id=\(linkedInKey)&"
authorizationURL += "redirect_uri=\(redirectURL)&"
authorizationURL += "state=\(state)&"
authorizationURL += "scope=\(scope)"
// logout already logined user or revoke tokens
logout()
// Create a URL request and load it in the web view.
let request = URLRequest(url: URL(string: authorizationURL)!)
linkedinWebView.loadRequest(request)
}
func logout(){
let revokeUrl = "https://api.linkedin.com/uas/oauth/invalidateToken"
let request = URLRequest(url: URL(string: revokeUrl)!)
linkedinWebView.loadRequest(request)
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
let url = request.url!
if url.host == "https://example.com/login/check-linkedin" {
if url.absoluteString.range(of: "code") != nil {
let urlParts = url.absoluteString.components(separatedBy: "?")
let code = urlParts[1].components(separatedBy: "=")[1]
requestForAccessToken(authorizationCode: code)
}
}
return true
}
func webViewDidStartLoad(_ webView: UIWebView) {
indicator.startAnimating()
}
func webViewDidFinishLoad(_ webView: UIWebView) {
indicator.stopAnimating()
}
func requestForAccessToken(authorizationCode: String) {
let grantType = "authorization_code"
let redirectURL = "https://example.com/login/check-linkedin".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
// Set the POST parameters.
var postParams = "grant_type=\(grantType)&"
postParams += "code=\(authorizationCode)&"
postParams += "redirect_uri=\(redirectURL)&"
postParams += "client_id=\(linkedInKey)&"
postParams += "client_secret=\(linkedInSecret)"
// Convert the POST parameters into a NSData object.
let postData = postParams.data(using: String.Encoding.utf8)
// Initialize a mutable URL request object using the access token endpoint URL string.
let request = NSMutableURLRequest(url: NSURL(string: accessTokenEndPoint)! as URL)
// Indicate that we're about to make a POST request.
request.httpMethod = "POST"
// Set the HTTP body using the postData object created above.
request.httpBody = postData
// Add the required HTTP header field.
request.addValue("application/x-www-form-urlencoded;", forHTTPHeaderField: "Content-Type")
// Initialize a NSURLSession object.
let session = URLSession(configuration: URLSessionConfiguration.default)
// Make the request.
let task: URLSessionDataTask = session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
// Get the HTTP status code of the request.
let statusCode = (response as! HTTPURLResponse).statusCode
if statusCode == 200 {
// Convert the received JSON data into a dictionary.
do {
let dataDictionary = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
print("dataDictionary\(dataDictionary)")
let accessToken = dataDictionary["access_token"] as! String
var socialAuth:[String:String] = [String:String]()
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_TYPE] = SocialMediaType.instagram.rawValue
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_ID] = dataDictionary["username"] as? String
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_TOKEN] = accessToken
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_RTOKEN] = accessToken
socialAuth["name"] = dataDictionary["full_name"] as? String
socialAuth["email"] = dataDictionary["username"] as? String
self.userDidLogin(socialAuth,accessToken,nil)
DispatchQueue.main.async {
self.dismiss(animated: true, completion: nil)
}
} catch {
print("Could not convert JSON data into a dictionary.")
}
}else{
print("cancel clicked")
}
}
task.resume()
}
}
But don't know it crashes my app after some time because of the below error
thread #20, name = 'WebThread', stop reason = EXC_BAD_ACCESS (code=1, address=0x2ffffff6b)
Here it is my stack trace
(lldb) bt
* thread #16, name = 'WebThread', stop reason = EXC_BAD_ACCESS (code=1, address=0x2ffffff6b)
* frame #0: 0x000000018fda66e4 JavaScriptCore`llint_entry + 15716
frame #1: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #2: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #3: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #4: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #5: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #6: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #7: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #8: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #9: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #10: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #11: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #12: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #13: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #14: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #15: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #16: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #17: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #18: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #19: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #20: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #21: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #22: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #23: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #24: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #25: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #26: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #27: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #28: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #29: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #30: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #31: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #32: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #33: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #34: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #35: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #36: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #37: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #38: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #39: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #40: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #41: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #42: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #43: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #44: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #45: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #46: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #47: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #48: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #49: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #50: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #51: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #52: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #53: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #54: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #55: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #56: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #57: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #58: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #59: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #60: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #61: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #62: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #63: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #64: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #65: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #66: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #67: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #68: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #69: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #70: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #71: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #72: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #73: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #74: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #75: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #76: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #77: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #78: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #79: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #80: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #81: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #82: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #83: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #84: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #85: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #86: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #87: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #88: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #89: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #90: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #91: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #92: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #93: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #94: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #95: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #96: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #97: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #98: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #99: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #100: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #101: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #102: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #103: 0x000000018f93a2a8 JavaScriptCore`JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 164
frame #104: 0x0000000190340a10 WebCore`WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 992
frame #105: 0x00000001906748d8 WebCore`WebCore::EventTarget::fireEventListeners(WebCore::Event&, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul>&) + 620
frame #106: 0x0000000190674588 WebCore`WebCore::EventTarget::fireEventListeners(WebCore::Event&) + 328
frame #107: 0x000000019067442c WebCore`WebCore::EventTarget::dispatchEvent(WebCore::Event&) + 108
frame #108: 0x00000001906743ac WebCore`WebCore::EventTarget::dispatchEventForBindings(WebCore::Event*, int&) + 116
frame #109: 0x00000001909eb22c WebCore`WebCore::jsEventTargetPrototypeFunctionDispatchEvent(JSC::ExecState*) + 260
frame #110: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #111: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #112: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #113: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #114: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #115: 0x000000018f6b0480 JavaScriptCore`JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*) + 13724
frame #116: 0x000000018f9936f4 JavaScriptCore`JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr<JSC::Exception>&) + 440
frame #117: 0x0000000190ec88a0 WebCore`WebCore::ScriptController::evaluateInWorld(WebCore::ScriptSourceCode const&, WebCore::DOMWrapperWorld&, WebCore::ExceptionDetails*) + 328
frame #118: 0x0000000190224c84 WebCore`WebCore::ScriptElement::executeScript(WebCore::ScriptSourceCode const&) + 612
frame #119: 0x00000001902a0448 WebCore`WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent(WebCore::PendingScript&) + 212
frame #120: 0x000000019026b5a8 WebCore`WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing() + 88
frame #121: 0x000000019078b53c WebCore`non-virtual thunk to WebCore::HTMLDocumentParser::notifyFinished(WebCore::CachedResource*) + 52
frame #122: 0x000000019029d8b8 WebCore`WebCore::CachedResource::checkNotify() + 448
frame #123: 0x000000019029d59c WebCore`WebCore::SubresourceLoader::didFinishLoading(double) + 1020
frame #124: 0x000000018c00e788 CFNetwork`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 80
frame #125: 0x000000018c00e718 CFNetwork`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 200
frame #126: 0x000000018c00e88c CFNetwork`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56
frame #127: 0x000000018bf393dc CFNetwork`___ZN27URLConnectionClient_Classic23_delegate_cacheTrifectaEPK20_CFCachedURLResponseU13block_pointerFvvE_block_invoke + 576
frame #128: 0x000000018bf34960 CFNetwork`___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 108
frame #129: 0x00000001033e921c libdispatch.dylib`_dispatch_client_callout + 16
frame #130: 0x00000001033f3c9c libdispatch.dylib`_dispatch_block_invoke_direct + 400
frame #131: 0x000000018bfebeb4 CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 36
frame #132: 0x000000018b6a79a8 CoreFoundation`CFArrayApplyFunction + 68
frame #133: 0x000000018bfebd98 CFNetwork`RunloopBlockContext::perform() + 136
frame #134: 0x000000018bfed0c0 CFNetwork`MultiplexerSource::perform() + 312
frame #135: 0x000000018bfece2c CFNetwork`MultiplexerSource::_perform(void*) + 64
frame #136: 0x000000018b77c278 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #137: 0x000000018b77bbc0 CoreFoundation`__CFRunLoopDoSources0 + 524
frame #138: 0x000000018b7797c0 CoreFoundation`__CFRunLoopRun + 804
frame #139: 0x000000018b6a8048 CoreFoundation`CFRunLoopRunSpecific + 444
frame #140: 0x000000019025845c WebCore`RunWebThread(void*) + 456
frame #141: 0x000000018a864850 libsystem_pthread.dylib`_pthread_body + 240
frame #142: 0x000000018a864760 libsystem_pthread.dylib`_pthread_start + 284
frame #143: 0x000000018a861dac libsystem_pthread.dylib`thread_start + 4
Related
Webrtc Swift - Thread 1: EXC_BAD_ACCESS (code=1, address=0xd000000000000040)
I am using Janus videoroom with Webrtc. Everything working fine. But when i go for ending call. And dismiss the current view controller - App Crashed. I am unable to get the point of crashing so i can resolve. the current view disappeared fine also. Logs shows this: callDropButton Clicked Videoroom viewDidDisappear Videoroom screen dismissed completely I am getting the crash at this 1st line of Appdelegate: class AppDelegate: UIResponder, UIApplicationDelegate { I am also attaching backtrace logs for more info. But this is not making any sence to me: (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xd000000000000040) frame #0: 0x00000001012e0024 WebRTC`___lldb_unnamed_symbol6199$$WebRTC + 120 frame #1: 0x00000001013c70f0 WebRTC`___lldb_unnamed_symbol12553$$WebRTC + 44 frame #2: 0x00000001013c7078 WebRTC`___lldb_unnamed_symbol12551$$WebRTC + 128 frame #3: 0x00000001013c6964 WebRTC`___lldb_unnamed_symbol12523$$WebRTC + 12 frame #4: 0x00000001013c6944 WebRTC`___lldb_unnamed_symbol12521$$WebRTC + 52 frame #5: 0x00000001012e16b0 WebRTC`___lldb_unnamed_symbol6278$$WebRTC + 36 frame #6: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148 frame #7: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68 frame #8: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16 frame #9: 0x00000001012f343c WebRTC`___lldb_unnamed_symbol6908$$WebRTC + 328 frame #10: 0x000000010050c8b0 Interpret`outlined destroy of RTCVideoTrack? at <compiler-generated>:0 frame #11: 0x00000001005346ec Interpret`#objc ConnectionViewController.__ivar_destroyer(self=0x0000000154016800) at ConnectionViewController.swift:0 frame #12: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148 frame #13: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68 frame #14: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16 frame #15: 0x00000001d04a5de8 UIKitCore`-[UIResponder dealloc] + 152 frame #16: 0x00000001cfeced0c UIKitCore`-[UIViewController dealloc] + 1748 frame #17: 0x00000001cfe07594 UIKitCore`-[UIPresentationController .cxx_destruct] + 372 frame #18: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148 frame #19: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68 frame #20: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16 frame #21: 0x00000001cfe030fc UIKitCore`-[UIPresentationController dealloc] + 60 frame #22: 0x00000001cfe08d5c UIKitCore`-[_UIFullscreenPresentationController dealloc] + 60 frame #23: 0x00000001a3ff7a44 libsystem_blocks.dylib`_Block_release + 152 frame #24: 0x00000001cfefbaf8 UIKitCore`-[_UIViewControllerTransitionContext .cxx_destruct] + 116 frame #25: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148 frame #26: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68 frame #27: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16 frame #28: 0x00000001cfefa3f8 UIKitCore`-[_UIViewControllerTransitionContext dealloc] + 60 frame #29: 0x00000001cfefbbb0 UIKitCore`-[_UIViewControllerOneToOneTransitionContext dealloc] + 84 frame #30: 0x00000001a37357cc libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 148 frame #31: 0x00000001a37456b8 libobjc.A.dylib`objc_destructInstance + 68 frame #32: 0x00000001a3745720 libobjc.A.dylib`object_dispose + 16 frame #33: 0x00000001a3ff7a44 libsystem_blocks.dylib`_Block_release + 152 frame #34: 0x00000001a444ca38 CoreFoundation`-[__NSSingleObjectArrayI dealloc] + 44 frame #35: 0x00000001d04870e8 UIKitCore`_runAfterCACommitDeferredBlocks + 356 frame #36: 0x00000001d0475bfc UIKitCore`_cleanUpAfterCAFlushAndRunDeferredBlocks + 352 frame #37: 0x00000001d04a2a6c UIKitCore`_afterCACommitHandler + 116 frame #38: 0x00000001a44ef4fc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32 frame #39: 0x00000001a44ea224 CoreFoundation`__CFRunLoopDoObservers + 412 frame #40: 0x00000001a44ea7a0 CoreFoundation`__CFRunLoopRun + 1228 frame #41: 0x00000001a44e9fb4 CoreFoundation`CFRunLoopRunSpecific + 436 frame #42: 0x00000001a66eb79c GraphicsServices`GSEventRunModal + 104 frame #43: 0x00000001d047bc38 UIKitCore`UIApplicationMain + 212 * frame #44: 0x0000000100522d7c Interpret`main at AppDelegate.swift:13:7 frame #45: 0x00000001a3fad8e0 libdyld.dylib`start + 4
Make sure you have something like this in your deinit ("screen dismissed completely"?): rtcAudioSession.remove(self) peerConnection.close() [localAudioTrack, localVideoTrack, remoteAudioTrack, remoteVideoTrack, ].forEach { track in track.isEnabled = false } Check on every WebRTC object you've created, if the class have something like close(), isEnabled = false, etc, you should call it in deinit. According to your crashlog, the problem is in one of RTCVideoTrack objects. Try commenting out all the code that creates any of the RTCVideoTrack and see if that helps. If it helps, uncomment them out one by one to determine which one is causing the problem.
Why does my app keep crashing since iOS 13?
My problem is that my app has been crashing since iOS 13. The app doesn't work on any iPhone anymore. A bit strange, however, is that the iPhone simulators on iOS 13 all work fine. Here is the output of the lldb console after I type bt: * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x48) frame #0: 0x00000001b952d268 AVFAudio`-[AVAudioPlayer(AVAudioPlayerPriv) privRemoveSessionListener] + 16 frame #1: 0x00000001b952b9ac AVFAudio`-[AVAudioPlayer dealloc] + 32 frame #2: 0x0000000100dae9e4 Ducko`#objc StartView.__ivar_destroyer(self=0x0000000101e2de70) at startView.swift:0 frame #3: 0x00000001ac8c01e8 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 112 frame #4: 0x00000001ac8d2d14 libobjc.A.dylib`objc_destructInstance + 88 frame #5: 0x00000001ac8d9db8 libobjc.A.dylib`_objc_rootDealloc + 48 frame #6: 0x00000001b0bd19b8 UIKitCore`-[UIResponder dealloc] + 152 frame #7: 0x00000001e1a40900 UIKit`-[UIResponderAccessibility dealloc] + 60 frame #8: 0x00000001c528e93c SpriteKit`-[SKNode dealloc] + 100 frame #9: 0x00000001c52461dc SpriteKit`-[SKScene dealloc] + 332 frame #10: 0x00000001c526bf54 SpriteKit`-[SKView _update:] + 568 frame #11: 0x00000001c526761c SpriteKit`__51-[SKView _vsyncRenderForTime:preRender:postRender:]_block_invoke.340 + 388 frame #12: 0x00000001c5266a1c SpriteKit`-[SKView _vsyncRenderForTime:preRender:postRender:] + 520 frame #13: 0x00000001c5269bd0 SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 200 frame #14: 0x00000001c52ac180 SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 132 frame #15: 0x0000000101c715f8 GPUToolsCore`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168 frame #16: 0x00000001b33dd514 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 632 frame #17: 0x00000001b34a7774 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 264 frame #18: 0x00000001acaed6d4 CoreFoundation`__CFMachPortPerform + 172 frame #19: 0x00000001acb16e5c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56 frame #20: 0x00000001acb16588 CoreFoundation`__CFRunLoopDoSource1 + 444 frame #21: 0x00000001acb1145c CoreFoundation`__CFRunLoopRun + 2168 frame #22: 0x00000001acb108bc CoreFoundation`CFRunLoopRunSpecific + 464 frame #23: 0x00000001b697b328 GraphicsServices`GSEventRunModal + 104 frame #24: 0x00000001b0ba56d4 UIKitCore`UIApplicationMain + 1936 * frame #25: 0x0000000100d777c8 Ducko`main at AppDelegate.swift:14:7 frame #26: 0x00000001ac99b460 libdyld.dylib`start + 4 (lldb) * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x48) frame #0: 0x00000001b952d268 AVFAudio`-[AVAudioPlayer(AVAudioPlayerPriv) privRemoveSessionListener] + 16 frame #1: 0x00000001b952b9ac AVFAudio`-[AVAudioPlayer dealloc] + 32 frame #2: 0x0000000100dae9e4 Ducko`#objc StartView.__ivar_destroyer(self=0x0000000101e2de70) at startView.swift:0 frame #3: 0x00000001ac8c01e8 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 112 frame #4: 0x00000001ac8d2d14 libobjc.A.dylib`objc_destructInstance + 88 frame #5: 0x00000001ac8d9db8 libobjc.A.dylib`_objc_rootDealloc + 48 frame #6: 0x00000001b0bd19b8 UIKitCore`-[UIResponder dealloc] + 152 frame #7: 0x00000001e1a40900 UIKit`-[UIResponderAccessibility dealloc] + 60 frame #8: 0x00000001c528e93c SpriteKit`-[SKNode dealloc] + 100 frame #9: 0x00000001c52461dc SpriteKit`-[SKScene dealloc] + 332 frame #10: 0x00000001c526bf54 SpriteKit`-[SKView _update:] + 568 frame #11: 0x00000001c526761c SpriteKit`__51-[SKView _vsyncRenderForTime:preRender:postRender:]_block_invoke.340 + 388 frame #12: 0x00000001c5266a1c SpriteKit`-[SKView _vsyncRenderForTime:preRender:postRender:] + 520 frame #13: 0x00000001c5269bd0 SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 200 frame #14: 0x00000001c52ac180 SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 132 frame #15: 0x0000000101c715f8 GPUToolsCore`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168 frame #16: 0x00000001b33dd514 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 632 frame #17: 0x00000001b34a7774 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 264 frame #18: 0x00000001acaed6d4 CoreFoundation`__CFMachPortPerform + 172 frame #19: 0x00000001acb16e5c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56 frame #20: 0x00000001acb16588 CoreFoundation`__CFRunLoopDoSource1 + 444 frame #21: 0x00000001acb1145c CoreFoundation`__CFRunLoopRun + 2168 frame #22: 0x00000001acb108bc CoreFoundation`CFRunLoopRunSpecific + 464 frame #23: 0x00000001b697b328 GraphicsServices`GSEventRunModal + 104 frame #24: 0x00000001b0ba56d4 UIKitCore`UIApplicationMain + 1936 * frame #25: 0x0000000100d777c8 Ducko`main at AppDelegate.swift:14:7 frame #26: 0x00000001ac99b460 libdyld.dylib`start + 4 Does anyone have any idea how to fix the problem? I don't know where to start.
How can I prevent the app from crashing after pausing the audio?
my problem is that my app crashes after pausing the audio. Thread 1: EXC_BAD_ACCESS (code=1, address=0x48) The sound is played as follows: var audioPlayer = AVAudioPlayer() var jumpAudio: URL? var coinAudio: URL? ... duck.run(SKAction.playSoundFileNamed("coin", waitForCompletion: true)) I pause the sound in another class by calling this function in the GameScene: func setAudioOn(pOn: Bool) { if pOn == true { audioPlayer.play() } else if pOn == false { audioPlayer.pause() } } Thank you in advance EDIT (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x48) frame #0: 0x00007fff20a2f58a AVFAudio`-[AVAudioPlayer pause] + 8 * frame #1: 0x000000010904711d Ducko`GameScene.setAudioOn(pOn=false, self=0x00007f91a9869e00) at GameScene.swift:1305:25 frame #2: 0x000000010905ca3b Ducko`SettingsView.touchesBegan(touches=Swift.Set<UIKit.UITouch> # 0x00007ffee6bf7838, event=0x00006000008afe70, self=0x00007f91a8d218d0) at settingsView.swift:124:27 frame #3: 0x000000010905cb18 Ducko`#objc SettingsView.touchesBegan(_:with:) at <compiler-generated>:0 frame #4: 0x00007fff2bfc519e SpriteKit`-[SKView touchesBegan:withEvent:] + 1090 frame #5: 0x00007fff46d9150e UIKitCore`-[UIWindow _sendTouchesForEvent:] + 1867 frame #6: 0x00007fff46d930f6 UIKitCore`-[UIWindow sendEvent:] + 4596 frame #7: 0x00007fff46d6e93b UIKitCore`-[UIApplication sendEvent:] + 356 frame #8: 0x00007fff46dede77 UIKitCore`__dispatchPreprocessedEventFromEventQueue + 6847 frame #9: 0x00007fff46df093d UIKitCore`__handleEventQueueInternal + 5980 frame #10: 0x00007fff23ac4241 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 frame #11: 0x00007fff23ac416c CoreFoundation`__CFRunLoopDoSource0 + 76 frame #12: 0x00007fff23ac3944 CoreFoundation`__CFRunLoopDoSources0 + 180 frame #13: 0x00007fff23abe64f CoreFoundation`__CFRunLoopRun + 1263 frame #14: 0x00007fff23abde36 CoreFoundation`CFRunLoopRunSpecific + 438 frame #15: 0x00007fff37f64bb0 GraphicsServices`GSEventRunModal + 65 frame #16: 0x00007fff46d562a3 UIKitCore`UIApplicationMain + 1621 frame #17: 0x000000010905f27b Ducko`main at AppDelegate.swift:12:7 frame #18: 0x00007fff51175cf5 libdyld.dylib`start + 1 frame #19: 0x00007fff51175cf5 libdyld.dylib`start + 1
SIGABRT in Macos application
I'm getting a SIGBART signal after the application is running a while. I suspect that it is related to timer which is running in the background. This is the code I'm using to invoke the recurrent timer: Timer.scheduledTimer(timeInterval: 20 , target: self, selector: #selector(self.scheduledEventHandler), userInfo: nil, repeats: true) And this is the handler: #objc func scheduledEventHandler() { print("got event") } And lastly, this is the stacktrace: thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x00007fff5182cfce libsystem_kernel.dylib`__pthread_kill + 10 frame #1: 0x0000000100fbb1b4 libsystem_pthread.dylib`pthread_kill + 333 frame #2: 0x00007fff5178930a libsystem_c.dylib`abort + 127 frame #3: 0x00007fff4f76bf8f libc++abi.dylib`abort_message + 245 frame #4: 0x00007fff4f76c12b libc++abi.dylib`default_terminate_handler() + 265 frame #5: 0x00007fff50af0eab libobjc.A.dylib`_objc_terminate() + 105 frame #6: 0x00007fff4f7877c9 libc++abi.dylib`std::__terminate(void (*)()) + 8 frame #7: 0x00007fff4f787478 libc++abi.dylib`__cxa_rethrow + 99 frame #8: 0x00007fff50aef139 libobjc.A.dylib`objc_exception_rethrow + 40 frame #9: 0x00007fff2a0f703e CoreFoundation`CFRunLoopRunSpecific + 638 frame #10: 0x00007fff29416866 HIToolbox`RunCurrentEventLoopInMode + 286 frame #11: 0x00007fff294165d6 HIToolbox`ReceiveNextEventCommon + 613 frame #12: 0x00007fff29416354 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64 frame #13: 0x00007fff27713a23 AppKit`_DPSNextEvent + 2085 frame #14: 0x00007fff27ea8e6c AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044 frame #15: 0x00007fff27708831 AppKit`-[NSApplication run] + 764 frame #16: 0x00007fff276d79d2 AppKit`NSApplicationMain + 804 frame #17: 0x0000000100034d2d App`main at AppDelegate.swift:15 frame #18: 0x00007fff516dd145 libdyld.dylib`start + 1 frame #19: 0x00007fff516dd145 libdyld.dylib`start + 1 *Please note, that this task works well most of the time (crashes rarely). I'll appreciate any suggestions to better understand the cause of such crash.
What is differance between the UIAlertView's from IOS 5 to IOS 6. In My IOS 6 all server side validation messages are not working
What is differance between the UIAlertView's from IOS 5 to IOS 6. In My IOS 6 all server side validation messages are not working..if We click on the Alert Button App is crash. I need Help On this. (lldb) bt:(after bt got this log) * thread #1: tid = 0x1c03, 0x0294209b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=1, address=0x80000008) frame #0: 0x0294209b libobjc.A.dylib`objc_msgSend + 15 frame #1: 0x01fc9020 UIKit`-[UIAlertView(Private) _buttonClicked:] + 294 frame #2: 0x02944705 libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 77 frame #3: 0x01bd9920 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96 frame #4: 0x01bd98b8 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 frame #5: 0x01c9a671 UIKit`-[UIControl sendAction:to:forEvent:] + 66 frame #6: 0x01c9abcf UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578 frame #7: 0x01c99d38 UIKit`-[UIControl touchesEnded:withEvent:] + 546 frame #8: 0x01c0933f UIKit`-[UIWindow _sendTouchesForEvent:] + 846 frame #9: 0x01c09552 UIKit`-[UIWindow sendEvent:] + 273 frame #10: 0x01be73aa UIKit`-[UIApplication sendEvent:] + 436 frame #11: 0x01bd8cf8 UIKit`_UIApplicationHandleEvent + 9874 frame #12: 0x035fedf9 GraphicsServices`_PurpleEventCallback + 339 frame #13: 0x035fead0 GraphicsServices`PurpleEventCallback + 46 frame #14: 0x02e89bf5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53 frame #15: 0x02e89962 CoreFoundation`__CFRunLoopDoSource1 + 146 frame #16: 0x02ebabb6 CoreFoundation`__CFRunLoopRun + 2118 frame #17: 0x02eb9f44 CoreFoundation`CFRunLoopRunSpecific + 276 frame #18: 0x02eb9e1b CoreFoundation`CFRunLoopRunInMode + 123 frame #19: 0x035fd7e3 GraphicsServices`GSEventRunModal + 88 frame #20: 0x035fd668 GraphicsServices`GSEventRun + 104 frame #21: 0x01bd665c UIKit`UIApplicationMain + 1211 frame #22: 0x0000255d mobiletummy`main + 125 at main.m:14 frame #23: 0x00002495 mobiletummy`start + 53
Have got the same problem. Throwing UIAlert on main thread resolved the thing for me. But on ur log stack it seems that you are already one the main thread.