Kamel-Media / Kamel

Kotlin asynchronous media loading and caching library for Compose.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Null pointer exception in LruCache on iOS

DJ-LEE11 opened this issue · comments

Affected platforms

  • iOS

Versions

  • Kamel version*: 0.7.0

Crash Info
7CBCA0D1DA9016C4587CDD705

Occurrence location
infoflow 2023-11-01 16-32-55

LinkedHashMap is thread-unsafe.

Yeah, that's definitely an issue with the LRU Cache. How often does it happen? Do you have a way to reproduce it regularly?

It's not thread safe:
see:
apollographql/apollo-kotlin#2878
apollographql/apollo-kotlin#2844

looks like using https://github.com/ReactiveCircus/cache4k could be a solution?

This crash happened by chance.
Our current solution is to use Ktor provide thread-safe ConcurrentMap to replace LinkedHashMap.

infoflow 2023-11-01 16-10-59
Screenshot 2023-11-02 at 3 32 32 AM

Making sure we use the same coroutineContext when loading a cached resource might be the issue. Idk have to look into it more.

but then again I don't think using a suspend there would be ideal 🤔

try 0.9.0 lmk if you have any problems. I switch it to being backed by stately's ConcurrentMutableMap