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

Unity 2018 with .NET 4.X compatibility on AOT platforms crashes on fsMetaProperty.Read #157

Open
lakrsv opened this issue Jun 28, 2018 · 0 comments

Comments

@lakrsv
Copy link

lakrsv commented Jun 28, 2018

Expected Behavior

When using FullSerializer on AOT platforms with the newest runtime & compatibility level, serialization/deserialization should complete successfully.

Current Behavior

With the newest runtime (.NET 4.X) with compatibility level .NET 4.X, serialization fails on AOT platforms (Android tested in my case).

I have traced the offending line down to "return ((PropertyInfo)_memberInfo).GetValue(context, new object[] { });" in fsMetaProperty.Read(object context)

Possible Solution

I worked around this issue for myself by changing the line
return ((PropertyInfo)_memberInfo).GetValue(context, new object[] { });
to
return ((PropertyInfo)_memberInfo).GetGetMethod().Invoke(context, null);

While this seems to resolve the issues, it causes the runtime tests to fail due to exceptions being thrown on that line. Due to this, I am currently using .NET Standard 2.0 without my work-around for now. (It may be possible to implement the hotfix in a compatible way by doing some kind of null-check prior)

Solution reference here:
https://forum.unity.com/threads/unity-5-0-3f2-il2cpp-problem-attempting-to-call-method-system-reflection-monoproperty-getteradapt.332335/page-2

Steps to Reproduce

  1. Install Unity 2018.1.6f1
  2. Build the FullSerializer.Testing.test_scene.unity with configuration specified in Context(Environment)
  3. Watch it fail serialization

Context (Environment)

As Unity 2018 introduces many workflow improvements for us, I have upgraded our project to use it. I was experimenting with using the .NET 4.X compatibility level, but after hitting these issues I have decided to stay with .NET Standard 2.0 for now.

Unity Version: Unity 2018.1.6f1
FullSerializer Version (Latest commit): c01db30
Unity Target: Android 6.0, Huawei Mediapad T3
Scripting Runtime Version: .NET 4.x Equivalent
Scripting Backend: IL2CPP
Api Compatibility Level: .NET 4.x

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

1 participant