Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential deadlock when accessing a shared pasteboard from a background thread #310

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Adjust/ADJAdditions/UIDevice+ADJAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@ - (NSString *)adjFbAttributionId {
#if ADJUST_NO_UIPASTEBOARD || TARGET_OS_TV
return @"";
#else
NSString *result = [UIPasteboard pasteboardWithName:@"fb_app_attribution" create:NO].string;
if (result == nil) return @"";
__block NSString *result;
void(^resultRetrievalBlock)(void) = ^{
result = [UIPasteboard pasteboardWithName:@"fb_app_attribution" create:NO].string;
if (result == nil) {
result = @"";
}
};
[NSThread isMainThread] ?
resultRetrievalBlock() :
dispatch_sync(dispatch_get_main_queue(), resultRetrievalBlock);
return result;
#endif
}
Expand Down