-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
refactor(android): optimize ImageView image download peformance #13078
Conversation
Fixes TIMOB-28538
Tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although unrelated to your changes, I'm seeing that TiDrawableReference is retrying a bad image URL up to seven times. There's old code that does this due to a bug from Android 2.3 😱
We should change DEFAULT_DECODE_RETRIES
to 2
, amend this for
to:
for (int i = 1; i < decodeRetries; i++) {
and increase this timeout to 1000ms or 3000ms
android/titanium/src/java/org/appcelerator/titanium/util/TiLoadImageManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: PASS
FT: PASS
Here's a modified ListViewImageRemoteNoCacheTest.js test so you can verify the images that are loaded are not the same.
const imageUrls = [
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifFlipHorizontal.jpg',
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifFlipVertical.jpg',
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifRotate180.jpg',
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifRotate270.jpg',
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifRotate90.jpg',
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifTranspose.jpg',
'https://github.com/appcelerator/titanium_mobile/raw/master/tests/Resources/ExifTransverse.jpg',
];
function createListViewSectionItems() {
const items = [];
for (let index = 1; index <= 1000; index++) {
const url = imageUrls[index % imageUrls.length];
items.push({ properties: {
title: `Row ${index}: ${url.split('/')[9]}`,
image: url
}});
}
return items;
}
const window = Ti.UI.createWindow();
window.add(
Ti.UI.createListView({
templates: {
template: {
properties: { layout: 'vertical' },
childTemplates: [
{
type: 'Ti.UI.ImageView',
bindId: 'image',
properties: { width: 160 }
},
{
type: 'Ti.UI.Label',
bindId: 'title',
properties: {
color: 'black',
font: { fontSize: '20dp', fontWeight:'bold' }
}
}
]
}
},
defaultItemTemplate: 'template',
sections: [
Ti.UI.createListSection({
headerTitle: 'ListView',
items: createListViewSectionItems(),
})
],
})
);
window.open();
Also verified error event still triggers, as this test was failing on Jenkins.
const win = Ti.UI.createWindow();
const img = Ti.UI.createImageView();
img.addEventListener('error', e => {
alert(`Error loading image:\n\n${e.image}`);
});
img.image = 'https://invalid.host.com/image.jpg';
win.add(img);
win.open();
FR Passed. |
JIRA:
Summary:
ImageView
image url download performance when:No-Cache
.TiDrawableReference.Key
class which guarantees uniqueness.TiImageLruCache
and replaced withTiImageCache
.TiDownloadManager
,TiLoadImageManager
,TiFileHelper
, andTiBlobLruCache
.TiDownloadManager
on startup if there were several ImageViews on screen. Can cause performance initial performance issues since thread pool size would be ignored.ImageView
"decodeRetries" property default from5
to2
.ListView Complex Template Test:
ListViewTemplateComplexTest.js
attached to TIMOB-28538 on Android.ListView No-Cache Test:
ListViewImageRemoteNoCacheTest.js
attached to TIMOB-28538 on Android.Image Hash Code Collision Test:
FP.jpg
andG1.jpg
attached to TIMOB-18786 to project's./assets/images
folder.ImageHashTest.js
attached to TIMOB-18786 as your "app.js".