XML and sound files are not loaded in PhoneGap build, iOS.
Opened this issue ยท 4 comments
The problem:
Running my game on IPhone 5 (IOS 10.2), wrapped with Cordova - no error, images load fine, but sounds and XML files don't trigger "fileload" event.
Result: my game works with no error, but has no sounds and no texts (I use createjsbitmaptext, which needs to load xml file to work).
Additional info:
Note that the same game works perfectly in Safari on the same device.
This game also works fine with PhoneGap+Cordova+Crosswalk on Android.
I narrowed down the root of the problem using this piece of code:
function loadFonts() {
window.addEventListener('error', function(e) {
console.log("coun't load: "+ e.target.src);
alert("coun't load: "+ e.target.src);
}, true); //This simply displays and logs an error in case of "404, file not found".
var fontManifest = [
{src: "fonts/bsfGrey.png", id: "bsfGrey"},
{src: "fonts/bsfGrey.xml", id: "bsfGrey_xml"}
{src: "fonts/bsfTest.png", id: "bsfTest"}, //This file doesn't exist (test 404 error handler)
{src: "fonts/bsfTest.xml", id: "bsfTest_xml"} //This file doesn't exist (test 404 error handler)
];
var loader = new createjs.LoadQueue(false);
var fontData = {};
loader.addEventListener("fileload", fontFileLoaded);
loader.addEventListener("complete", allFontsLoaded);
loader.loadManifest(fontManifest);
function fontFileLoaded(evt) {
fontData[evt.item.id] = evt.result;
console.log("fileLoaded:" + evt.result); //logging and alerting if file loads.
alert("fileLoaded:" + evt.result);
}
}
In XDK emulator, it works as expected: logs and alerts 2 times "404 not found" (for intentionally missing xml and png) and logs 2 fileload events.
On a real device I get the following output:
"fileLoaded" - for fonts/bsfGrey.png
"couldn't load:" - for sbfText.png (as expected, because there is no such file)
And that's it.
Loading fonts/bsfTest.xml should throw an error, because this file doesn't exist. But nope, no error!
And loading fonts/bsfGrey.xml should alert "fileLoaded" - but it doesn't.
WTF.
Building in Intel XKD (cloud build).
Tried targeting: IOS (8.0 or 9.0), adhoc profile, using createjs-2015.11.26.min.js
I don't know how to poke this issue any further. Any help is welcome.
Its possible that a missing file response that is not an actual 404 could be interpreted as a success. Web Audio and XML are both loaded as text, so this could explain it.
That makes sense, but doesn't help me resolve the problem in any way.
I've wrapped my app using CocoonJS instead of IntelXDK and it works just fine.
So I don't have to fight this problem anymore.
I'm still willing to try finding out the cause of the problem, just out of curiosity.
Have you got an idea on what should I log, so I could further narrow down the issue?
Without a test case, this is hard to solve. I am going to leave it open, as we should do some more investigation on preloading in PhoneGap/Cordova for the next version.
This may be a rare problem, and it doesn't bother me anymore. Feel free to close\ignore it. ๐
If someone else gets this problem and you decide to investigate, I could send you a project where I had this issue.
As for my projects - I found a workaround by using CocoonJS, so it may be not a CreateJS\Cordova issue, but something about Intel XDK. Don't know, don't wanna waste any more time on it ๐