Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Chrome and Safari "Pending Request" #8

Closed
nathggns opened this Issue · 34 comments

2 participants

@nathggns

So I'm having trouble using this. When ever I tell the script to load the file, it doesn't, it just creates a unknown "pending" request in Chrome and Safari. The weird thing is, is it works when running from chrome developer tools. I've also tried running it from an window load event listener, but it still doesn't work. Works fine in Firefox.

The code I'm using

var loader = new html5Preloader(file);

The result:

result

@jussi-kalliokoski

This is odd, and not least because Safari shouldn't support Ogg Vorbis. I will try to reproduce so I can root out the problem.

@nathggns
@jussi-kalliokoski

But that should be exactly the case since Safari doesn't support ogg, but it shouldn't create a pending request, though. Is this in file:/// environment or on a server?

@nathggns
@nathggns
@jussi-kalliokoski

All right then, thanks for the info, I'll try to figure it out.

@nathggns
@jussi-kalliokoski

Nah, please hang on a bit, I'm releasing a new version (a complete rewrite) soon and let's see if this becomes fixed along with it.

@nathggns
@jussi-kalliokoski

Well, apparently it took a few hours. There might be some bugs in there, and it's backwards incompatible, but I think you'll like the new syntax, as it supports multiple event handlers, etc, having a built-in event emitter. Also, now all the requests are run in parallel, so it's a lot faster for most cases.


var loader = new html5Preloader('sound*:sound.ogg||sound.mp3');

loader.on('finish', function () {
  console.log('all files loaded');
  loader.getFile('sound').play();
});

loader.on('error', function (e) {
  console.error(e);
});

loader.on('fileloaded', function () {
  console.log(this.filesLoaded, 'file(s) loaded out of', this.filesLoading);
});

If you could try it out (the h5p.js in /js/) to see if the issue was fixed, would be awesome. Also if you find bugs using it, would be much appreciated if you file them as well. :)

Hope it works!

Cheers,
Jussi

@nathggns
@nathggns
@jussi-kalliokoski

Yes, all the events have the loader instance bound as this. Wrote loader in the example out of being used to it. :)

@nathggns
@nathggns
@jussi-kalliokoski

Ok, now I need to look at your project! :D Just pop a link as a priv msg or as an attachment on my gmail, the address is my github handle except that the dash is a dot.

@nathggns
@jussi-kalliokoski

Yeah, I got it, sorry I was putting my kid to sleep, looking at it now.

@nathggns
@nathggns
@jussi-kalliokoski

I don't think so, it's not doing any XHR in this case, there's some reference error going on in the error handling of my new version, causing the root document to be returned instead of the failed audio element. I'll try to go deeper to find out where exactly this is happening.

@nathggns
@jussi-kalliokoski

All right then, the issue of the main document being returned instead of the error event is now fixed, but what it basically means is that there's an error in the load, so the behavior was actually caused because A) the URLs to the sound files are incorrect / the files don't exist B) the files may be malformed and the browser doesn't parse them correctly. The reason it might have been working in Firefox is probably that Firefox has a cache error and doesn't check from the server if the file actually exists, but just fetches it directly from cache. These kind of cache errors happen often if Firefox crashes or has some kind of an error while downloading some resources.

@nathggns
@jussi-kalliokoski

Oh, found one bug affecting WebKit browsers, but that wasn't present in the old version, so it's not related. Also, it's fixed now. :) Could you see for me if this page works for your versions of Safari and Chrome: http://labs.avd.io/h5p/ ? If it does, I think the error isn't in html5Preloader.

@nathggns

The music played... And it seems the update fixed it but I didn't realise as the code I used to test it had some errors in. Thanks so much :)

@nathggns nathggns closed this
@jussi-kalliokoski

No problem, great that you got it working! :) Also, thanks for giving me the reason to finally sit down and do the rewrite ;) Good luck with your project!

@nathggns
@nathggns

Now that is weird, the problem just returned without changing a line of code.

@jussi-kalliokoski

Very odd, sounds like there's something wrong with caching from the browser's side.

@nathggns
@jussi-kalliokoski

Yeah, but it's not doing any XHR, so I don't think that applies here. Also, you can already disable caching for the files that end up as XHRs by starting the url with an exclamation mark. new html5Preloader('!http://server.com/doc.xml') Can you try another server with different/default configuration?

@jussi-kalliokoski

You might want to try the latest version, I found and fixed race condition error that might occur when audio/video is used. The bug caused the finish event to be fired prematurely sometimes. Not sure it would affect your case since you were loading just one file per loader, though, but it's worth a shot. Also, seemed to affect only Firefox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.