Texture
Texture copied to clipboard
ASNetworkImageNode, gif image disappear for a second when scroll back
gif image disappear for a second and then show again when scroll back in a tableView or collectionView.
Try to setup shouldCacheImage property as false(objc: NO)
@GeekTree0101 it doesn't work
When did you set gif resource url onto ASNetworkImageNode ?
@GeekTree0101 just in the init method. use the examples/ASCollectionView.
string is a gif resource
`
- (instancetype)initWithString:(NSString *)string
{
self = [super init];
if (self != nil) {
.......
self.imageNode.defaultImage = nil;
self.imageNode.URL = [NSURL URLWithString:string];
[self addSubnode:self.imageNode];
...... } } `
self.imageNode.URL = [NSURL URLWithString:string]; In this case, resetToDefault is YES. try to use this method imageNode.setURL(gifURL, resetToDefault: false)
@GeekTree0101 It doesn't work either. notice the show example gif , Why the first gif is OK?
I upload an demo at here
You may download "t plus one" from app store, it use ASNetworkImageNode for all images, just simply set imageNode.URL = [NSURL URLWithString:imageURLInText]; App version 1.0.12 = Texture 2.7 by cocoapods
@yang152412 Have you resolved the problem? I have the same problem. I'm using Texture/IGListKit...
I have the same issue, it happens in the latest version of Texture.
Finally, I find where is the problem.
The code at ASNetworkImageNode.mm 334~371:
- (void)displayWillStartAsynchronously:(BOOL)asynchronously
{
[super displayWillStartAsynchronously:asynchronously];
if (asynchronously == NO && _cacheFlags.cacheSupportsSynchronousFetch) {
ASLockScopeSelf();
NSURL *url = _URL;
if (_imageLoaded == NO && url && _downloadIdentifier == nil) {
UIImage *result = [[_cache synchronouslyFetchedCachedImageWithURL:url] asdk_image];
if (result) {
}
...
}
[self didEnterPreloadState];
}
ASDisplayNode will display asynchronously if we set the displaysAsynchronously to NO according the document. So, I set displaysAsynchronously to NO,and implement - (nullable id <ASImageContainerProtocol>)synchronouslyFetchedCachedImageWithURL:(NSURL *)URL method.
But the problem is _imageLoaded == NO, _imageLoaded has been set to YES before the code goes here, here is the stack:
#1 0x000000010b6c8bb9 in -[ImageManager cachedImageWithURL:callbackQueue:completion:] 75
#2 0x000000010b8ec403 in ::-[ASNetworkImageNode _lazilyLoadImageIfNecessary]() 793
#3 0x000000010b8ea95a in ::-[ASNetworkImageNode didEnterPreloadState]() 432
#4 0x000000010b881cd8 in ::-[ASDisplayNode applyPendingInterfaceState:](ASInterfaceState) 3135
#5 0x000000010b8815bc in ::-[ASDisplayNode setInterfaceState:](ASInterfaceState) 3076
#6 0x000000010b8814d7 in ::__46-[ASDisplayNode recursivelySetInterfaceState:]_block_invoke(ASDisplayNode *) 3060
#7 0x000000010b88d685 in ::ASDisplayNodePerformBlockOnEveryNode(CALayer *, ASDisplayNode *, BOOL, void (^)(ASDisplayNode *)) 103
#8 0x000000010b88da6e in ::ASDisplayNodePerformBlockOnEveryNode(CALayer *, ASDisplayNode *, BOOL, void (^)(ASDisplayNode *)) 117
#9 0x000000010b881449 in ::-[ASDisplayNode recursivelySetInterfaceState:](ASInterfaceState) 3059
#10 0x000000010b8fbc77 in ::-[ASRangeController _updateVisibleNodeIndexPaths]() at ASRangeController.mm:389
#11 0x000000010b8f9e6b in ::-[ASRangeController updateRanges]() at ASRangeController.mm:164
#12 0x000000010b8f9e29 in ::-[ASRangeController updateIfNeeded]() at ASRangeController.mm:157
#13 0x000000010b8f9d8d in ::__35-[ASRangeController setNeedsUpdate]_block_invoke() at ASRangeController.mm:149
#14 0x000000010fec65d1 in _dispatch_call_block_and_release ()
#15 0x000000010fec763e in _dispatch_client_callout ()
#16 0x000000010fed49d6 in _dispatch_main_queue_callback_4CF ()
#17 0x000000010ef757f9 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#18 0x000000010ef6fe86 in __CFRunLoopRun ()
#19 0x000000010ef6f221 in CFRunLoopRunSpecific ()
#20 0x0000000114f7b1dd in GSEventRunModal ()
#21 0x000000011834f115 in UIApplicationMain ()
#22 0x000000010b6cdbc0 in main
#23 0x000000010ff3d551 in start ()
So UIImage *result = [[_cache synchronouslyFetchedCachedImageWithURL:url] asdk_image]; will never be executed. ASNetworkImageNode will always read cache asynchronously. That's why the animated image flashed when scroll.
At last,my solution is use an ASImageNode to display image, and an ASNetworkImageNode to download.I use synchronouslyFetchedCachedImageWithURL to read cache. use the ASImageNode to display if cache is exist, or defaultImage if not.
And update the image in delegate method - (void)imageNode:(ASNetworkImageNode *)imageNode didLoadImage:(UIImage *)image info:(ASNetworkImageNodeDidLoadInfo)info. but this method has a bug at 2.7 version. It does not be called if an url is a gif,(it's ok at 2.6). So i create a pull request#1121 to fix it.
I meet this problem only when the gif has single frame, gif with multi-frame works fine
Can someone please upload a sample project which reproduces this issue?
@garrettmoon I make a sample project to reproduce this problem, see: https://drive.google.com/file/d/1_YZUm8AGnLCy13hzz-t9gO0KquiCmaUE/view?usp=sharing
and the gif:

Two years later and this still isn't fixed :(
No fixes?
same problem....