DevDmitryHub / cordova-plugin-appsflyer

AppsFlyer plugin for Cordova (Phonegap)
3 stars 2 forks source link

App crashes on first launch ios 9.2 #3

Closed SreeharshaJois closed 8 years ago

SreeharshaJois commented 8 years ago

Precondition: Make sure that app is not installed on the device.

Test environment details: cordova-ios-4.0.1 cordova:6.1.1 appsflyer plugin version:4.0.1

Steps to reproduce: 1.Install app from itunes/xcode 2.Open the app

Issue seen: App is crashing only on first time launch in iOS 9.2. Subsequent launch crash is not seen. This issue can be found in the forked plugin https://github.com/AppsFlyerSDK/PhoneGap as well.

Initial Analysis from log: stringByEvaluatingJavaScriptFromString method call needs to be done from main thread which is not happening on first launch

-(void)onConversionDataReceived:(NSDictionary) installData { NSError error; NSData jsonData = [NSJSONSerialization dataWithJSONObject:installData options:0 error:&error]; if (jsonData) { NSString JSONString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding]; [[super webView] stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"javascript:window.plugins.appsFlyer.onInstallConversionDataLoaded(%@)", JSONString]]; } else { NSLog(@"%@",error); } }

Below is the crash log: _WebTryThreadLock(bool), 0x7fc24c204210: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now... 1 0x11682434b WebThreadLock 2 0x10dbe5580 -[UIWebView stringByEvaluatingJavaScriptFromString:] 3 0x10b8444b8 -[CDVUIWebViewEngine evaluateJavaScript:completionHandler:] 4 0x10b8277a6 -[AppsFlyerPlugin onConversionDataReceived:] 5 0x10b8c47ad 37-[AppsFlyerTracker getConversionData]_block_invoke170 6 0x10f19d6b5 75-[NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke 7 0x10f1afa02 49-[NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke 8 0x10c826304 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK 9 0x10c762035 -[NSBlockOperation main] 10 0x10c744f8a -[__NSOperationInternal _start:] 11 0x10c744b9b NSOQSchedule_f 12 0x10fb5649b _dispatch_client_callout 13 0x10fb3c8ec _dispatch_queue_drain 14 0x10fb3be0d _dispatch_queue_invoke 15 0x10fb3ea56 _dispatch_root_queue_drain 16 0x10fb3e4c5 _dispatch_worker_thread3 17 0x10fe8e68f _pthread_wqthread 18 0x10fe8c365 start_wqthread

AbraXus commented 8 years ago

Hi @SreeharshaJois, I'm facing the exact same issue. Have you found a solution yet?

AbraXus commented 8 years ago

Hello everyone. Are there any news on this?

kaelmoreno-cp commented 8 years ago

Any updates? Also happens on my case.

DevDmitryHub commented 8 years ago

It should be fixed in the latest release 4.1.0