Move the SD_CHECK_CGIMAGE_RETAIN_SOURCE assertion to SDWebImage Demo and Tests only
This does not effects user who use this framework, only useful for ourselves to ensure Apple does not break our code
This commit is contained in:
parent
80683c20d8
commit
9c0c715d6a
|
@ -173,9 +173,8 @@
|
||||||
53761299155AB74D005750A4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
53761299155AB74D005750A4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||||
5376129B155AB74D005750A4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
5376129B155AB74D005750A4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
5376129D155AB74D005750A4 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
5376129D155AB74D005750A4 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||||
537612A1155AB74D005750A4 /* SDWebImage Demo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SDWebImage Demo-Info.plist"; sourceTree = "<group>"; };
|
537612A1155AB74D005750A4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
537612A5155AB74D005750A4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
537612A5155AB74D005750A4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
537612A7155AB74D005750A4 /* SDWebImage Demo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SDWebImage Demo-Prefix.pch"; sourceTree = "<group>"; };
|
|
||||||
537612A8155AB74D005750A4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
537612A8155AB74D005750A4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
537612A9155AB74D005750A4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
537612A9155AB74D005750A4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
537612AB155AB74D005750A4 /* MasterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MasterViewController.h; sourceTree = "<group>"; };
|
537612AB155AB74D005750A4 /* MasterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MasterViewController.h; sourceTree = "<group>"; };
|
||||||
|
@ -393,9 +392,8 @@
|
||||||
537612A0155AB74D005750A4 /* Supporting Files */ = {
|
537612A0155AB74D005750A4 /* Supporting Files */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
537612A1155AB74D005750A4 /* SDWebImage Demo-Info.plist */,
|
537612A1155AB74D005750A4 /* Info.plist */,
|
||||||
537612A5155AB74D005750A4 /* main.m */,
|
537612A5155AB74D005750A4 /* main.m */,
|
||||||
537612A7155AB74D005750A4 /* SDWebImage Demo-Prefix.pch */,
|
|
||||||
);
|
);
|
||||||
name = "Supporting Files";
|
name = "Supporting Files";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1031,8 +1029,7 @@
|
||||||
baseConfigurationReference = 789EDF4244C66933FDF3E181 /* Pods-SDWebImage iOS Demo.debug.xcconfig */;
|
baseConfigurationReference = 789EDF4244C66933FDF3E181 /* Pods-SDWebImage iOS Demo.debug.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "SDWebImage Demo/SDWebImage Demo-Prefix.pch";
|
INFOPLIST_FILE = "SDWebImage Demo/Info.plist";
|
||||||
INFOPLIST_FILE = "SDWebImage Demo/SDWebImage Demo-Info.plist";
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
@ -1044,8 +1041,7 @@
|
||||||
baseConfigurationReference = 0829378FA7103DD8649CCCF3 /* Pods-SDWebImage iOS Demo.release.xcconfig */;
|
baseConfigurationReference = 0829378FA7103DD8649CCCF3 /* Pods-SDWebImage iOS Demo.release.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "SDWebImage Demo/SDWebImage Demo-Prefix.pch";
|
INFOPLIST_FILE = "SDWebImage Demo/Info.plist";
|
||||||
INFOPLIST_FILE = "SDWebImage Demo/SDWebImage Demo-Info.plist";
|
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
//
|
|
||||||
// Prefix header for all source files of the 'SDWebImage Demo' target in the 'SDWebImage Demo' project
|
|
||||||
//
|
|
||||||
|
|
||||||
#import <Availability.h>
|
|
||||||
|
|
||||||
#ifdef __OBJC__
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#endif
|
|
17
Podfile
17
Podfile
|
@ -64,3 +64,20 @@ target 'Tests TV' do
|
||||||
platform :tvos, '9.0'
|
platform :tvos, '9.0'
|
||||||
all_test_pods
|
all_test_pods
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Inject macro during SDWebImage Demo and Tests
|
||||||
|
post_install do |installer_representation|
|
||||||
|
installer_representation.generated_pod_targets.each do |target|
|
||||||
|
if target.pod_name == "SDWebImage"
|
||||||
|
build_settings = target.build_settings
|
||||||
|
build_settings.each do |configuration, build_setting|
|
||||||
|
if configuration == :debug
|
||||||
|
config = build_setting.xcconfig
|
||||||
|
old_value = config.attributes['GCC_PREPROCESSOR_DEFINITIONS']
|
||||||
|
config.attributes['GCC_PREPROCESSOR_DEFINITIONS'] = old_value + ' SD_CHECK_CGIMAGE_RETAIN_SOURCE=1'
|
||||||
|
config.save_as(target.xcconfig_path(configuration))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -18,14 +18,16 @@
|
||||||
#import <ImageIO/ImageIO.h>
|
#import <ImageIO/ImageIO.h>
|
||||||
#import <CoreServices/CoreServices.h>
|
#import <CoreServices/CoreServices.h>
|
||||||
|
|
||||||
|
#if SD_CHECK_CGIMAGE_RETAIN_SOURCE
|
||||||
|
#import <dlfcn.h>
|
||||||
|
|
||||||
|
// SPI to check thread safe during Example and Test
|
||||||
|
static CGImageSourceRef (*SDCGImageGetImageSource)(CGImageRef);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Specify File Size for lossy format encoding, like JPEG
|
// Specify File Size for lossy format encoding, like JPEG
|
||||||
static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestinationRequestedFileSize";
|
static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestinationRequestedFileSize";
|
||||||
|
|
||||||
// Only assert on Debug mode
|
|
||||||
#define SD_CHECK_CGIMAGE_RETAIN_SOURCE DEBUG && \
|
|
||||||
((__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_15_0)) || \
|
|
||||||
((__TV_OS_VERSION_MAX_ALLOWED >= __TVOS_15_0))
|
|
||||||
|
|
||||||
// This strip the un-wanted CGImageProperty, like the internal CGImageSourceRef in iOS 15+
|
// This strip the un-wanted CGImageProperty, like the internal CGImageSourceRef in iOS 15+
|
||||||
// However, CGImageCreateCopy still keep those CGImageProperty, not suit for our use case
|
// However, CGImageCreateCopy still keep those CGImageProperty, not suit for our use case
|
||||||
static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) {
|
static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) {
|
||||||
|
@ -301,8 +303,13 @@ static CGImageRef __nullable SDCGImageCreateCopy(CGImageRef cg_nullable image) {
|
||||||
if (@available(iOS 15, tvOS 15, *)) {
|
if (@available(iOS 15, tvOS 15, *)) {
|
||||||
// Assert here to check CGImageRef should not retain the CGImageSourceRef and has possible thread-safe issue (this is behavior on iOS 15+)
|
// Assert here to check CGImageRef should not retain the CGImageSourceRef and has possible thread-safe issue (this is behavior on iOS 15+)
|
||||||
// If assert hit, fire issue to https://github.com/SDWebImage/SDWebImage/issues and we update the condition for this behavior check
|
// If assert hit, fire issue to https://github.com/SDWebImage/SDWebImage/issues and we update the condition for this behavior check
|
||||||
extern CGImageSourceRef CGImageGetImageSource(CGImageRef);
|
static dispatch_once_t onceToken;
|
||||||
NSCAssert(!CGImageGetImageSource(imageRef), @"Animated Coder created CGImageRef should not retain CGImageSourceRef, which may cause thread-safe issue without lock");
|
dispatch_once(&onceToken, ^{
|
||||||
|
SDCGImageGetImageSource = dlsym(RTLD_DEFAULT, "CGImageGetImageSource");
|
||||||
|
});
|
||||||
|
if (SDCGImageGetImageSource) {
|
||||||
|
NSCAssert(!SDCGImageGetImageSource(imageRef), @"Animated Coder created CGImageRef should not retain CGImageSourceRef, which may cause thread-safe issue without lock");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue