mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-08 13:42:51 +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)
|
- 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)
|
- 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 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
|
## 2.7
|
||||||
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
|
- 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];
|
[self setDisplaySuspended:YES];
|
||||||
//schedule clear contents on next runloop
|
//schedule clear contents on next runloop
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
ASDN::MutexLocker l(__instanceLock__);
|
__instanceLock__.lock();
|
||||||
if (ASInterfaceStateIncludesDisplay(_interfaceState) == NO) {
|
ASInterfaceState interfaceState = _interfaceState;
|
||||||
|
__instanceLock__.unlock();
|
||||||
|
if (ASInterfaceStateIncludesDisplay(interfaceState) == NO) {
|
||||||
[self clearContents];
|
[self clearContents];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3162,8 +3164,10 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
|||||||
[[self asyncLayer] cancelAsyncDisplay];
|
[[self asyncLayer] cancelAsyncDisplay];
|
||||||
//schedule clear contents on next runloop
|
//schedule clear contents on next runloop
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
ASDN::MutexLocker l(__instanceLock__);
|
__instanceLock__.lock();
|
||||||
if (ASInterfaceStateIncludesDisplay(_interfaceState) == NO) {
|
ASInterfaceState interfaceState = _interfaceState;
|
||||||
|
__instanceLock__.unlock();
|
||||||
|
if (ASInterfaceStateIncludesDisplay(interfaceState) == NO) {
|
||||||
[self clearContents];
|
[self clearContents];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3355,6 +3359,9 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
|||||||
- (void)clearContents
|
- (void)clearContents
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
|
ASAssertUnlocked(__instanceLock__);
|
||||||
|
|
||||||
|
ASDN::MutexLocker l(__instanceLock__);
|
||||||
if (_flags.canClearContentsOfLayer) {
|
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.
|
// 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;
|
_layer.contents = nil;
|
||||||
|
@ -590,10 +590,9 @@ static ASDN::StaticMutex& cacheLock = *new ASDN::StaticMutex;
|
|||||||
- (void)clearContents
|
- (void)clearContents
|
||||||
{
|
{
|
||||||
[super clearContents];
|
[super clearContents];
|
||||||
|
|
||||||
__instanceLock__.lock();
|
ASDN::MutexLocker l(__instanceLock__);
|
||||||
_weakCacheEntry = nil; // release contents from the cache.
|
_weakCacheEntry = nil; // release contents from the cache.
|
||||||
__instanceLock__.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Cropping
|
#pragma mark - Cropping
|
||||||
|
@ -412,8 +412,11 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
|||||||
#pragma mark - Core Internal
|
#pragma mark - Core Internal
|
||||||
- (void)_setDisplayedImageIdentifier:(id)displayedImageIdentifier withImage:(UIImage *)image
|
- (void)_setDisplayedImageIdentifier:(id)displayedImageIdentifier withImage:(UIImage *)image
|
||||||
{
|
{
|
||||||
if (ASObjectIsEqual(displayedImageIdentifier, _displayedImageIdentifier))
|
ASDisplayNodeAssertMainThread();
|
||||||
|
|
||||||
|
if (ASObjectIsEqual(_displayedImageIdentifier, displayedImageIdentifier)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_displayedImageIdentifier = displayedImageIdentifier;
|
_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.
|
// Skip the many method calls of the recursive operation if the top level cell node already has the right interfaceState.
|
||||||
- (void)clearContents
|
- (void)clearContents
|
||||||
{
|
{
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
for (ASCollectionElement *element in [_dataSource elementMapForRangeController:self]) {
|
for (ASCollectionElement *element in [_dataSource elementMapForRangeController:self]) {
|
||||||
ASCellNode *node = element.nodeIfAllocated;
|
ASCellNode *node = element.nodeIfAllocated;
|
||||||
if (ASInterfaceStateIncludesDisplay(node.interfaceState)) {
|
if (ASInterfaceStateIncludesDisplay(node.interfaceState)) {
|
||||||
@ -528,6 +529,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
|
|
||||||
- (void)clearPreloadedData
|
- (void)clearPreloadedData
|
||||||
{
|
{
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
for (ASCollectionElement *element in [_dataSource elementMapForRangeController:self]) {
|
for (ASCollectionElement *element in [_dataSource elementMapForRangeController:self]) {
|
||||||
ASCellNode *node = element.nodeIfAllocated;
|
ASCellNode *node = element.nodeIfAllocated;
|
||||||
if (ASInterfaceStateIncludesPreload(node.interfaceState)) {
|
if (ASInterfaceStateIncludesPreload(node.interfaceState)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user