mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Merge pull request #1097 from facebook/iOS9ConcurrentImageDecodingSystemBug
[ASImageNode] @synchronized around UIImage draw to prevent concurrently decoding the same instance.
This commit is contained in:
commit
64ad48a248
@ -235,7 +235,21 @@
|
||||
UIRectFill({ .size = backingSize });
|
||||
}
|
||||
|
||||
// iOS 9 appears to contain a thread safety regression when drawing the same CGImageRef on
|
||||
// multiple threads concurrently. In fact, instead of crashing, it appears to deadlock.
|
||||
// The issue is present in Mac OS X El Capitan and has been seen hanging Pro apps like Adobe Premier,
|
||||
// as well as iOS games, and a small number of ASDK apps that provide the same image reference
|
||||
// to many separate ASImageNodes. A workaround is to set .displaysAsynchronously = NO for the nodes
|
||||
// that may get the same pointer for a given UI asset image, etc.
|
||||
// FIXME: We should replace @synchronized here, probably using a global, locked NSMutableSet, and
|
||||
// only if the object already exists in the set we should create a semaphore to signal waiting threads
|
||||
// upon removal of the object from the set when the operation completes.
|
||||
// Another option is to have ASDisplayNode+AsyncDisplay coordinate these cases, and share the decoded buffer.
|
||||
// Details tracked in https://github.com/facebook/AsyncDisplayKit/issues/1068
|
||||
|
||||
@synchronized(image) {
|
||||
[image drawInRect:imageDrawRect];
|
||||
}
|
||||
|
||||
if (isCancelled()) {
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user