TimOliver / TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects
http://www.timoliver.com.au/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/
MIT License
4.74k stars 956 forks source link

Crop view freezes on iOS until the background image is loaded completely. #538

Open ZahraVe opened 2 years ago

ZahraVe commented 2 years ago

Describe the bug I am using high-resolution images, which are pretty large in size, in my app. Images are shown in the photo-view (PhotoViewGallery.builder). Each image takes a few sec to be loaded If you try to pop the copper view before the image is completely loaded on screen: On Android, you don't see the image in cropper view, and the checkmark is indicating circular progress until the image is ready. -> which is UX-friendly! But on iOS, You immediately see the image in cropper view but the screen freezes, like a glitch, you need to hold on until the image is loaded. -> This is a bad experience for the user.

Here is the function that I use for saving wallpaper and it pops up the cropper:

Future<bool> saveWallpaperPortion(String myPath) async {
    var file = await DefaultCacheManager().getSingleFile(myPath);
    final croppedFile = await ImageCropper().cropImage(
      sourcePath: file.path,
      aspectRatio: CropAspectRatio(
          ratioY: SizeConfig.screenHeight, ratioX: SizeConfig.screenWidth),
      compressQuality: 100,
      uiSettings: [
        IOSUiSettings(
          rotateButtonsHidden: true,
          rotateClockwiseButtonHidden: true,
          aspectRatioLockEnabled: true,
        ),
      ],
    );
    try {
      if (croppedFile != null) {
        try {
          final result = await ImageGallerySaver.saveFile(croppedFile.path);
          return true;
        } catch (e) {
          return false;
        }
      } else {
        return false;
      }
    } catch (e) {
      return false;
    }
  }

Expected behavior Getting the same behaviour as Android on iOS

Screenshots If applicable, add screenshots to help explain your problem.

iOS Device: iPhone 12 pro, iPhone 13pro, iPhone 14 pro

Additional context How to work around this issue! I am about to release the app!