Skip to content

Bug: Does not work with UniTask in WebGL (IL2CPP) #44

@nopjia

Description

@nopjia

When I try to have both this package and UniTask included in my project, the Converters stopped working when built to WebGL. They would still work fine in Editor. I spent a day trying out different scenarios in a fresh project, all of the following scenarios fail:

  • Importing UniTask and simply having it in the project in the Packages folder
  • Calling JsonConvert.SerializeObject() from both normal synchronous and asynchronous function
  • Linking UniTask into asmdef
  • Linking Converters into asmdef

Expected behavior

Serialize JSON when built and run in WebGL, while UniTask is also included in the project.

Actual behavior

This still works in Editor and Desktop build. Crash while running in WebGL. It seems the Converters aren't being built. Error:

JsonSerializationException: Self referencing loop detected for property 'normalized' with type 'UnityEngine.Vector3'. Path 'normalized'.

Steps to reproduce

  • New project
  • Import jillejr.newtonsoft.json-for-unity via UPM
  • Import jillejr.newtonsoft.json-for-unity.converters via UPM
  • Import UniTask via UPM
  • Create asmdef and add UniTask
  • Add following script to scene:
void Start() {
  str = JsonConvert.SerializeObject(new Vector3(0, 2.5f, 5.1f));
}
  • Switch to WebGL
  • Build and Run

Details

Host machine OS running Unity Editor: Windows 10

Unity build target: WebGL

Newtonsoft.Json-for-Unity package version: 12.0.301

Newtonsoft.Json-for-Unity.Converters package version: 1.0.0

I was using Unity version: 2018.4.18f1, 2019.4.11f1

Checklist

  • Shutdown Unity, deleted the /Library folder, opened project again in Unity, and problem still remains.
  • Checked to be using latest version of the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions