My project will load several images using [UIImage imageNamed:] when a button is pressed, it runs smoothly under iOS12, but when I switch deploy target to iOS13, the action takes several seconds to completion which is unacceptable. (even loading 1px image become slower)
After some research, using the same .jpg image in default .xcassets , same code environment, I found that since iOS13, the default implementation of UIImage imageNamed: may have different call stacks.
the faster way
the time consuming way
In the later way, ulock_wait is one of the heaviest methods.
I made some efforts, like dispatching imageNamed: to global queue, but nothing helps. I have no clues how to make it call the faster way.
After some research, using the same .jpg image in default .xcassets , same code environment, I found that since iOS13, the default implementation of UIImage imageNamed: may have different call stacks.
the faster way
Code Block +[UIImage imageNamed:inBundle:withConfiguration:] +[_UIAssetManager newAssetNamed:fromBundle:] _UIImageCollectImagePathsForPath _UIImageCollectImagePathsForPath_block_invoke _UIImageCollectImagePathsForPath_block_invoke_2.168 ___UIImageCollectImagePathsForPath_block_invoke.155 -[NSFileManager fileExistsAtPath:]
the time consuming way
Code Block +[UIImage imageNamed:inBundle:withConfiguration:] -[_UIAssetManager imageNamed:configuration:] -[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:] 78-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke -[_UIAssetManager _lookUpObjectForTraitCollection:withAccessorWithAppearanceName:] -[UITraitCollection _enumerateThemeAppearanceNamesForLookup:] 82-[_UIAssetManager _lookUpObjectForTraitCollection:withAccessorWithAppearanceName:]_block_invoke 78-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke_2 -[CUICatalog namedLookupWithName:scaleFactor:deviceIdiom:deviceSubtype:displayGamut:layoutDirection:sizeClassHorizontal:sizeClassVertical:appearanceName:] -[CUICatalog _namedLookupWithName:scaleFactor:deviceIdiom:deviceSubtype:displayGamut:layoutDirection:sizeClassHorizontal:sizeClassVertical:appearanceName:] -[CUICatalog _resolvedRenditionKeyFromThemeRef:withBaseKey:scaleFactor:deviceIdiom:deviceSubtype:displayGamut:layoutDirection:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:deviceSubtypeFallBackOrder:adjustRenditionKeyWithBlock:] -[CUICatalog _private_resolvedRenditionKeyFromThemeRef:withBaseKey:scaleFactor:deviceIdiom:deviceSubtype:displayGamut:layoutDirection:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:deviceSubtypeFallBackOrder:localizationIdentifier:adjustRenditionKeyWithBlock:] -[CUIStructuredThemeStore _canGetRenditionWithKey:isFPO:lookForSubstitutions:] -[CUIStructuredThemeStore assetExistsForKey:] -[CUICommonAssetStorage assetExistsForKeyData:length:] _os_unfair_lock_lock_slow ulock_wait
In the later way, ulock_wait is one of the heaviest methods.
I made some efforts, like dispatching imageNamed: to global queue, but nothing helps. I have no clues how to make it call the faster way.