[TIMOB-28324] iOS: image from filereader function not being called
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-05-18T18:28:50.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.0, Release 9.3.3 |
Components | iOS |
Labels | file, iOS, image |
Reporter | Samir Mohammed |
Assignee | Vijay Singh |
Created | 2021-01-20T10:49:12.000+0000 |
Updated | 2021-05-18T18:28:54.000+0000 |
Description
On iOS the 2nd image which is being read in by filereader is not being loaded but on Android it works as expected.
*+Test Case:+*
var win = Ti.UI.createWindow({
backgroundColor:'white'
});
var earthFile,
earthFileStream,
earthBuffer;
function fileReader(args) {
if (args.bytesProcessed === -1) {
Ti.API.error('Done');
Ti.API.info(earthBuffer.toBlob().height + ' . ' + earthBuffer.toBlob().width + ' . ' + earthBuffer.toBlob().mimeType);
earthImage.image = earthBuffer.toBlob();
Ti.API.info(earthImage.image.height + ' . ' + earthImage.image.width + ' . ' + earthImage.image.mimeType);
earthBuffer.release();
earthImage.animate({
opacity: 1,
duration: 100
});
} else {
Ti.API.error(args.bytesProcessed + ' of ' + args.totalBytesProcessed);
if (earthBuffer === null) {
earthBuffer = Ti.createBuffer();
}
earthBuffer.append(args.buffer);
}
}
function loadEarth() {
earthImage.image = null;
earthImage.opacity = 0;
earthFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, '/Earth.jpg');
earthFileStream = Ti.Filesystem.openStream(Ti.Filesystem.MODE_READ, earthFile.nativePath);
earthBuffer = null;
Ti.Stream.pump(earthFileStream, fileReader, 512, true);
}
var fishImage = Ti.UI.createImageView({
left: '10dp',
top: '10dp',
right: '10dp',
height: '200dp',
image: '/ClownFish.jpg'
});
win.add(fishImage);
var earthImage = Ti.UI.createImageView({
left: '10dp',
bottom: '10dp',
right: '10dp',
height: '200dp',
opacity: 0
});
earthImage.addEventListener('singletap', loadEarth);
win.add(earthImage);
loadEarth();
win.open();
*+Test Steps:+*
Create an application with the test case above
Make sure app thinning is disabled in the tiapp.xml
add the two images attached below into the resources folder
Run application on iOS
*+Actual result:+* 2nd image does not load and nothing is logged in the console. *+Expected result:+* 2nd image should load and log the following
[ERROR] Done
[INFO] 1600 . 2560 . image/jpeg
[INFO] 1600 . 2560 . image/jpeg
Attachments
File | Date | Size |
---|---|---|
ClownFish.jpg | 2021-01-20T10:49:08.000+0000 | 1044897 |
Earth.jpg | 2021-01-20T10:49:10.000+0000 | 1860714 |
Workaround is add following line - earthFileStream.addEventListener('pump', fileReader); inside function loadEarth .
PR - https://github.com/appcelerator/titanium_mobile/pull/12616
FR Passed. Waiting for Jenkins build
merged to master, 10_0_X and 9_3_X branches.