Xcode Version: 12.2
Swift Version: 5.3
Installation Platform & Verison: Swift Package
The crash happens on all Facebook iOS 8.x.x SDK versions.
I'm facing into a crash when invoking
+ (void)resolveAppLink:(NSURL *)destination handler:(FBSDKAppLinkBlock)handler
of FBSDKAppLinkNavigation class
I use it inside
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable restorableObjects))restorationHandler
of my app delegate class in this way
[FBSDKAppLinkNavigation resolveAppLink:userActivity.webpageURL
handler:^(FBSDKAppLink * _Nullable appLink, NSError * _Nullable error) {
Every time the method is invoked, it makes the app crash, below the log, hoping it could be useful

I installed FacebookCore SDK via swift package (actually 8.2.0 version), so I was able to navigate into the code, and I saw that this crash happens in the line number 167 of FBSDKWebViewAppLinkResolver class, specifically when try to initialize an MKWebView inside the method
- (void)appLinkFromURL:(NSURL *)url handler:(FBSDKAppLinkBlock)handler
..
..
WKWebView *webView = [[WKWebView alloc] init]; (line 167)
At the very beginning of the method I can see those lines
dispatch_async(dispatch_get_main_queue(), ^{
[self followRedirects:url handler:^(NSDictionary<NSString *,id> *result, NSError * _Nullable error) {
IMO I think that followRedirects:url are not responding on main thread, so maybe putting
dispatch_async(dispatch_get_main_queue(), ^{
inside the followRedirects:url handler, could solve it.
Anyone else with the same issue?
I'm trying to work out what UI is being called from a background thread since the appLinkFromURL:handler: callback is already dispatched on the main thread and that's what would display UI.
I think it might have to do with how you're using
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray<id<UIUserActivityRestoring>> * __nullable restorableObjects))restorationHandler
According to the Apple Docs:
restorationHandler
A block to execute if your app creates objects to perform the task. Calling this block is optional and you can copy this block > and call it at a later time. When calling a saved copy of the block, you must call it from the app鈥檚 main thread.
Can you confirm that you are calling the restoration handler on the main thread?
Yes I can confirm that.
As I mentioned, my suspicious is that the issue is inside the completion handler of
[self followRedirects:url handler:^(NSDictionary<NSString *,id> *result, NSError * _Nullable error) {
It is not sufficient to call the entire method on the main thread, if the completion handler responds on another thread.
Taking a look at the code, that handler is called as a completion handler of an NSURLSessionDataTask that responds in a thread different than the main
I updated to master branch, now I can facing another crash invoking the same method, but now the class involved isFBSDKWebViewAppLinkResolverWebViewDelegate
In particular there is a missed check inside this method
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
if (self.hasLoaded) {
self.didFinishLoad(webView);
decisionHandler(WKNavigationActionPolicyCancel);
}
self.hasLoaded = YES;
decisionHandler(WKNavigationActionPolicyAllow);
}`
that makes the app crash because of
Thread 1: "Completion handler passed to -[FBSDKWebViewAppLinkResolverWebViewDelegate webView:decidePolicyForNavigationAction:decisionHandler:] was called more than once"
This fix looks reasonable enough. Can you share a little more about the use case here? I'm trying to sort out how to test the fixes.
Is it accurate that you're handling a universal link, extracting app link data out of the metadata from that universal link, and that the metadata includes a al:ios:url meta tag that has a url that redirects?
Yes it is correct, it is exactely what I'm trying to do.
Unfortunately I can't share with you the link(s) that I'm using, btw this issues started for me when moved from the old Bolt framework to this one integrated in CoreKit
This fix should make it into the next patch release. Thanks for the help!