From f9fda3d5436eec235daac0700ce21f6961765d1d Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 21 Mar 2019 12:50:02 +0100 Subject: [PATCH 1/2] [Share Extension] Do not offer the possibility to resize an image to large size if one dimension is too high in order to prevent the risk of memory limit exception. --- RiotShareExtension/Managers/ShareExtensionManager.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RiotShareExtension/Managers/ShareExtensionManager.m b/RiotShareExtension/Managers/ShareExtensionManager.m index 823993423..51d020ecb 100644 --- a/RiotShareExtension/Managers/ShareExtensionManager.m +++ b/RiotShareExtension/Managers/ShareExtensionManager.m @@ -23,6 +23,8 @@ NSString *const kShareExtensionManagerDidUpdateAccountDataNotification = @"kShareExtensionManagerDidUpdateAccountDataNotification"; +static const CGFloat kLargeImageSizeMaxDimension = 2048.0; + typedef NS_ENUM(NSInteger, ImageCompressionMode) { ImageCompressionModeNone, @@ -560,7 +562,9 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode) }]]; } - if (compressionSizes.large.fileSize) + // Do not offer the possibility to resize an image with a dimension above kLargeImageSizeMaxDimension, to prevent the risk of memory limit exception. + // TODO: Remove this condition when issue https://github.com/vector-im/riot-ios/issues/2341 will be fixed. + if (compressionSizes.large.fileSize && (MAX(compressionSizes.large.imageSize.width, compressionSizes.large.imageSize.height) <= kLargeImageSizeMaxDimension)) { NSString *resolution = [NSString stringWithFormat:@"%@ (%d x %d)", [MXTools fileSizeToString:compressionSizes.large.fileSize round:NO], (int)compressionSizes.large.imageSize.width, (int)compressionSizes.large.imageSize.height]; From 97d7e37f5684a69fab6dfe837a9195b333405afb Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 21 Mar 2019 13:12:56 +0100 Subject: [PATCH 2/2] Update changes --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index b35002fbc..b8cee48f4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,7 @@ Changes in 0.8.4 (2019-03-xx) =============================================== Improvements: + * Share extension: Remove image large size resizing choice if output dimension is too high to prevent memory limit exception (PR #2342). Bug fix: