Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

WebGL build doesn't work 2017.1 (ExecutionEngineException)

Discussion in 'WebGL' started by Ichimitsu, Sep 3, 2017.

  1. Ichimitsu

    Ichimitsu

    Joined:
    Oct 9, 2014
    Posts:
    24
    ExecutionEngineException: Attempting to call method 'GetActionDelegate' for which no ahead of time (AOT) code was generated.
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation
    (Filename: currently not available on il2cpp Line: -1)

    Code (CSharp):
    1. Delegate GetActionDelegate<T>(object handlerValue)
    2. {
    3.     var method = handlerValue.GetType().GetMethod("Invoke");
    4.  
    5.     return new Action<T>(value =>
    6.     {
    7.         method.Invoke(handlerValue, new object[] { value });
    8.     });
    9. }
    Does anyone know what to do?
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    This can happen with an AOT compiler like IL2CPP. We need to know all of the possible types T at compile time. Often with generics that is not possible. To troubleshoot this, first we need to determine what the type of T is when the exception occurs. You can probably do with with logging:

    Code (CSharp):
    1. Debug.Log(typeof(T).FullName);
    Once we know that, then you can change the code to make an explicit call to GetActionDelete with that type. That will allow IL2CPP to see that type is used, and generate the proper code for it to be called at runtime.
     
  3. Ichimitsu

    Ichimitsu

    Joined:
    Oct 9, 2014
    Posts:
    24
    Thanks, I rewrote the code so that the T type was known at the compilation stage. Now everything works.
     
    JoshPeterson likes this.