TextureGroup / Texture

Smooth asynchronous user interfaces for iOS apps.
https://texturegroup.org/
Other
7.99k stars 1.29k forks source link

We got some crash on iOS 8 #716

Closed wangyutao0424 closed 6 years ago

wangyutao0424 commented 6 years ago

image

- (ASCellNodeBlock)collectionNode:(ASCollectionNode *)collectionNode nodeBlockForItemAtIndexPath:(NSIndexPath *)indexPath {
    return ^{
        GCHpAssetsCell *elementNode = [[GCHpAssetsCell alloc] init];
        return elementNode;
    };
}

@implementation GCHpAssetsCell
- (instancetype)init {
    if (self = [super init]) {
        _title0 = ({
            ASTextNode *node = [[ASTextNode alloc] init];
            node.maximumNumberOfLines = 1;
            node.style.height =  ASDimensionMake(21);
            [self addSubnode:node];

            node;
        });

        _title1 =({
            ASTextNode *node = [[ASTextNode alloc] init];
            node.maximumNumberOfLines = 1;
            node.style.height =  ASDimensionMake(19);
            [self addSubnode:node];
            node;
        });

        _title2 =({
            ASTextNode *node = [[ASTextNode alloc] init];
            node.maximumNumberOfLines = 1;
            node.style.height =  ASDimensionMake(19);
            [self addSubnode:node];

            node;
        });
        _leftArrow = ({
            ASDisplayNode *node = [[ASDisplayNode alloc] init];
            node.backgroundColor = [UIColor clearColor];
            node.style.preferredSize = CGSizeMake(8, 8);
            [self addSubnode:node];
            node;
        });
        _arrow = ({
            ASImageNode *node = [[ASImageNode alloc] init];
            node.image = [UIImage imageNamed:@"gchp_arrow"];
            node.style.preferredSize = CGSizeMake(8, 8);
            [self addSubnode:node];
            node;
        });
        self.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0.0] ;

    }
    return self;
}
garrettmoon commented 6 years ago

@wangyutao0424 I don't think this is an issue with Texture. In our testing we found that calling imageNamed: off the main thread isn't safe, however, calling imageNamed:inBundle:compatibleWithTraitCollection: is.

Why not try using as_imageNamed: or as_imageNamed:compatibleWithTraitCollection: and seeing if that fixes the issue.

xingxzhou commented 6 years ago

@garrettmoon Hi,I have same issue on iOS8. So saaaaad, imageNamed:inBundle:compatibleWithTraitCollection: , In iOS 9 and later, this method is thread safe. Is there any idea to fix it on iOS8?

garrettmoon commented 6 years ago

@PatrickChow Have you tried using the above methods I suggested?

xingxzhou commented 6 years ago

@garrettmoon Yes,as_imageNamed will be crash on iOS 8.1 sometimes. I using collectionNode:nodeForItemAtIndexPath instead of collectionNode:nodeBlockForItemAtIndexPath to make sure initial node at main thread.