Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ final class ImageReaderSurfaceProducer
// Flip when debugging to see verbose logs.
private static final boolean VERBOSE_LOGS = false;

// If we cleanup the ImageReaders on memory pressure it breaks VirtualDisplay
// backed platform views. Disable for now as this is only necessary to work
// around a Samsung-specific Android 14 bug.
private static final boolean CLEANUP_ON_MEMORY_PRESSURE = false;

private final long id;

private boolean released;
Expand Down Expand Up @@ -649,6 +654,9 @@ PerImage dequeueImage() {

@Override
public void onTrimMemory(int level) {
if (!CLEANUP_ON_MEMORY_PRESSURE) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect to re-enable this code path again soon? Is there another reason we want to keep it around instead of fully reverting the changes from the original PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not going to re-enable this code path but want the option to do that in the future :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

}
cleanup();
createNewReader = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,12 @@ public void ImageReaderSurfaceProducerTrimMemoryCallback() {
assertEquals(1, texture.numImages());

// Invoke the onTrimMemory callback.
// This should do nothing.
texture.onTrimMemory(0);
shadowOf(Looper.getMainLooper()).idle();

assertEquals(0, texture.numImageReaders());
assertEquals(0, texture.numImages());
assertEquals(1, texture.numImageReaders());
assertEquals(1, texture.numImages());
}

// A 0x0 ImageReader is a runtime error.
Expand Down