Search Unity

Is it IL2CPP generating bug? or my mistake?

Discussion in 'Scripting' started by sdf_eee, Nov 30, 2015.

  1. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Environment: Unity 5.2.3f1 (5.2.2f1 with same problem), Xcode 7.1.1

    After some code writing, and I try to build.
    and I got this error from iOS/64bit build with IL2CPP.


    then, I search U3CPrivateImplementationDetailsU3E_ctor_m11_xxxx from Il2CppMethodPointerTable.o.
    I can find it.



    and I can find it too from g_MethodPointers[].




    BUT I can not find this method's body from any generated native cpp. I think, It was something wrong.
    So, I make build success by code revert. and I can find method body.

    and


    What is this situation? the code is it.
    Code (CSharp):
    1. // sdf: IL2CPP error.
    2. public partial class DialogBalloon
    3. {
    4.     //public enum DialogType
    5.     //{
    6.     //    Exclamation,
    7.     //    Question,
    8.     //    Confusion,
    9.     //    Talk
    10.     //}
    11.  
    12.     //public IEnumerator DialogProcess()
    13.     //{
    14.     //    _transform.localScale = Vector3.zero;
    15.     //    SetActive(true);
    16.  
    17.     //    const float maxTime = 0.15f;
    18.  
    19.     //    var elapsedTime = 0.0f;
    20.     //    while (elapsedTime < maxTime)
    21.     //    {
    22.     //        elapsedTime += Mediator.GetTimeDelta();
    23.     //        _transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, elapsedTime / maxTime);
    24.  
    25.     //        yield return null;
    26.     //    }
    27.  
    28.     //    yield return new WaitForSeconds(1.0f);
    29.  
    30.     //    SetActive(false);
    31.     //}
    32. }
    when I change this comment to code, error occur.
    I was experienced this situation with "private delegate void Func()" too.

    but really weird side is another classes have no problem with enum, coroutine, delegate.

    I spent a lot of times with it. one line revert, build, online revert, build, revert, build.... very painful debugging.
    How can I fix it? or anyone have something like experience?

    plz help me. sorry my English.

    ps: empty coroutine makes same error. that codes context is not related with error I think.
     
    Last edited: Nov 30, 2015
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    A couple of things I would try... Try moving the enum outside of the class instead of having it nested. See if that fixes the issue. But the one glaring thing that I see that could cause a problem is the declaration of a constant inside of your method. Look at line 17 "const float maxTime = 0.15f". That shouldn't be declared inside your method at all. That declaration should be part of your class as a field.
     
  3. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    thanks for reply. but empty Coroutine is making same error.
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    Is this something il2cpp can't handle or something?

    because constants in methods are a common thing that is supported by C#/.Net.

    nested types as well, with even Unity themselves having demo code with nested enums, as well as code in their source that does as well.
     
  5. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    @OP - I notice your class is partial, what is in the other portion of the class? Is there a function in the other half that happens to have the same name 'DialogProcess'?
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    It was just a guess. There's really no good reason to have constants inside of methods that I'm aware of. There's no point to it.

    Again just a guess, I thought maybe IL2CPP was having trouble converting nested types to native code. It was worth a try anyway.
     
  7. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    Aw, ok, just wanted to know if you knew something about il2cpp I don't know.

    I haven't mucked about with it a whole ton, so I'm always interested if there's info out there about it.
     
  8. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    sorry for confusing by my example code.
    here is full code. but plz remember it. partial, nested enum or something is working in other classes.
    I use many partial, nested enum or coroutine things. but no problem. I don't understand it.

    I try do my best for this code, so many times change with various grammar.
    but I can't build it with that coroutine(empty is too), nested enum.

    I will test empty project with this code and result will report here.
    thanks for reply.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public partial class DialogBalloon : MonoBehaviour
    5. {
    6.     public Transform CameraTransform;
    7.  
    8.     public SpriteRenderer BaseSprite;
    9.     public MeshRenderer TextRenderer;
    10.  
    11.     public TextMesh EmotionText;
    12.  
    13.     private Transform _transform;
    14.  
    15.     public void Init()
    16.     {
    17.         _transform = transform;
    18.  
    19.         if (Camera.main)
    20.             CameraTransform = Camera.main.transform;
    21.  
    22.         SetActive(false);
    23.     }
    24.  
    25.     public void SetActive(bool active)
    26.     {
    27.         BaseSprite.enabled = active;
    28.         TextRenderer.enabled = active;
    29.     }
    30.  
    31.     void LateUpdate()
    32.     {
    33.         _transform.rotation = CameraTransform.rotation;
    34.     }
    35.  
    36.     public void Dialog(string message)
    37.     {
    38.         EmotionText.text = message;
    39.  
    40.         StopCoroutine("DialogProcess");
    41.         StartCoroutine("DialogProcess");
    42.     }
    43. }
    44.  
    45. // sdf: IL2CPP error.
    46. public partial class DialogBalloon
    47. {
    48.     //public enum DialogType
    49.     //{
    50.     //    Exclamation,
    51.     //    Question,
    52.     //    Confusion,
    53.     //    Talk
    54.     //}
    55.  
    56.     //public IEnumerator DialogProcess()
    57.     //{
    58.     //    _transform.localScale = Vector3.zero;
    59.     //    SetActive(true);
    60.  
    61.     //    const float maxTime = 0.15f;
    62.  
    63.     //    var elapsedTime = 0.0f;
    64.     //    while (elapsedTime < maxTime)
    65.     //    {
    66.     //        elapsedTime += Mediator.GetTimeDelta();
    67.     //        _transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, elapsedTime / maxTime);
    68.  
    69.     //        yield return null;
    70.     //    }
    71.  
    72.     //    yield return new WaitForSeconds(1.0f);
    73.  
    74.     //    SetActive(false);
    75.     //}
    76. }
     
  9. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    Don't use the string version of StartCoroutine and StopCoroutine.

    Call them directly, and cache the 'Coroutine' object that comes back:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public partial class DialogBalloon : MonoBehaviour
    6. {
    7.     public Transform CameraTransform;
    8.  
    9.     public SpriteRenderer BaseSprite;
    10.     public MeshRenderer TextRenderer;
    11.  
    12.     public TextMesh EmotionText;
    13.  
    14.     private Transform _transform;
    15.     private Coroutine _routine;
    16.  
    17.     public void Init()
    18.     {
    19.         _transform = transform;
    20.  
    21.         if (Camera.main)
    22.             CameraTransform = Camera.main.transform;
    23.  
    24.         SetActive(false);
    25.     }
    26.  
    27.     public void SetActive(bool active)
    28.     {
    29.         BaseSprite.enabled = active;
    30.         TextRenderer.enabled = active;
    31.     }
    32.  
    33.     void LateUpdate()
    34.     {
    35.         _transform.rotation = CameraTransform.rotation;
    36.     }
    37.  
    38.     public void Dialog(string message)
    39.     {
    40.         EmotionText.text = message;
    41.  
    42.         if(_routine != null)
    43.         {
    44.             StopCoroutine(_routine);
    45.             _routine = null;
    46.         }
    47.         _routine = StartCoroutine(DialogProcess());
    48.     }
    49. }
    50.  
     
  10. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    thanks for suggest coroutine style. It is more effective.
    and I will manage it coroutine object list.

    but sadly that can't solve my build problem.
     
  11. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    Hrmmm... this is very odd.

    I don't really see anything that would be causing the problems. I agree I don't think it's the enums/coroutine itself, as I too have used those.

    The only thing I can think of now is the fact you're using partial classes. Have you used those elsewhere like that when compiling for iOS? Have you tried bringing the partial class code directly into the main portion of the class instead?
     
  12. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Yes I tried it. partial is using for just isolation that error codes.
    build error started from no partial class.

    now I'm trying to test with empty project. I will report it.
    this is very odd situation and I can't understand it. I spent 3 full days for it.:oops:
     
  13. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Out of curiosity, have you tried with a WebGL build? Or, Android IL2CPP with Unity 5.2 or Windows Store IL2CPP with Unity 5.3? I wonder if this is a general IL2CPP error or limited to iOS 64-bit? The error is complaining about not finding ARM-64 symbols, so I wonder if this is a Unity bug of some kind that's limited to iOS.
     
  14. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Error build's DialogBalloon class output in Il2CppMethodPointerTable.o


    This is Test Empty Project's DialogBalloon class build result.


    It looks have no difference.
    but, test empty project's code dose not make U3CPrivateImplementationDetailsU3E_ctor_m11_xxxx.

    I think that code is have not problem. but It is triggering error in my project.
    I suspicion It maybe related with PrivateImplementationDetails from C#.

    but I can't find solution. I dig it more.:(
    and sorry my English. it's not my first language.
     
  15. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    @Dustin Horne Yes. I think so.
    but I didn't build it for WebGL, Android.. ETC. (my Android build is using mono2x) then I can't conviction it is a bug.
     
  16. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Hmm... I wonder if it's possible that the stripping engine is causing an issue since it's always active for IL2CPP. It may be incorrectly stripping something.
     
  17. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    I feel same for forced stripping. I will try to edit manually that generated native .cpp code.
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    @sdf_eee

    I'm not sure what part of this code is causing a problem, but IL2CPP should never generated C++ code that does not compile. So this is certainly a bug on your side. I can't offer a work around now, but can you submit a bug report, include this project, and let me know the bug report number? We will investigate this.
     
  19. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    @JoshPeterson Sadly, My project is so bigger and Test Project can not occur any IL2CPP error with that code.
    but I try to make a bug environment project and try to report it. thanks for reply.
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    @sdf_eee

    If the project is too large to submit via the bug reporter, but you are still willing to provide the project to us, you can submit a bug report without the project and we can obtain it via other methods like a blind FTP. Let me know if you are interested in this option. Thanks.
     
  21. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    @JoshPeterson

    Our project in server and there is complex setting environment for run to project. (symbolic links, separated project.. etc)
    then I think how.

    Can you try to connect our server and login for bug tracking?

    If you can, I make guest account for you.
    If you can't, I make a project for test and receiving with blind FTP. but It takes sometime.
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    @sdf_eee

    It would probably be best to have a standalone test project one our side, if that is possible. I'm not sure who on our team will investigate the bug report, so if we can have something self-contained that we can pass around internally, I would prefer that.
     
  23. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    OK. I'm not assure that I can create standalone bug project. but I will try it.

    Anyway, I find a condition for this bug.

    Release build doesn't occur error.
    Debug build makes error. (There is no generated U3CPrivateImplementationDetailsU3E_ctor_m11_xxxx's body. and no U3CPrivateImplementationDetailsU3E releated struct.)

    At the first, two build options make the same error. But, it isn't now.
    I don't know why. However, release build doesn't make any errors.
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    @sdf_eee

    The generated code should not differ between release and debug builds, so maybe something else is going on there. Where are you switching from debug to release? Is this in Xcode?
     
  25. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Switch it in Unity Build Settings.

    [Development Build] option.
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    @sdf_eee

    Ok, that is interesting. The Development Build option does change the arguments passed to il2cpp.exe, so that might help us track down the cause of the issue. Can you provide the editor log file for build with "Development Build" enabled and one with it disabled?

    The il2cpp.exe command line options should be written to the editor log file.
     
  27. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Very odd thing happens too. there is no log files in ~Library/Logs/Unity/ folder.
    in Windows, log file makes with no problems.

    on OSX, Release / Debug options all same. no log file making.
    It's very odd. Editor Build, Command line Build is same.

    but on Command-line build, I can redirect log stream. I will post it.
     
  28. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    OMG! I know why this bug(It's not a bug!) happens to me!!
    I'm so stupid. It was my own build script's problem.

    First, I made a Template (xcode project copy).
    that template's file list have Bulk_Assem..._6.cpp.

    when I make a new code and build, Unity generated correctly,
    code is overflow from Bulk_Assem..._6.cpp and create Bulk_Assem..._7.cpp.

    but my xcode template doesn't have _7.cpp's info.
    then. build failed. I'm a idiot:(

    very thanks for reply this post.
    It helps me to track my own bugs.

    It wasn't Unity bug.
    Thanks!