Skip to content

Instantly share code, notes, and snippets.

@ant1441
Last active July 15, 2016 13:56
Show Gist options
  • Save ant1441/df7fe450dea975cc6a12e9c41798654d to your computer and use it in GitHub Desktop.
Save ant1441/df7fe450dea975cc6a12e9c41798654d to your computer and use it in GitHub Desktop.
Chrome Image Loading issue
<!doctype HTML>
<html>
<div><h1 id="out"></h1></div>
<div id="images" style="display: block;"></div>
<script>
var state = {
total: 500,
count: 0,
fail: 0
};
setInterval(function(){
console.log(state.count, state.fail);
document.getElementById("out").innerHTML = "Loaded: " + state.count + "/" + state.total + " (" + state.fail + " errored)";
}, 500);
function loadImage(path) {
var img = new Image;
img.onload = function(e){
state.count++;
};
img.onerror = function(e){
state.fail++;
console.groupCollapsed(path + " (" + state.fail + ")");
console.log("Error loading image");
console.log(e);
console.log(img);
console.groupEnd();
};
img.src = "./" + path + "?_="+(Math.random());
// document.getElementById("images").appendChild(img);
}
console.log("Images: " + state.total);
for (var i = 0; i < state.total; i++) {
loadImage("cat.jpg");
}
</script>
</html>

Image taken from http://placekitten.com/2001/800. Issue appears on Chrome on Android, versions:

  • Chrome 51.0.2704.81 (32-bit)
  • Chrome beta (52.0.2743.62) (32-bit)
  • Chromium 54.0.2798.0 (32-bit) Developer Build

go version go1.6.2 linux/amd64

Running the sever with GODEBUG=http2server=0 to disable HTTP/2, we do not see the issue

package main
import (
"log"
"net/http"
)
func main() {
err := http.ListenAndServeTLS(":443", "<PATHTO>/fullchain.pem", "<PATHTO>/privkey.pem", http.FileServer(http.Dir(".")))
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment