Jump to content

failed audio file request gets reported as failed image request in IE


stupot
 Share

Recommended Posts

Hi,

 

I've been having some problems with phaser in IE10, having worked around some unexpected behaviour I noticed some more problems.

 

I was getting console errors reporting failed image requests although the browser network log shows successful image requests.  Then I noticed some prior audio file request failures - fixing these and the image failures also went away.

 

It turns out that the function fileError() is being called with the wrong index.  At the time of the audio file failure, fileError is getting called with the current index of a subsequent file request, and not the index of the audio file.

 

I put together a jsfiddle example to show this. It 1st requests a non-existant audio file, then it requests a number of image files.  At the time the audio file load fails, it will be someway down the image file requests, so the actual fimage file it reports as failing will vary.

 

I was initially using IE10, it looks like IE11 does it too, other browsers maybe, haven't tried.

 

So, goto http://jsfiddle.net/stupot/84b6x7s4/, open the console, clear the cache and refresh, you'll see the image file error.

 

Then comment out the 1st line in preload (beginning with game.load.audio) , clear the cache and hit reload - the image error has gone!  Anyone care to have a crack at it

Link to comment
Share on other sites

Agreed, IE is a bit shite challenging.

 

It seemed to me that in Phaser.Loader.prototype.loadFile(), the 'this' context is saved in the variable '_this' but that gets modified by subsequent usage such that when the failure is triggered the error call is using the current context rather than the required context.  Sounds reasonable and the code looks wrong.

 

However, I tried modifying it such that the required context was saved off in a local closure where the file.data.onerror function is set, but I didn't get it right, and it was late and I was tired, so with fingers crossed I hoped the magical internet fairies would fix it whilst I slept.

Link to comment
Share on other sites

Th onerror function is definitely being called later on after other files have been loaded, such that the fileError function is using the wrong _fileIndex, so it tags the wrong 'error' property to true.

 

I got it to remember the right file index so it reports the right file failing, but this still does happen later on after other files have loaded - but if it's not supposed to be progressing like you say, then this is the real fault.  In fact it still goes on to then do a "Phaser.Loader loadFile invalid index" probably because my fix fixes a sympton rather than the underlying cause.

 

Github issue created here: https://github.com/photonstorm/phaser/issues/1212

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...