mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-06 20:54:04 +00:00
Improve locking around clearContents (#1107)
* Improve locking around clearContents * Add changelog
This commit is contained in:
parent
eb5bd0942b
commit
f759d5cc7d
@ -40,6 +40,7 @@
|
||||
- Remove double scaling of lineHeightMultiple & paragraphSpacing attributes in ASTextKitFontSizeAdjuster. [Eric Jensen](https://github.com/ejensen)
|
||||
- Add a delegate callback for when the framework has initialized. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||
- Improve TextNode2 by skipping an unneeded copy during measurement. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||
- Improve locking around clearContents [Michael Schneider](https://github.com/maicki)
|
||||
|
||||
## 2.7
|
||||
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
|
||||
|
@ -3144,8 +3144,10 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
[self setDisplaySuspended:YES];
|
||||
//schedule clear contents on next runloop
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (ASInterfaceStateIncludesDisplay(_interfaceState) == NO) {
|
||||
__instanceLock__.lock();
|
||||
ASInterfaceState interfaceState = _interfaceState;
|
||||
__instanceLock__.unlock();
|
||||
if (ASInterfaceStateIncludesDisplay(interfaceState) == NO) {
|
||||
[self clearContents];
|
||||
}
|
||||
});
|
||||
@ -3162,8 +3164,10 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
[[self asyncLayer] cancelAsyncDisplay];
|
||||
//schedule clear contents on next runloop
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (ASInterfaceStateIncludesDisplay(_interfaceState) == NO) {
|
||||
__instanceLock__.lock();
|
||||
ASInterfaceState interfaceState = _interfaceState;
|
||||
__instanceLock__.unlock();
|
||||
if (ASInterfaceStateIncludesDisplay(interfaceState) == NO) {
|
||||
[self clearContents];
|
||||
}
|
||||
});
|
||||
@ -3355,6 +3359,9 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
||||
- (void)clearContents
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
ASAssertUnlocked(__instanceLock__);
|
||||
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (_flags.canClearContentsOfLayer) {
|
||||
// No-op if these haven't been created yet, as that guarantees they don't have contents that needs to be released.
|
||||
_layer.contents = nil;
|
||||
|
@ -590,10 +590,9 @@ static ASDN::StaticMutex& cacheLock = *new ASDN::StaticMutex;
|
||||
- (void)clearContents
|
||||
{
|
||||
[super clearContents];
|
||||
|
||||
__instanceLock__.lock();
|
||||
_weakCacheEntry = nil; // release contents from the cache.
|
||||
__instanceLock__.unlock();
|
||||
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
_weakCacheEntry = nil; // release contents from the cache.
|
||||
}
|
||||
|
||||
#pragma mark - Cropping
|
||||
|
@ -412,8 +412,11 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
#pragma mark - Core Internal
|
||||
- (void)_setDisplayedImageIdentifier:(id)displayedImageIdentifier withImage:(UIImage *)image
|
||||
{
|
||||
if (ASObjectIsEqual(displayedImageIdentifier, _displayedImageIdentifier))
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
if (ASObjectIsEqual(_displayedImageIdentifier, displayedImageIdentifier)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_displayedImageIdentifier = displayedImageIdentifier;
|
||||
|
||||
|
@ -518,6 +518,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
||||
// Skip the many method calls of the recursive operation if the top level cell node already has the right interfaceState.
|
||||
- (void)clearContents
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
for (ASCollectionElement *element in [_dataSource elementMapForRangeController:self]) {
|
||||
ASCellNode *node = element.nodeIfAllocated;
|
||||
if (ASInterfaceStateIncludesDisplay(node.interfaceState)) {
|
||||
@ -528,6 +529,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
||||
|
||||
- (void)clearPreloadedData
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
for (ASCollectionElement *element in [_dataSource elementMapForRangeController:self]) {
|
||||
ASCellNode *node = element.nodeIfAllocated;
|
||||
if (ASInterfaceStateIncludesPreload(node.interfaceState)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user