Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17692] iOS: Cannot load saved images anymore

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-09-26T20:15:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.4.0, Release 3.5.0
ComponentsiOS
LabelsTCSupportTriage, regression
ReporterJérôme Danthinne
AssigneeJon Alter
Created2014-09-10T12:45:10.000+0000
Updated2014-11-21T20:26:09.000+0000

Description

This was working fine with SDK 3.3.0, but since 3.4.0-beta, my app cannot load previously saved images anymore... message = "invalid image type"; [ERROR] : nativeLocation = "-[TiUIImageView setImage_:] (TiUIImageView.m:685)"; [ERROR] : nativeReason = "expected TiBlob, String, TiFile, was: TiBlob"; Strangely, it seems to expect a TiBlob, and gets one, but doesn't load it...

Comments

  1. Ingo Muschenetz 2014-09-10

    Thank you for the report. Can you please provide a test case?
  2. Jérôme Danthinne 2014-09-10

    Here's a very small part of my app, causing the bug. First pick an image, then click "Show Image" to load it.
       <Alloy>
       	<Window class="container" layout="vertical">
       		<Button title="Pick Image" onClick="PickImage" top="50" />
       		<Button title="Show Image" onClick="ShowImage" />
       		<ImageView id="imageView" width="Ti.UI.FILL" height="300"></ImageView>
       	</Window>
       </Alloy>
       
       var imageFilename = "test.jpg";
       function PickImage() {
       	Ti.Media.openPhotoGallery({
       		mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
       		success: function(event) {
       			var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename);
       			if (f.exists()) {
       				f.deleteFile();
       				f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename);
       			}
       			f.write(event.media);
       		}
       	});
       }
       function ShowImage() {
       	var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename);
       	if (f.exists()) {
       		var imageBlob = f.read();
       		$.imageView.image = imageBlob;
       	}
       }
       $.index.open();
       
  3. Ingo Muschenetz 2014-09-15

    Possibly related to TIMOB-16882.
  4. Jon Alter 2014-09-15

    PR master: https://github.com/appcelerator/titanium_mobile/pull/6083 PR 3_4_X: https://github.com/appcelerator/titanium_mobile/pull/6084

    Steps to Test

    1. Click "Pick Image" 2. Select a photo 3. Click "Show Image" 4. The image should now be visible at the bottom of the screen.

    Test Code

       var win = Ti.UI.createWindow({
       	backgroundColor: 'white'
       });
       win.open();
       
       var button1 = Ti.UI.createButton({
       	title: 'Pick Image',
       	top: 50,
       	height: 50
       });
       button1.addEventListener('click', function() {
       	PickImage();
       });
       win.add(button1);
       
       var button2 = Ti.UI.createButton({
       	title: 'Show Image',
       	top: 150,
       	height: 50
       });
       button2.addEventListener('click', function() {
       	ShowImage();
       });
       win.add(button2);
       
       var imageView = Ti.UI.createImageView({
       	width:Ti.UI.FILL,
       	height:300,
       	bottom: 0,
       	backgroundColor: 'blue'
       });
       win.add(imageView);
       
       var imageFilename = "test.jpg";
       function PickImage() {
           Ti.Media.openPhotoGallery({
               mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
               success: function(event) {
                   var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename);
                   if (f.exists()) {
                       f.deleteFile();
                       f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename);
                   }
                   f.write(event.media);
               }
           });
       }
       function ShowImage() {
           var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory + imageFilename);
           if (f.exists()) {
               var imageBlob = f.read();
               imageView.image = imageBlob;
           } else {
           	console.log("image does not exist");
           }
       }
       
  5. Ewan Harris 2014-09-17

    Verified fix on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201409131030 Titanium SDK build: 3.4.0.v20140916151649 Titanium CLI, build: 3.4.0-rc4 Alloy: 1.5.0-rc2 Xcode6 GM Seed iPhone Device 5 (8.0 GM Seed) Used the above test code and built to device. The image was shown on the screen after I selected it and clicked 'Show Image'. Closing ticket.

JSON Source