Skip to content
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

[BUG] Android- Blobcache sometimes null. why or how to handle it? #641

Open
EmilAlipiev opened this issue Jan 4, 2021 · 2 comments
Open
Labels

Comments

@EmilAlipiev
Copy link

Describe the bug
I am seeing regularly below exception in my exception logs.

JsonSerializationMixin.GetObject[T] (Akavache.IBlobCache This, System.String key)
System.ArgumentNullException: Value cannot be null. Parameter name: source

at System.Reactive.Linq.Observable.SelectMany[TSource,TResult] (System.IObservable`1[T] source, System.Func`2[T,TResult] selector) <0x7c91370e34 + 0x000e0> in <11c0ec0fa99843708cbf96b5e08890cd>:0 \n  at Akavache.JsonSerializationMixin.GetObject[T] (Akavache.IBlobCache This, System.String key)

I am not sure why it is occurring but it seems that maybe BlobCache is null according to the source code, if i am reading it correct.

 public static IObservable<T> GetObject<T>(this IBlobCache blobCache, string key)
        {
            if (blobCache is null)
            {
                throw new ArgumentNullException(nameof(blobCache));
            }

            if (blobCache is IObjectBlobCache objCache)
            {
                return objCache.GetObject<T>(key);
            }

            return blobCache.Get(GetTypePrefixedKey(key, typeof(T))).SelectMany(DeserializeObject<T>);
        }

If thats the case in what cases it maybe null ? I initialize akavache right inside the App.cs Constructor as

            Akavache.BlobCache.ApplicationName = "myCache";
            Akavache.BlobCache.EnsureInitialized();

and I only use Shutdown in Ondestroy

   protected override void OnDestroy()
        {         
                base.OnDestroy();
                Akavache.BlobCache.Shutdown().Wait();  // this calls the shutdown code
                Akavache.BlobCache.UserAccount = null; // clear out the static cached variables
 }
 

If that is so far fine what could be the reason BlobCache is null after initialized?

@EmilAlipiev EmilAlipiev added the Bug label Jan 4, 2021
@glennawatson
Copy link
Contributor

I want to go through Akavache and give it some love soon. I'll look into your exception then.

@angelru
Copy link

angelru commented Jan 25, 2022

The same thing happens to some users of my Android application...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants