Ticket #2806 (closed bug: duplicate)

Opened 3 years ago

Last modified 2 years ago

loadend not fired in IE6 when a tile fails loading

Reported by: bartvde Owned by: ahocevar
Priority: minor Milestone: 2.12 Release
Component: Tile.Image Version: 2.9
Keywords: Cc:
State:

Description

this.imgDiv._attempts is undefined, 1 and 2, so this condition will never become true:

if (this.imgDiv._attempts > OpenLayers.IMAGE_RELOAD_ATTEMPTS) {

It should have been 1, 2 and 3 however.

So it seems OpenLayers.Util.onImageLoadError is run after the local onerror handler, indeed this is the case, I verified.

Change History

Changed 3 years ago by bartvde

I've got no good idea on how to fix this one unfortunately, anybody else?

Changed 3 years ago by bartvde

See also:

 http://dl.dropbox.com/u/513327/event_order.html

<!DOCTYPE html>
<html>
<head>
<title>Event order</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script type="text/javascript">
  function addEvent(num) {
    function handler() {
      document.getElementById('result').innerHTML += '<li>' + num + '</li>';
    }

    if (typeof document.addEventListener !== 'undefined') {
      window.addEventListener('load', handler, false);
    }
    else if (typeof document.attachEvent !== 'undefined') {
      window.attachEvent('onload', handler);
    }
  }

  var i = 1;
  while (i <= 30) addEvent(i++);
</script>
</head>
<body>
<p>IE < 9 executes in randomish order :P</p>
<ol id="result"></ol>
</body>
</html>

Changed 3 years ago by bartvde

The only fix I could come up with is something like:

        // Bind a listener to the onerror of the image div so that we
        // can registere when a tile has finished loading with errors.
        var onerror = function() {

            // if this happens, we know we are running before OpenLayers.Util.onImageLoadError
            if (this.imgDiv._attempts === undefined) {
                this._runningFirst = true;
            }

            // If we have gone through all image reload attempts, it is time
            // to realize that we are done with this image. Since
            // OpenLayers.Util.onImageLoadError already has taken care about
            // the error, we can continue as if the image was loaded
            // successfully.
            if ((this._runningFirst === true && this.imgDiv._attempts >= OpenLayers.IMAGE_RELOAD_ATTEMPTS) ||
                (this._runningFirst === undefined && this.imgDiv._attempts > OpenLayers.IMAGE_RELOAD_ATTEMPTS)) {
                    onload.call(this);
            }
        };

Changed 2 years ago by ahocevar

  • status changed from new to closed
  • resolution set to duplicate

This issue is addressed in #3419. Marking as duplicate.

Note: See TracTickets for help on using tickets.