Hi All
Long time Unity user here, but this is my first question, my actual problem is already solved but I'd like to know a little more about what on earth is going on.
So the problem that led to this. I have a system that reads xml files for meta data, XmlSerializer class is used for this and all worked fine. Today I added a new file and on desktop everything was fine but when I built for WebGL suddenly it started crashing, I tinkered around a little thinking there must be something wrong with the new file, but no, it was just whatever file was loaded last would cause the crash during XmlSerializer.Deserialize, with the error
"missing function pthread_create"
After lots of digging I ended up in the Mono XmlSerializer code on github
[XmlSerializer.cs][1] (sorry to link to github, it's just late :( )
So in there it turns out that there is a variable 'generationThreshold' that once exceeded switches the generation of the readers to a method that uses threads (or something like that) that doesn't work in WebGL builds.
I've fixed this for now by increasing the value from 50 to 100 like so
System.Environment.SetEnvironmentVariable("MONO_XMLSERIALIZER_THS", "100");
No big deal, but my question is, how can I avoid just having to set this variable to some insanely high number, which could be detrimental to performance, and why once I'm done with the serializer does the value this effects 'serializerData.UsageCount' not decrease, it just keeps getting bigger as far as I can tell.
Hopefully the above will be useful to someone anyway, but I'd love someone with more indepth knowledge of Monos serialization to tell me more about what's going on.
Thanks
Tom
PS
Thanks to everyone that answers questions on here, it's why I've never had to ask one before ;)
[1]: https://github.com/mono/mono/blob/master/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs
↧