FFImageLoading icon indicating copy to clipboard operation
FFImageLoading copied to clipboard

Sometimes see null ref exception errors and bitmap reconfigure warning spam together

Open ahohns opened this issue 10 years ago • 10 comments

Am seeing a null reference exceptions appearing when clicking around (for both Uri and File images) and at the same time warnings about calling reconfigure on a bitmap in use. The warning says it could cause graphical corruption and that's what happened. See screenshot

While doing testing I loaded the root page, then clicked around other pages with as many different images as I could find before returning to the root page. Then scrolling through the root page's listview I got the below debug spam:

Something wrong happened while adding decoding options to image: http://<site>/M4/Down/5/7/4/c/574ca515-8b0b-4d55-8058-177ec9f192be.jpg?&width=954&height=450&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
Something wrong happened while adding decoding options to image: http://<site>/M4/Down/0/9/c/f/09cf5459-023d-4a32-9513-a0a36a2221cf.jpg?&width=138&height=138&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
Something wrong happened while adding decoding options to image: defaultuser.png
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
Something wrong happened while adding decoding options to image: http://<site>/M4/Down/3/c/d/0/3cd06ad0-d8a3-4a39-9d88-c61b1e4b74e0.jpg?&width=954&height=450&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
Something wrong happened while adding decoding options to image: http://<site>/M4/Down/0/9/c/f/09cf5459-023d-4a32-9513-a0a36a2221cf.jpg?&width=138&height=138&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
Something wrong happened while adding decoding options to image: http://<site>/M4/Down/d/e/c/c/decca9e2-7d4f-4f39-ada0-0f16d3235b08.jpg?&width=954&height=450&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
Something wrong happened while adding decoding options to image: http://<site>/M4/Down/7/5/1/8/75182711-128a-41d2-a830-45e57ca43cde.jpg?&width=954&height=450&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
Something wrong happened while adding decoding options to image: http://<site>/M4/Down/0/9/c/f/09cf5459-023d-4a32-9513-a0a36a2221cf.jpg?&width=138&height=138&mode=crop
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
[Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption!
Something wrong happened while adding decoding options to image: defaultuser.png
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
Something wrong happened while adding decoding options to image: defaultuser.png
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 
Something wrong happened while adding decoding options to image: defaultuser.png
System.NullReferenceException: Object reference not set to an instance of an object
  at FFImageLoading.Cache.ImageCache.GetBitmapFromReusableSet (Android.Graphics.Options options) [0x0009f] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask.AddInBitmapOptions (Android.Graphics.Options options) [0x0000c] in <filename unknown>:0 
  at FFImageLoading.Work.ImageLoaderTask+<GetDrawableAsync>c__async3+<GetDrawableAsync>c__AnonStoreyE+<GetDrawableAsync>c__asyncD.MoveNext () [0x0043d] in <filename unknown>:0 

ahohns avatar Dec 15 '15 00:12 ahohns

My commit fixes possible null exception but doesn't apply to [Bitmap] Called reconfigure on a bitmap that is in use! This may cause graphical corruption! @molinch any clues?

daniel-luberda avatar Dec 15 '15 04:12 daniel-luberda

Awesome investigation @ahohns ! This will definitely help. It's definitely an issue with ImageCache that gives a Bitmap still in use.

By any chance @ahohns would you have a repro that you could email me?

molinch avatar Dec 15 '15 04:12 molinch

In any case I think our implementation of cache/bitmap pool, on Android, should be closer to TangoAndCache: https://github.com/rdio/tangoandcache

I will integrate some of their nice ideas

molinch avatar Dec 15 '15 05:12 molinch

@molinch Do you want to include those changes in 2.0.0?

daniel-luberda avatar Dec 15 '15 16:12 daniel-luberda

I'm currently implementing the changes, therefore I will start to push them in a branch. We should only merge if branch is satisfying

molinch avatar Dec 15 '15 17:12 molinch

@molinch I went into work early today with the intention of trying to create a repro for you but we're close to release so was busy all day :( Will be off until Monday as well. Was basically the same as the recycled bitmap thing - loading up heaps of images on other pages then returning to the main page and browsing through the listview.

ahohns avatar Dec 16 '15 08:12 ahohns

MASSIVE change to better handle bitmap reuse (beware it's absolutely not the same as caching) done in https://github.com/molinch/FFImageLoading/commit/25c96f7c86057aff6741af15b973a528a83bbf55

It's currently only in branch better-bitmap-pool

I would be super happy if people could heavily test it @daniel-luberda @ahohns

molinch avatar Dec 16 '15 12:12 molinch

@molinch Nice work! I'm going to do some tests soon.

daniel-luberda avatar Dec 16 '15 16:12 daniel-luberda

Haven't come across anything like this so far with the new version, looking good!

ahohns avatar Dec 21 '15 04:12 ahohns

@ahohns Thanks for the info. We could close it then. Feel free to reopen it if you experience those exceptions while testing.

daniel-luberda avatar Dec 21 '15 13:12 daniel-luberda