Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8669] Android: ImageView triggers error event only once

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-04-02T11:24:17.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.0.2
ComponentsiOS
Labelsapi, parity
ReporterMarkus Krug
AssigneeShameer Jan
Created2012-04-10T13:06:35.000+0000
Updated2017-03-21T22:04:47.000+0000

Description

Problem

On Android, the error event is only triggered once if an image is not accessible. On iOS, it triggers the error event each time. Which is better in my opinion.

Test case

var win = Ti.UI.createWindow({backgroundColor: 'white'});
win.open();
 
function createImageView (params) {
    var imageView = Ti.UI.createImageView(params);
 
    imageView.addEventListener('load', function (event) {
        Ti.API.info('load event');
    });
 
    imageView.addEventListener('error', function (event) {
        Ti.API.info('error event');
    });
 
    return imageView;
}
 
Ti.API.info('loading first image');
win.add(createImageView({image: 'https://invalid.url/doesnotexist.png', width: 200, height: 100, top: 50}));
 
setTimeout(function () {
    Ti.API.info('loading second image');
 
    win.add(createImageView({image: 'https://invalid.url/doesnotexist.png', width: 200, height: 100, top: 150}));
}, 2000);
When executing this code, you'll notice that the error event is just displayed once in error log. The load event is never triggered. On iOS the error event is triggered twice. This is especially inappropriate if the image is not available for just a short time. On the next app start the error event is also not triggered since it is cached. It should try to reload the image.

Community Discussion

Q&A [Android Parity: ImageView triggers error event only once](http://developer.appcelerator.com/question/135037/android-parity-imageview-triggers-error-event-only-once) I've also explained why I need the error event.

Log

D/TiAssetHelper(  410): Fetching "app.js" with Fastdev...
I/TiAPI   (  410): loading first image
D/dalvikvm(  410): GC_EXTERNAL_ALLOC freed 537K, 53% free 2895K/6087K, external 1967K/2137K, paused 159ms
I/TiRootActivity(  410): (main) [0,0] checkpoint, on root activity resume. activity = de.test.mobile.TestMobileActivity@405a4498
D/dalvikvm(  410): GREF has increased to 201
E/TiDownloadManager(  410): (pool-3-thread-1) [31,31] Exception downloading https://invalid.url/doesnotexist1.png
E/TiDownloadManager(  410): java.net.ConnectException: invalid.url/62.157.140.133:443 - Connection refused
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:207)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
E/TiDownloadManager(  410): 	at java.net.Socket.connect(Socket.java:983)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:74)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:298)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:381)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeConnection(HttpsURLConnectionImpl.java:369)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:510)
E/TiDownloadManager(  410): 	at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:247)
E/TiDownloadManager(  410): 	at java.net.URL.openStream(URL.java:645)
E/TiDownloadManager(  410): 	at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:157)
E/TiDownloadManager(  410): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
E/TiDownloadManager(  410): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
E/TiDownloadManager(  410): 	at java.lang.Thread.run(Thread.java:1019)
I/TiAPI   (  410): error event
I/TiAPI   (  410): loading second image
D/dalvikvm(  136): GC_EXPLICIT freed 50K, 51% free 2971K/5959K, external 4969K/5664K, paused 51ms
I/InputReader(   62): Device reconfigured: id=0x0, name=qwerty2, display size is now 480x854
I/InputManager-Callbacks(   62): No virtual keys found for device qwerty2.

Comments

  1. Shameer Jan 2013-04-02

    Issue does not reproduces Tested with Titanium Studio, build: 3.2.0.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
  2. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced and due to the above comments.

JSON Source