-
-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images are not loaded after couple of restarts #40
Comments
get the same issue, some image is loaded but the remain images are broken and throw error Failed assertion: line 362 pos 12: '_codec != null': is not true. |
We have the same error. It means in our case that when an image has been tried to load the first time in offline mode, thus resulting in error, it won't load ever again correctly even when reconnected. As a workaround I have wrapped |
I am trying to understand what's going wrong, but I don't really understand it.. I tried to breakpoint the code when using an app offline, but it doesn't get past this code in CacheManager.getFile
I also found that the synchronized doesn't seem to work the way I expected and that the singleton design seems to be broken. I could not find any sources on how to make a Singleton when the initialization phase needs an await (is asynchronous). I also suspect that the synchronized might be broken in dart 2.0. |
@renefloor you can create a quick fix my checking map for null in your code before pushing to CacheObject |
@lemonboston any chance you can share or PR? |
Could you check whether this is fixed in 0.4.1? I did multiple improvements, so I am not sure whether this case is fixed. |
didn't see that happening again with 0.4.1 |
I don't see the exception with 0.4.1 either, although the issue with these steps still happens:
But if I close and restart the app, then that particular image is loaded correctly (I don't know if that was the case with 0.4.0 as well or not). @Cyan101 my workaround was not a fix for this library, just guarding |
@lemonboston that is indeed still a problem. See also the conversation in https://github.com/renefloor/flutter_cache_manager/issues/9 and issue #41. |
Why is that closed? |
Here is how i made it work for now try to add this to the main or before :
This will init the cache manager if its null so _cacheData will not be null : static Future getInstance() async { CacheManager._(); SharedPreferences _prefs; static Object _lock = new Object(); ///Shared preferences is used to keep track of the information about the files _getSavedCacheDataFromPreferences() { |
I guess this is a cause of the #38 #36 #35
This is a stacktrace of the error:
Also I've found that error happened in this code:
So in debugger I see that
_loadAsync
returns with error and then codec becomes nullThen I go deeper and found that error happens in cache_object.dart in method
CacheObject.fromMap(String url, Map map)
because map is null. Map is null because ofCacheManager
class and its_getSavedCacheDataFromPreferences
method. Inside_keyCacheData
we can found an empty string with null map.To be clear
_keyCacheData
has"": null
inside. I don't know why it is there, but this is the cause.The text was updated successfully, but these errors were encountered: