Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Address bad access exception in MGLAttributionInfo (#13300)
Browse files Browse the repository at this point in the history
* [ios] move creation of attributed string to global queue]

* [ios] check if on main queue
  • Loading branch information
jmkiley authored Nov 14, 2018
1 parent 01d9005 commit d44be9a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions platform/darwin/src/MGLAttributionInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ @implementation MGLAttributionInfo
NSData *htmlData = [styledHTML dataUsingEncoding:NSUTF8StringEncoding];

#if TARGET_OS_IPHONE
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithData:htmlData
options:options
documentAttributes:nil
error:NULL];
__block NSMutableAttributedString *attributedString;
dispatch_block_t initialization = ^{
// This initializer should be called from a global or main queue. https://developer.apple.com/documentation/foundation/nsattributedstring/1524613-initwithdata
attributedString = [[NSMutableAttributedString alloc] initWithData:htmlData
options:options
documentAttributes:nil
error:NULL];
};

if (![[NSThread currentThread] isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), initialization);
} else {
initialization();
}
#else
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithHTML:htmlData
options:options
Expand Down

0 comments on commit d44be9a

Please sign in to comment.