@@ -66,29 +66,31 @@ - (void)submitImageData:(NSData *)image
6666#pragma clang diagnostic ignored "-Wcompletion-handler"
6767 dispatch_async (self.scalingQueue , ^{
6868 while (YES ) {
69- [self .nextImageLock lock ];
70- NSData *nextImageData = self.nextImage ;
71- self.nextImage = nil ;
72- if (nextImageData == nil ) {
73- self.isScalingScheduled = NO ;
69+ @autoreleasepool {
70+ [self .nextImageLock lock ];
71+ NSData *nextImageData = self.nextImage ;
72+ self.nextImage = nil ;
73+ if (nextImageData == nil ) {
74+ self.isScalingScheduled = NO ;
75+ [self .nextImageLock unlock ];
76+ return ;
77+ }
7478 [self .nextImageLock unlock ];
75- return ;
76- }
77- [self .nextImageLock unlock ];
7879
79- // We do not want this value to be too high because then we get images larger in size than original ones
80- // Although, we also don't want to lose too much of the quality on recompression
81- CGFloat recompressionQuality = MAX (0.9 ,
82- MIN (FBMaxCompressionQuality, FBConfiguration.mjpegServerScreenshotQuality / 100.0 ));
83- NSData *thumbnailData = [self .class fixedImageDataWithImageData: nextImageData
84- scalingFactor: scalingFactor
85- uti: UTTypeJPEG
86- compressionQuality: recompressionQuality
87- // iOS always returns screnshots in portrait orientation, but puts the real value into the metadata
88- // Use it with care. See https://github.com/appium/WebDriverAgent/pull/812
89- fixOrientation: FBConfiguration.mjpegShouldFixOrientation
90- desiredOrientation: nil ];
91- completionHandler (thumbnailData ?: nextImageData);
80+ // We do not want this value to be too high because then we get images larger in size than original ones
81+ // Although, we also don't want to lose too much of the quality on recompression
82+ CGFloat recompressionQuality = MAX (0.9 ,
83+ MIN (FBMaxCompressionQuality, FBConfiguration.mjpegServerScreenshotQuality / 100.0 ));
84+ NSData *thumbnailData = [self .class fixedImageDataWithImageData: nextImageData
85+ scalingFactor: scalingFactor
86+ uti: UTTypeJPEG
87+ compressionQuality: recompressionQuality
88+ // iOS always returns screnshots in portrait orientation, but puts the real value into the metadata
89+ // Use it with care. See https://github.com/appium/WebDriverAgent/pull/812
90+ fixOrientation: FBConfiguration.mjpegShouldFixOrientation
91+ desiredOrientation: nil ];
92+ completionHandler (thumbnailData ?: nextImageData);
93+ }
9294 }
9395 });
9496#pragma clang diagnostic pop
0 commit comments