Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidOperationException: Current error context error is different to requested error. #18

Closed
gw1108 opened this issue Feb 23, 2017 · 4 comments

Comments

@gw1108
Copy link

gw1108 commented Feb 23, 2017

I've been using Giles and the "Play Custom Map" will seemingly randomly spit out this error when loading a particular level. This level would load fine just 5 minutes ago.

InvalidOperationException: Current error context error is different to requested error. Newtonsoft.Json.Serialization.JsonSerializerInternalBase.GetErrorContext (System.Object currentObject, System.Object member, System.String path, System.Exception error) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/Serialization/JsonSerializerInternalBase.cs:93) Newtonsoft.Json.Serialization.JsonSerializerInternalBase.IsErrorHandled (System.Object currentObject, Newtonsoft.Json.Serialization.JsonContract contract, System.Object keyValue, IJsonLineInfo lineInfo, System.String path, System.Exception ex) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/Serialization/JsonSerializerInternalBase.cs:111) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:182) Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/JsonSerializer.cs:823) Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/JsonSerializer.cs:802) Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/JsonConvert.cs:865) Newtonsoft.Json.JsonConvert.DeserializeObject[pb_SceneNode] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) (at C:/Users/George/Downloads/Json.Net.Unity3D-master/Json.Net.Unity3D-master/src/Newtonsoft.Json/JsonConvert.cs:822) GILES.pb_Scene.LoadLevel (System.String levelJson) (at Assets/Lib Assets/GILES/Code/Scripts/pb_Scene.cs:157) GILES.Example.pb_SceneLoader.OnLevelWasLoaded (Int32 i) (at Assets/Lib Assets/GILES/Code/Scripts/pb_SceneLoader.cs:47)

I've loaded levels and they usually work fine. Minutes later some levels start spitting out this error. I've tried making duplicates of the .json files to see if the .json file is corrupted somehow but the json file is identical. Remaking the file from scratch always fixes the problem temporarily.

I've pulled the Unity Json project from https://github.com/SaladLab/Json.Net.Unity3D and built my own .dll and .pdb files so I can look deeper into what's going on. Inside json it throws the exception basically at this line https://github.com/SaladLab/Json.Net.Unity3D/blob/master/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs#L182. The exception has a stacktrace of this:
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0012c] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519 at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x0000e] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:77 at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass3_0.<CreateParameterizedConstructor>b__0 (System.Object[] a) [0x00003] in C:\\Users\\George\\Downloads\\Json.Net.Unity3D-master\\Json.Net.Unity3D-master\\src\\Newtonsoft.Json\\Utilities\\LateBoundReflectionDelegateFactory.cs:59 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializable (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonISerializableContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00197] in C:\\Users\\George\\Downloads\\Json.Net.Unity3D-master\\Json.Net.Unity3D-master\\src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:1746 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00410] in C:\\Users\\George\\Downloads\\Json.Net.Unity3D-master\\Json.Net.Unity3D-master\\src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:587 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0007c] in C:\\Users\\George\\Downloads\\Json.Net.Unity3D-master\\Json.Net.Unity3D-master\\src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:293 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x000a6] in C:\\Users\\George\\Downloads\\Json.Net.Unity3D-master\\Json.Net.Unity3D-master\\src\\Newtonsoft.Json\\Serialization\\JsonSerializerInternalReader.cs:167

So now I'm not sure if it's because I'm using procore meshes as prefabs, prefabs with children, or json is invoking a method that doesn't exist.

@gw1108
Copy link
Author

gw1108 commented Feb 23, 2017

I've investigated further and it seems one object in particular is causing eventual problems. One of my prefabs is an empty gameObject with Pb_Meta Data Component attached. It has 3 child objects. 2 of the child objects have Mesh Filters and Mesh Renderers. The third object has a box collider and some C# monobehaviours I wrote.

I found this out by saving a level in Giles that only had this prefab. After an hour Giles was no longer able to open the .json level and gave the above crash. I'll be creating even simpler prefabs to see if I can recreate it again.

@karl-
Copy link
Contributor

karl- commented Feb 23, 2017

@gw1108
Copy link
Author

gw1108 commented Feb 23, 2017

Here are two example files. Both were created with just an empty Gameobject with a child object that had the Unity Mesh Filter(cube) and Mesh Renderer. Default material. The difference between the two files are the Version=2.0.6262.37719. If you merge the fixed Version= into the Broken Version= it'll fix the Json error. Not sure what this Version thing is or how it breaks anything.

ParentChildMeshFilter_broken.json.txt
ParentChildMeshFilter_working.json.txt

@gw1108
Copy link
Author

gw1108 commented Mar 1, 2017

Figured it out. Turns out I was using a c# file that incremented the assembly build version a lot. Taken from here: http://xeophin.net/en/blog/2014/05/09/simple-version-numbering-unity3d

For some reason the JSON reader doesn't like it when you do that so I commented the file out and now no more of this error.

@gw1108 gw1108 closed this as completed Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants