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

fix(android): return 0 for recycled images when clearing cache #14156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 14, 2024

When TiBlobLruCache.getInstance().evictAll(); is called it will currently display:

[WARN]  Bitmap: Called getRowBytes() on a recycle()'d bitmap! This is undefined behavior!
[WARN]  Bitmap: Called getHeight() on a recycle()'d bitmap! This is undefined behavior!

This fix will check if it is recycled or not and then just return 0 and not try to calculate the size.

Test

var img = Ti.UI.createImageView();
var win = Ti.UI.createWindow();

win.addEventListener("click", function() {
	Ti.Media.showCamera({
		success: function(event) {
			img.image = event.media;

			var f1 = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory + "/image3.jpg");
			f1.write(event.media.imageAsResized(20, 20));
		}
	});
});

win.add(img);
win.open()
  • Start the app
  • click the window and take a picture
  • repeat it multiple times

Result:

  • 12.6.0.GA: warnings as mentioned above
  • with this PR: no warnings

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

Successfully merging this pull request may close these issues.

1 participant