Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Unity internal JSonNet is colliding with JSonNet in Plugins folder

Discussion in 'Editor & General Support' started by starabanaf, Oct 5, 2020.

  1. starabanaf

    starabanaf

    Joined:
    Jun 26, 2019
    Posts:
    8
    After installing Burst and Collections packages I got a new internal Unity jSon.Net package called "
    com.unity.nuget.newtonsoft-json@2.0.0-preview".
    and problem is that I am also using JSon.Net in my project that is mandatory for me. And it is colliding with the internal Unity JSon.Net package

    According to documentation:
    https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@1.1/manual/index.html
    This is a package intended for internal Unity Development Projects and as such this package is not supported. Use it at your own risk.

    Hm but I am forced to use it because I cannot block it from being downloaded as a dependency of one of the packages.

    As a temporal solution, I've removed it from PackageCache but Unity time to time restores it and it is annoying. I've created a bug ticket and waiting for a response.

    How can I fix this issue? Is there a workaround for it?
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,187
    I remember this coming up in the past, but I don't recall the overall solution. I personally used to have a JSON.Net plugin in my project, and I believe I experienced collisions with that DLL and Burst. In my case, I deleted my local plugin and instead started using the package version. The info on the Newtonsoft package specifically calls out that it can be use to avoid assembly clashes:

    upload_2020-10-5_11-59-10.png

    It sounds like we're using fairly similar packages here, so maybe that'll work for you too.
     
  3. starabanaf

    starabanaf

    Joined:
    Jun 26, 2019
    Posts:
    8
    Thanks for your answer. I am not seeing it in my PackageManager, it is invisible. How you make it visible in the package manager? Are you using Unity 2020?

    The problem is that Unity's internal plugin is not working on iOS and it is not working with DropBox.dll I used in my project that needed some another specific JSon.net. So I have currently two json.net in project one for iOS and another for Editor and DropBox.dll. So I really don't need to have additional Unity one colliding with other jSon.net dlls I already have.

    I've found that this is a dependency of package "com.unity.test-framework.performance"
    So I've removed it manually from package.json. But it is possible to block this dependency completely?
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,187
    I'm using unity 2019.4.11. I'm not sure why it might not be showing up. I don't think it's a "Preview" package, but you might need to make sure you're showing preview packages:

    upload_2020-10-6_14-0-41.png

    If that doesn't work, I believe you can always manually add the entry to your `manifest.json' file in your project:
    Code (CSharp):
    1. "com.unity.nuget.newtonsoft-json": "2.0.0",
    It's possible that's how I added it at some point, I don't recall.
     
  5. starabanaf

    starabanaf

    Joined:
    Jun 26, 2019
    Posts:
    8
    Thanks. But I need to remove it completely somehow.

    I've fixed it temporally by manually adding
    com.unity.collections@0.9.0-preview.6 and com.unity.test-framework.performance@2.0.8-preview into Plugin folder
    and removing them from manifest.json. So now all works like it should so test-framework.performance is now using my own json.net dll.

    Unity please add a way to ignore your internal stuff like json.net dll. I don't want to have it messing with my assemblies. Or use a different namespace for your stuff so it is not intersecting with dlls with same name.
    I need some clarification how this should be solved in general?
     
    thehen2 likes this.
  6. starabanaf

    starabanaf

    Joined:
    Jun 26, 2019
    Posts:
    8
    Unity dev team. Could you give me any comments on this issue?
    1. How I can use my own JSon.net library in my project together with com.unity.collections package?
    2. Why your library has not compiled under the Unity namespace and uses a Newtonstoft namespace that creates an issue for me?
    3. Should I expect you to use any other generic libraries in the future for your packages and expect to have more colliding issues?
     
  7. gekidoslayer

    gekidoslayer

    Unity Technologies

    Joined:
    Sep 27, 2016
    Posts:
    134
    Do you have any more details about what the issues might be that are forcing you to have multiple json.net dll's in your project?

    The team chose to publish the newtonsoft package under the original namespace to simplify integration into user projects and reduce maintenance complexity going forward.

    One of the original reasons we published this package in the first place was to try and solve the original issue you have mentioned - the newtonsoft parser is a very common / popular package so the hope was to try and eliminate the need for different projects to depend on their own versions, causing conflicts like you have described.
     
  8. starabanaf

    starabanaf

    Joined:
    Jun 26, 2019
    Posts:
    8
    Hi mikew,
    I see your points, this makes sense but probably this solution is not flexible enough and needs some adjustments. This does not help me to solve my problems
    I have currently this issues:
    1. I have Dropbox.dll in my project that is required a specific version of json.net and not working with your json.net. Dropbox.dll is required for some internal Editor processes to import files and assets into Unity. So it should be there.
    2. Your json.net not working on iOS and webgl platforms. So I used a fork of JSON .net called jillejr.newtonsoft.json-for-unity@12.0.301 instead.

      So I have 2 different json.dlls, one for Editor mode, another for standalone/mobile deployment. And now I have a third dll from Unity itself as part of test framework dependency. How I can solve this problem in the current Unity compilation pipeline?
     
    Last edited: Oct 15, 2020
  9. starabanaf

    starabanaf

    Joined:
    Jun 26, 2019
    Posts:
    8
    Any updates / comments?
     
  10. Sevdanski

    Sevdanski

    Joined:
    Nov 14, 2013
    Posts:
    5
    So I just spent the better part of a day trying to dance around this issue that you have created.

    I added in the Remote Config package to an old project I am updating, and it brought along your version of JSON.NET. It collided with my existing library so I removed the original as suggested. Seemed to run fine until I got in on the device - suddenly things started not saving.

    After much trial an error I finally discovered that the problem was with a HashSet<string> - it was failing to deserialize. Saving the data worked and serialized it correctly, but when I went to load the data in on boot, it failed with a message about a null value.

    I was lucky on this project because it is simple and I could easily change the HashSet to a List with no problems, but I can see my larger projects being totally wrecked by your package.

    I found another forum post which put me on the right track: https://forum.unity.com/threads/unable-to-deserialize-hashsets.962805/

    Going through the forums, I can see that this is an ongoing issue. It really needs a better fix. Change yoru package name or let us disable it or something.