igreenwood / SimpleCropView

A simple image cropping library for Android.
MIT License
2.49k stars 467 forks source link

CropImageView SavedState takes too much space and crashes #82

Closed GrindingOgre closed 7 years ago

GrindingOgre commented 8 years ago

Be careful on the CropImageView.onSaveInstanceState, because if i use a big bitmap, there's a chance that the app crashes.

I have CropImageView inside a fragment, and, when the app goes in background, it throws TransactionTooLargeException. I've seen on onSaveInstanceState method that you save the bitmap inside the Bundle and i don't think this is a good practice.

To avoid this crash, i call setImageDrawable(null) when the Fragment goes inside onPause method

Rainer-Lang commented 7 years ago

@GrindingOgre I have the same problem. Do you have a solution?

Nuclominus commented 7 years ago

@Rainer-Lang you may create fast-fix like say @GrindingOgre.

  1. Call mCropView.setImageDrawable(null) in onPause methode on MainFragment
  2. Move setImageResource image from onViewCreated to onResume.
GrindingOgre commented 7 years ago

I used the same workaround as @Nuclominus and it worked just fine. Just don't use Glide or Picasso because there are some weird behaviour on some devices, like bitmap inside the view was overly scaled.

Unfortunately i had to switch to another library because this one didn't have all the features i need.

igreenwood commented 7 years ago

In the new version, CropImageView does not save bitmap internally . Please use the version 1.1.5 and see also new sample.