Chrome and Safari "Pending Request" #8

Closed
nathggns opened this Issue Feb 4, 2012 · 34 comments

Projects

None yet

2 participants

@nathggns
Contributor
nathggns commented Feb 4, 2012

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
Owner

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
Contributor
nathggns commented Feb 5, 2012

Sorry, I think you misunderstood me. Safari isn't loading the ogg file, rather, it just isn't loading any at all. In chrome, it shows up as pending. I can send you the project zipped if you want.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 06:37, Jussi Kalliokoski wrote:

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.


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

Server.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 14:59, Jussi Kalliokoski wrote:

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?


Reply to this email directly or view it on GitHub:
#8 (comment)

@nathggns
Contributor
nathggns commented Feb 5, 2012

I doubt it. My server isn't using SSL, nor does it work in Chrome.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 15:03, Jussi Kalliokoski wrote:

Could it be the same issue as this: http://stackoverflow.com/questions/8350410/mp4-video-wont-load-in-safari-status-pending-type-undefined ?


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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

@nathggns
Contributor
nathggns commented Feb 5, 2012

I can send you the project if you can't manage to reproduce.

On Sunday, 5 February 2012 at 15:13, Jussi Kalliokoski wrote:

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


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

How soon? It's quite urgent, as it's part of the project I'm writing for my ICT GCSE and I can't continue until it's fixed.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 15:23, Jussi Kalliokoski wrote:

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.


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

Will do :) This project has helped me out hugely though.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 16:44, Jussi Kalliokoski wrote:

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 events, 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


Reply to this email directly or view it on GitHub:
#8 (comment)

@nathggns
Contributor
nathggns commented Feb 5, 2012

Quick question, is the "this" variable for the finish callback the loader?

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 16:44, Jussi Kalliokoski wrote:

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 events, 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


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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

@nathggns
Contributor
nathggns commented Feb 5, 2012

Cool, that fixes a different problem I was having where the loader instance would sometimes be overridden 'cause of the way I'm doing progress bars.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 17:17, Jussi Kalliokoski wrote:

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


Reply to this email directly or view it on GitHub:
#8 (comment)

@nathggns
Contributor
nathggns commented Feb 5, 2012

BTW, it didn't work. BTW, it works on a clean cache?? Oh, and loader.getFile() is returning the page src rather than the element.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 17:17, Jussi Kalliokoski wrote:

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


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

I sent it about half an hour ago, don't know if you got it?

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 17:32, Jussi Kalliokoski wrote:

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.


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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

@nathggns
Contributor
nathggns commented Feb 5, 2012

Okay :)

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 18:39, Jussi Kalliokoski wrote:

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


Reply to this email directly or view it on GitHub:
#8 (comment)

@nathggns
Contributor
nathggns commented Feb 5, 2012

I'm not sure, but it could have something to do with ajax caching?

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 18:44, Nathaniel Higgins wrote:

Okay :)

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 18:39, Jussi Kalliokoski wrote:

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


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

Okay :)

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 19:07, Jussi Kalliokoski wrote:

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.


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

Oh, possibly. I'll try to see if it's something wrong with the files.

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 19:41, Jussi Kalliokoski wrote:

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.


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

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 Feb 5, 2012
@jussi-kalliokoski
Owner

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
Contributor
nathggns commented Feb 5, 2012

Thanks :)

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 20:10, Jussi Kalliokoski wrote:

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!


Reply to this email directly or view it on GitHub:
#8 (comment)

@nathggns
Contributor
nathggns commented Feb 5, 2012

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

@jussi-kalliokoski
Owner

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

@nathggns
Contributor
nathggns commented Feb 5, 2012

Yes. Maybe you could add an option to turn off ajax caching all together. I'd do it but I'm not familiar with pure ajax (I usually use jquery when I need to do this).

Nathaniel Higgins
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Sunday, 5 February 2012 at 20:27, Jussi Kalliokoski wrote:

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


Reply to this email directly or view it on GitHub:
#8 (comment)

@jussi-kalliokoski
Owner

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
Owner

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