Coder Social home page Coder Social logo

System.Reflection.Emit about jace HOT 14 OPEN

pieterderycke avatar pieterderycke commented on July 28, 2024 1
System.Reflection.Emit

from jace.

Comments (14)

pieterderycke avatar pieterderycke commented on July 28, 2024 1

@strangenoora I am happy to read that it solved your issue. I will document it in the readme.

from jace.

pieterderycke avatar pieterderycke commented on July 28, 2024

The problem is that Jace is using System.Reflection.Emit for its dynamic compiler (to generate and compile dynamically .NET functions) which is what is not possible on Unity. A potential solution could be to use Jace in interpreted mode: it will be slower, but it will not rely on the dynamic compiler.

Would you be able to test this workaround?

from jace.

KoalaHao avatar KoalaHao commented on July 28, 2024

Thanks for the reply
I'll test it out when I get the chance to.
Also, how much performance hit are we talking about with interpreted vs compiled?

from jace.

pieterderycke avatar pieterderycke commented on July 28, 2024

See the first page of this github repository. But it heavily depends on how many times you reuse the same function. If you don't reuse compiles functions then there will not be a lot of performance difference

from jace.

Giorgi avatar Giorgi commented on July 28, 2024

@KoalaHao If you only need basic arithmetic you can use Math Expression Evaluator which doesn't user Reflection.Emit but still supports compiled mode

from jace.

KoalaHao avatar KoalaHao commented on July 28, 2024

I tried interpreted mode, and I am on the 0.8.5 version, i think it has bugs with interpreted version, will upgrade and try again later

from jace.

pieterderycke avatar pieterderycke commented on July 28, 2024

I am not aware of bugs with the interpreted mode of 0.8.5, but would it be possible to test a more recent version? In case you have issues, let me know and I will look to investigate it.

from jace.

KoalaHao avatar KoalaHao commented on July 28, 2024

I still havn'nt test the new version yet, but the bug of 0.8.5 is in interpreted mode, all variables gets converted into lower case, then it tries to match with a "not converted to lower case" string, which results in variable not found error

from jace.

pieterderycke avatar pieterderycke commented on July 28, 2024

version 0.8.5 is 5 years old, so I recommend to upgrade to the newest version. It contains a number of bug fixex.

from jace.

pieterderycke avatar pieterderycke commented on July 28, 2024

@KoalaHao Did you already had time to try a more recent version of Jace inside a Unity project?

from jace.

strangenoora avatar strangenoora commented on July 28, 2024

Hey there, I have a similar issue. I have a Unity project using the latest version of Unity and a version of Jace I downloaded in August. Performance is not critical for me, I am using Jace because it's nice to let non-programmers to edit game balancing formulas in text. It worked great for me until I switched the scripting backend from Mono (Unity default) to IL2CPP (which is required to make a x64 build for Android, which is required by Google Play Store since August 1st this year).

Here's the error I get

ExecutionEngineException: Attempting to call method 'System.Linq.Expressions.Interpreter.LightLambda::MakeRun1<Jace.FormulaContext,System.Double>' for which no ahead of time (AOT) code was generated. System.Func2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)
System.Linq.Expressions.Expression1[TDelegate].Compile (System.Boolean preferInterpretation) (at <00000000000000000000000000000000>:0) Jace.Execution.DynamicCompiler.BuildFormula (Jace.Operations.Operation operation, Jace.Execution.IFunctionRegistry functionRegistry, Jace.Execution.IConstantRegistry constantRegistry) (at <00000000000000000000000000000000>:0) System.Func2[T,TResult].Invoke (T arg) (at <00000000000000000000000000000000>:0)`

Googling ExecutionEngineException I found this in the Unity manual
https://docs.unity3d.com/Manual/ScriptingRestrictions.html

Could you help me figure out a workaround like this for my project?

from jace.

strangenoora avatar strangenoora commented on July 28, 2024

After investigating further, I think a workaround won't be possible after all. The manual I linked specifically says namespace System.Reflection.Emit simply isn't supported. I will test Interpreted mode instead.

from jace.

strangenoora avatar strangenoora commented on July 28, 2024

I tried the interpreted mode and it works like a charm.
Sorry for the spam!

Can I suggest adding a note in the readme for Unity projects (using IL2CPP) to consider using the Interpreted mode?

from jace.

KoalaHao avatar KoalaHao commented on July 28, 2024

@KoalaHao Did you already had time to try a more recent version of Jace inside a Unity project?

Sorry I didn't have time to try the new version. I've fixed the caps problem, force use interpreted mode, and it works

from jace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.