-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a method of frame waiting that resets when we get certain trim me…
…mory callbacks. The GL context may be destroyed on TRIM_MEMORY_MODERATE or higher. We could strictly listen to that callback, but we'd end up racing because we only get trimMemory on the UI thread and decodes happen on multiple background threads. Hopefully by resetting when the app is backgrounded we can minimize those races. PiperOrigin-RevId: 337927814
- Loading branch information
1 parent
6d7c484
commit b0a7efe
Showing
11 changed files
with
179 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
library/src/main/java/com/bumptech/glide/manager/FirstFrameAndAfterTrimMemoryWaiter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bumptech.glide.manager; | ||
|
||
import android.app.Activity; | ||
import android.content.ComponentCallbacks2; | ||
import android.content.res.Configuration; | ||
import android.os.Build; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.RequiresApi; | ||
|
||
@RequiresApi(Build.VERSION_CODES.O) | ||
final class FirstFrameAndAfterTrimMemoryWaiter implements FrameWaiter, ComponentCallbacks2 { | ||
|
||
@Override | ||
public void registerSelf(Activity activity) {} | ||
|
||
@Override | ||
public void onTrimMemory(int level) {} | ||
|
||
@Override | ||
public void onConfigurationChanged(@NonNull Configuration newConfig) {} | ||
|
||
@Override | ||
public void onLowMemory() {} | ||
} |
9 changes: 7 additions & 2 deletions
9
library/src/main/java/com/bumptech/glide/manager/FirstFrameWaiter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.bumptech.glide.manager; | ||
|
||
import android.app.Activity; | ||
import android.os.Build; | ||
import androidx.annotation.RequiresApi; | ||
|
||
interface FirstFrameWaiter { | ||
void registerSelf(Activity activity); | ||
@RequiresApi(Build.VERSION_CODES.O) | ||
final class FirstFrameWaiter implements FrameWaiter { | ||
|
||
@Override | ||
public void registerSelf(Activity activity) {} | ||
} |
12 changes: 0 additions & 12 deletions
12
library/src/main/java/com/bumptech/glide/manager/FirstFrameWaiterO.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
library/src/main/java/com/bumptech/glide/manager/FrameWaiter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.bumptech.glide.manager; | ||
|
||
import android.app.Activity; | ||
|
||
interface FrameWaiter { | ||
void registerSelf(Activity activity); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.