@@ -667,18 +667,20 @@ + (void)swizzleResumeSelector:(SEL)selector forClass:(Class)class {
667
667
Method originalResume = class_getInstanceMethod (class, selector);
668
668
IMP implementation = imp_implementationWithBlock (^(NSURLSessionTask *slf) {
669
669
670
- // AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
671
- // -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
672
- if (![slf isKindOfClass: [AVAggregateAssetDownloadTask class ]]) {
673
- // iOS's internal HTTP parser finalization code is mysteriously not thread safe,
674
- // invoking it asynchronously has a chance to cause a `double free` crash.
675
- // This line below will ask for HTTPBody synchronously, make the HTTPParser
676
- // parse the request, and cache them in advance. After that the HTTPParser
677
- // will be finalized. Make sure other threads inspecting the request
678
- // won't trigger a race to finalize the parser.
679
- [slf.currentRequest HTTPBody ];
680
-
681
- [FLEXNetworkObserver.sharedObserver URLSessionTaskWillResume: slf];
670
+ if (@available (iOS 11.0 , *)) {
671
+ // AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
672
+ // -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
673
+ if (![slf isKindOfClass: [AVAggregateAssetDownloadTask class ]]) {
674
+ // iOS's internal HTTP parser finalization code is mysteriously not thread safe,
675
+ // invoking it asynchronously has a chance to cause a `double free` crash.
676
+ // This line below will ask for HTTPBody synchronously, make the HTTPParser
677
+ // parse the request, and cache them in advance. After that the HTTPParser
678
+ // will be finalized. Make sure other threads inspecting the request
679
+ // won't trigger a race to finalize the parser.
680
+ [slf.currentRequest HTTPBody ];
681
+
682
+ [FLEXNetworkObserver.sharedObserver URLSessionTaskWillResume: slf];
683
+ }
682
684
}
683
685
684
686
((void (*)(id , SEL ))objc_msgSend)(
@@ -1985,10 +1987,12 @@ - (void)URLSession:(NSURLSession *)session
1985
1987
}
1986
1988
1987
1989
- (void )URLSessionTaskWillResume : (NSURLSessionTask *)task {
1988
- // AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
1989
- // -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
1990
- if ([task isKindOfClass: [AVAggregateAssetDownloadTask class ]]) {
1991
- return ;
1990
+ if (@available (iOS 11.0 , *)) {
1991
+ // AVAggregateAssetDownloadTask deeply does not like to be looked at. Accessing -currentRequest or
1992
+ // -originalRequest will crash. Do not try to observe these. https://github.com/FLEXTool/FLEX/issues/276
1993
+ if ([task isKindOfClass: [AVAggregateAssetDownloadTask class ]]) {
1994
+ return ;
1995
+ }
1992
1996
}
1993
1997
1994
1998
// Since resume can be called multiple times on the same task, only treat the first resume as
0 commit comments