stupot Posted September 29, 2014 Share Posted September 29, 2014 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 More sharing options...
rich Posted September 29, 2014 Share Posted September 29, 2014 It's fine in Chrome and FF here. I suspect it's fine in any browser that supports Web Audio actually, and is a side-effect of IE being shite using Audio tags to load audio files, which throws it out of the normal loader sequence. lewster32 1 Link to comment Share on other sites More sharing options...
stupot Posted September 30, 2014 Author Share Posted September 30, 2014 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 More sharing options...
rich Posted September 30, 2014 Share Posted September 30, 2014 It should still load sequentially though, that's the bug I think, not the context as such. The issue is that it shouldn't even try and carry on loading more files until the Audio file is completed. If you could stick this on github issues that'd be great. Link to comment Share on other sites More sharing options...
stupot Posted September 30, 2014 Author Share Posted September 30, 2014 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 More sharing options...
stupot Posted September 30, 2014 Author Share Posted September 30, 2014 Probable fault found and solution posted in github issue. Link to comment Share on other sites More sharing options...
Recommended Posts