{"action":"created","issue":{"url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/382","repository_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading","labels_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/382/labels{/name}","comments_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/382/comments","events_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/382/events","html_url":"https://github.com/luberda-molinet/FFImageLoading/issues/382","id":189516724,"number":382,"title":"Images sometimes don't load on android","user":{"login":"rusty21","id":10209880,"avatar_url":"https://avatars.githubusercontent.com/u/10209880?v=3","gravatar_id":"","url":"https://api.github.com/users/rusty21","html_url":"https://github.com/rusty21","followers_url":"https://api.github.com/users/rusty21/followers","following_url":"https://api.github.com/users/rusty21/following{/other_user}","gists_url":"https://api.github.com/users/rusty21/gists{/gist_id}","starred_url":"https://api.github.com/users/rusty21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rusty21/subscriptions","organizations_url":"https://api.github.com/users/rusty21/orgs","repos_url":"https://api.github.com/users/rusty21/repos","events_url":"https://api.github.com/users/rusty21/events{/privacy}","received_events_url":"https://api.github.com/users/rusty21/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-15T21:49:15Z","updated_at":"2016-11-17T14:53:52Z","closed_at":null,"body":"Alright so I'm still seeing this error occur on android and it causes images not to get loaded into image views. \r\n\r\n    Image loading failed: https://s3.amazonaws.com/fanlete/uploads/dee371d0c35a816d22b067d8862b9cfd2db062c8.png System.NullReferenceException: Object reference not set to an instance of an object.\r\n    at FFImageLoading.Collections.StrongLruCache`2[TKey, TValue].Add (TKey key, TValue value, System.Boolean overwrite) [0x000ae] in C:\\projects\\ffimageloading\\source\\FFImageLoading.Droid\\Collections\\StrongLruCache.cs:146 \r\n    at FFImageLoading.Collections.StrongLruCache`2[TKey, TValue].Add (TKey key, TValue value) [0x00000] in C:\\projects\\ffimageloading\\source\\FFImageLoading.Droid\\Collections\\StrongLruCache.cs:113 \r\n    at FFImageLoading.Cache.ReuseBitmapDrawableCache.Add (System.String key, FFImageLoading.Drawables.ISelfDisposingBitmapDrawable value) [0x0006a] in C:\\projects\\ffimageloading\\source\\FFImageLoading.Droid\\Cache\\ReuseBitmapDrawableCache.cs:352 \r\n    at FFImageLoading.Cache.ImageCache.Add (System.String key, FFImageLoading.Work.ImageInformation imageInformation, FFImageLoading.Drawables.ISelfDisposingBitmapDrawable bitmap) [0x00042] in C:\\projects\\ffimageloading\\source\\FFImageLoading.Droid\\Cache\\ImageCache.cs:95 \r\n\r\nI figured to track this down I was going to need to download the FFImageloading source and add it to my project so I could step through the code and figure out where things were going wrong. Here's what I think I've learned. The error occurs in this block of code in StrongLruCache.cs\r\n\r\n\t145         while (CheckEvictionRequired()) {\r\n\t146\t\tOnWillEvictEntry(list.First.Value, dict[list.First.Value]);\r\n\t147\r\n\t148\t\tevictions = evictions ?? new Dictionary<TKey, TValue>();\r\n\t149\t\tevictions[list.First.Value] = dict[list.First.Value];\r\n\t150\r\n\t151\t\tdict.Remove(list.First.Value);\r\n\t152\t\tlist.RemoveFirst();\r\n\t153\r\n\t154\t\traiseEntryRemovedDueToEviction = true;\r\n\t155\t    }\r\n\r\nThe error occurs on line 146. The LinkedList<T> list variable is empty. So list.First is null and list.First.Value throws the null reference exception error.\r\n\r\nYou can correct me if I'm wrong but what it appears is happening is the StrongLruCache class is a base class for ByteBoundStrongLruCache. This class I believe attempts to keep track of the number of total bytes in the StrongLruCache. \r\n\r\nIn the ByteBoundStrongLruCache there is an override for CheckEvictionRequired() which looks like:\r\n\r\n\tprotected override bool CheckEvictionRequired()\r\n\t{\r\n\t\tlock (monitor) {\r\n\t\t\tif (current_cache_size > high_watermark) {\r\n\t\t\t\thas_exceeded_high_watermark = true;\r\n\t\t\t\treturn true;\r\n\t\t\t} else if (has_exceeded_high_watermark && current_cache_size > low_watermark) {\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\thas_exceeded_high_watermark = false;\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\nTo me this basically is saying if we exceeded the high water mark keep saying we need to evict entries until we've reached the low water mark. The logic here seems sound. It appears as though the variable current_cache_size is somehow not correctly keeping track of the actual number of bytes held onto by the StrongLruCache. When the null reference exception is generated the LinkedList<T> list is empty, and current_cache_size is greater than low_watermark. If the LinkedList is empty then it stands to reason that current_cache_size should also be 0. \r\n\r\nThe effect of all of this is that the ByteBoundStrongLruCache keeps telling the StrongLruCache to evict entries when there are no entries to evict, causing the null reference exception. \r\n\r\nTesting and Moto g Android 5.1 with VS2015. If theres anything else you need from me let me know. "},"comment":{"url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/comments/261267301","html_url":"https://github.com/luberda-molinet/FFImageLoading/issues/382#issuecomment-261267301","issue_url":"https://api.github.com/repos/luberda-molinet/FFImageLoading/issues/382","id":261267301,"user":{"login":"rusty21","id":10209880,"avatar_url":"https://avatars.githubusercontent.com/u/10209880?v=3","gravatar_id":"","url":"https://api.github.com/users/rusty21","html_url":"https://github.com/rusty21","followers_url":"https://api.github.com/users/rusty21/followers","following_url":"https://api.github.com/users/rusty21/following{/other_user}","gists_url":"https://api.github.com/users/rusty21/gists{/gist_id}","starred_url":"https://api.github.com/users/rusty21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rusty21/subscriptions","organizations_url":"https://api.github.com/users/rusty21/orgs","repos_url":"https://api.github.com/users/rusty21/repos","events_url":"https://api.github.com/users/rusty21/events{/privacy}","received_events_url":"https://api.github.com/users/rusty21/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T14:53:52Z","updated_at":"2016-11-17T14:53:52Z","body":"Been testing on various phones and views and things are looking good. I haven't had a single image throw an exception. "}}
{"actor":{"display_login":"rusty21"}}