Skip to content

Commit

Permalink
Guard against onTrimMemory NullPointerException. (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrtwhite authored Sep 13, 2022
1 parent 0e9c1ab commit 11f4b40
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions coil-base/src/main/java/coil/RealImageLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ internal class RealImageLoader(
/** Called by [SystemCallbacks.onTrimMemory]. */
@Suppress("SAFE_CALL_WILL_CHANGE_NULLABILITY", "UNNECESSARY_SAFE_CALL")
internal fun onTrimMemory(level: Int) {
// https://github.com/coil-kt/coil/issues/1211
memoryCacheLazy?.value?.trimMemory(level)
// https://github.com/coil-kt/coil/issues/1443
try {
memoryCacheLazy?.value?.trimMemory(level)
} catch (_: NullPointerException) {}
}

override fun shutdown() {
Expand Down

0 comments on commit 11f4b40

Please # to comment.