I’m trying to bring in 3 external files :
One png using WWW class
One file containing a path as a string - either text using www in XML using XMLReader
One XML document
I can get them all in and working fine, but if I use the WWW or the XMLReader twice in a script, then the app crashes on application.quit - no problem at all when running.
If I use one of each (1 WWW and 1 XMLReader) it quits cleanly and swiftly with no crash.
I’ve tried Disposing the WWWs and Closing the XMLReaders and no joy - it’s the last hurdle in the project and is very frustraiting!
Is this a bug or a limitation?
It seems like Unity (or me) is not releasing the resources if more than one of the classes is used
It’s all within one script on the Main Camera.
Hope someone can help!
Rob
Im not really sure what you are doing, but Im useing multiple www’s (a hell of a lot actually) and XmlNodeReader’s (ye alot of them too) and Im not having any problems with crashes.
maybe you can give a bit more info? i.e. a code snippet?
Although we still have a crashbug in firefox we havnt found yet. Are you using firefox? win or osx?
//perlohmann
Extracts of the main script…
In the Start function is this…
var myDataURL = "file:config.txt";
var wwwXML = new WWW(myDataURL);
yield wwwXML;
XMLDataPath = wwwXML.data;
wwwXML.Dispose();
myXmlReader = new XmlTextReader(XMLDataPath);
//Working Blow
var myURL = "file:schoolLogo.png";
var www = new WWW(myURL);
yield www;
schoolLogo = [url]www.texture;[/url]
www.Dispose();
then in the update is this…
if (Input.anyKey) {
myXmlReader.Close();
Application.Quit();
}
It reads in a user definable path from the config.txt file which points the script to the XML file’s URL and then displays a dynamic graph. The other WWW is just to load in an external logo.
It’s designed to have basic screensaver functionality - touch a key and it quits, but generally it’s just a running app.
This crash is in OSX - not in a browser.
Thanks
Rob
I think the file url is wrong.
like http where the protocol is http://, the file protocol is file:// not file: as you used it there which potentially could lock the www and kill it if you try to get rid / reinit it.
When Application.Quit is called I get…
“The Application House Points Display quit unexpectedly”
Console gives…
15/07/2009 09:34:19 com.apple.launchd[425] ([0x0-0xb00b0].unity.Semantise.House Points Display[4666]) Exited abnormally: Abort trap
I’ve changed the protocol now but it still crashes on quit.
The app runs perfectly with the multiple calls to WWW or XML, it’s only when quitting it crashes.
Thanks for the help so far!..
Rob
well you could first of all use the if (wwwXML.error == "")
to verify that no error occured when downloading the file.
Don’t get any errors, but thanks for the suggestion!
Seems like I’ve narrowed it down a dozen times to different things, but the current thing is making this change fixes it…
myXmlReader = new XmlTextReader(“http://localhost/testing/house_point_data.xml”);
changed to
myXmlReader = new XmlTextReader(“house_point_data.xml”);
There is the correct XML file in both locations but accessing it using http:// seems to break things,
Rob
wondering if it’s a permissions thing…investigating…
Nope not a permissions thing 
hmm java isnt my strongest side but you might wanna explicit declare the XMLDataPath as a TextAsset (var XMLDataPath : TextAsset = …).
and then use XMLDataPath.text to get the “string”
this is a snippet of some code Ive used using assetbundles, XMLDocument and C#.
TextAsset xmlFile = (TextAsset)bundle.mainAsset;
string text = xmlFile.text;
//for some reason the assetbundle has added an empty character at the beginning of the string.... so remove it
if (text[0] != '<')
{
//Debug.Log("first char not \"<\"");
text = text.Remove(0, 1);
}
try
{
xmlDoc.LoadXml(text);
}
catch (XmlException xmlError)
{
Debug.Log(xmlError.Message);
Debug.Log(xmlError.StackTrace);
}
since www dosnt give any error I do not think the problem is that it cant find the file.
Im not really sure the XMLTextReader can access a “web” related file but look it up on msdn to be sure.
I’ve had a look at the msdn docs for XMLReader and the examples use things like this…
reader = new XmlTextReader(“http://localhost/baseuri.xml”);
I’m starting to think that it’s a problem with my network/apache rather than Unity as both local and http://localhost… access both work fine and deliver the data from the XML file, it’s just that somehow unity can’t let go of the XML when it’s quitting if the http is used.
I’ve kicked it off to the clients to test on their network and we’ll see if they have the same problems,
Thanks all for your help!
Rob