Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28324] iOS: image from filereader function not being called

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2021-05-18T18:28:50.000+0000
Affected Version/sn/a
Fix Version/sRelease 10.0.0, Release 9.3.3
ComponentsiOS
Labelsfile, iOS, image
ReporterSamir Mohammed
AssigneeVijay Singh
Created2021-01-20T10:49:12.000+0000
Updated2021-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

FileDateSize
ClownFish.jpg2021-01-20T10:49:08.000+00001044897
Earth.jpg2021-01-20T10:49:10.000+00001860714

Comments

  1. Vijay Singh 2021-03-16

    Workaround is add following line - earthFileStream.addEventListener('pump', fileReader); inside function loadEarth .
  2. Vijay Singh 2021-03-18

    PR - https://github.com/appcelerator/titanium_mobile/pull/12616
  3. Satyam Sekhri 2021-03-22

    FR Passed. Waiting for Jenkins build
  4. Christopher Williams 2021-03-23

    merged to master, 10_0_X and 9_3_X branches.

JSON Source