Ti.UI.createImageView fails to decode image on creation (log attached) in Android 2.2 (NookColor and Emulator). The Android 2.3.6 Device and Tab 3.1 have a separate error of filenotfound (attached), but the iPhone Simulator 5.0 and iPhone 5.0 correctly load and decode the remote image. Local images work in all cases.
Android 2.2 Error Log Excerpt:
12-01 14:12:07.093: W/TiDrawableReference(374): (main) [6,1703] Bitmap bounds could not be determined. If bitmap is loaded, it won't be scaled.
12-01 14:12:07.103: D/skia(374): --- SkImageDecoder::Factory returned null
12-01 14:12:07.113: E/TiUIImageView(374): (main) [20,1723] Max retries reached, giving up decoding image source:
http://www.zoomout.gr/assets/media/PICTURES/???????/651_thumb1.jpg
Android 2.3.6, 3.1 Error Log Excerpt:
12-01 15:11:26.505: E/TiDownloadManager(2872): (pool-3-thread-1) [365,13155] Exception downloading
http://www.zoomout.gr/assets/media/PICTURES/???????/651_thumb1.jpg
12-01 15:11:26.505: E/TiDownloadManager(2872): java.io.FileNotFoundException:
http://www.zoomout.gr/assets/media/PICTURES/???????/651_thumb1.jpg
12-01 15:11:26.505: E/TiDownloadManager(2872): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:521)
12-01 15:11:26.505: E/TiDownloadManager(2872): at java.net.URL.openStream(URL.java:645)
12-01 15:11:26.505: E/TiDownloadManager(2872): at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:134)
12-01 15:11:26.505: E/TiDownloadManager(2872): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
12-01 15:11:26.505: E/TiDownloadManager(2872): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
12-01 15:11:26.505: E/TiDownloadManager(2872): at java.lang.Thread.run(Thread.java:1019)
Steps to Reproduce:
1. Run the following code in a new app.
Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({backgroundColor:'#fff'});
var test_img = Titanium.UI.createImageView({image:'http://www.zoomout.gr/assets/media/PICTURES/ΜΟΥΣΙΚΗ/651_thumb1.jpg'});
win.add(test_img);
win.open();
Expected Result:
Image should download, decode and display.
Actual Result:
No image displays, errors log to the console. Android 2.2 has decode errors, Android 2.3.6 has filenotfound errors, iOS Simulators/Devices work correctly.
Note:
The local image 'KS_nav_ui.png' works as expected across platforms.
This bug has been fixed a while back. The fix is simple in JS:
It is not possible for us to automatically URL-encode specific portions of URLs, because we can't know if (or what parts) of the URL are safe for encoding. iOS does have some automagic here, but IIRC there are cases where it will break and be too optimistic about encoding (which there is no way to get out of). We provide a method already for allowing explicit control of URL encoding called
encodeURIComponent
Closing ticket as the issue will not fix.