Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11484] Android: Imageview: App is giving null pointer exception if value of image is given as '../image/xxx.jpg', which works fine for iOS.

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-12-07T19:49:05.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2012 Sprint 25, 2012 Sprint 25 API
ComponentsAndroid
Labelsapi, qe-and100112
ReporterShyam Bhadauria
AssigneePing Wang
Created2012-10-15T09:54:12.000+0000
Updated2013-11-07T18:30:39.000+0000

Description

This is not a regression. It exists as far as 2.0.1. When the value of image is given as '/image/xxx.jpg' , it works fine. But using '../image/xxx.jpg crashes the app which works fine in iOS. This issue is replicated when contentURL value is given as '../xxxx.mp4' instead of '/xxxx.mp4'. Steps to reproduce: 1. Use the code below in app.js and paste the attached image of flower in 'images' folder under resource in the app.
var win = Ti.UI.createWindow();
win.backgroundColor = 'white';

var label = Ti.UI.createLabel({
	text: 'ImageView should auto size to image and stay within the blue',
	top: 20,
	left: 10,
	height: Ti.UI.SIZE,
	width: Ti.UI.SIZE,
	color: 'black'
});

var view1 = Ti.UI.createView({
	height: 30,
	width: 60,
	top: 80,
	backgroundColor: 'red'
});

var imageView1 = Ti.UI.createImageView({
	image: '../images/flower.jpg',
	backgroundColor: 'blue'
});

view1.add(imageView1);
win.add(view1);
win.add(label);
win.open();
2. Run the app. Expected result: 1. App should run and show an imageview with flower image in it. Actual result: 1. App crashes with null pointer exception.Logs are attached.

Attachments

FileDateSize
flower.jpg2012-10-15T09:54:12.000+000017766
ImageView_Exception.rtf2012-10-15T09:54:12.000+00006415

Comments

  1. Ping Wang 2012-12-03

    The NPE does not show any more on Android using the latest master. But the flower image is not shown with the log:
       D/TiUIImageView( 9239): (main) [82,512] Retrying bitmap decode: 4/5
       W/TiDrawableReference( 9239): (AsyncTask #5) [1,513] Bitmap bounds could not be determined. If bitmap is loaded, it won't be scaled.
       W/TiDrawableReference( 9239): (AsyncTask #5) [1,514] Could not open stream to get bitmap
       D/TiUIImageView( 9239): (main) [167,681] Retrying bitmap decode: 5/5
       W/TiDrawableReference( 9239): (AsyncTask #1) [1,682] Bitmap bounds could not be determined. If bitmap is loaded, it won't be scaled.
       W/TiDrawableReference( 9239): (AsyncTask #1) [1,683] Could not open stream to get bitmap
       E/TiUIImageView( 9239): (main) [1,684] Max retries reached, giving up decoding image source: file:///android_asset/Resources/../images/flower.jpg
       D/TiUIImageView( 9239): (main) [81,765] Retrying bitmap decode: 5/5
       W/TiDrawableReference( 9239): (AsyncTask #2) [1,766] Bitmap bounds could not be determined. If bitmap is loaded, it won't be scaled.
       W/TiDrawableReference( 9239): (AsyncTask #2) [0,766] Could not open stream to get bitmap
       E/TiUIImageView( 9239): (main) [1,767] Max retries reached, giving up decoding image source: file:///android_asset/Resources/../images/flower.jpg
       
    Also tested on iOS, the flower image is not shown either.
  2. Ping Wang 2012-12-07

    In the original test case, flower.jpg is under the folder Resources/images, so the expected result should be: App should run without crash but the flower image won't show. Run the modified test case below and paste the attached flower.jpg under the folder Resources/images:
       --------------------------- app.js ----------------------------
       var Window = require('ui/win');
       new Window().open();
       
       --------------------------- Resources/ui/win.js ----------------------------
       function ApplicationWindow() {
           var self = Ti.UI.createWindow({
               backgroundColor:'#ffffff',
               navBarHidden:true
           });
           
       
       	var view = Ti.UI.createView({
       		height : 300,
       		width : 300,
       		top : 80,
       		backgroundColor : 'red'
       	});
       
       	var imageView = Ti.UI.createImageView({
       		image : '../images/flower.jpg',
       		backgroundColor : 'blue'
       	});
       
       	view.add(imageView);
       	self.add(view); 
       
                
           return self;
       }
       module.exports = ApplicationWindow;
       
    Expected Result: App runs without crash and the flower image shows correctly. The original and modified test cases run as expected. Mark the ticket as Cannot Reproduce.
  3. Shyam Bhadauria 2013-03-04

    Original test case still crashes(gives NPE) with build 3.1.0.v20130228214607 on device LG-P970 Android 2.2.2 but not over other devices.Tested with Samung GALAXY Tab 620 Android 3.2 and Samsung GALAXY Note Android 2.3.6 as well. The modified test case is working fine on all android devices.Image still do not appears on iOS(tested with iphone 5 iOS 6.0 and ipad 3 iOS 6.0) with modified test case.
  4. Shyam Bhadauria 2013-04-11

    Modified case is working fine on android.So closing the bug.

JSON Source