Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[Bug 841296] Profiler.BeginSample() stripped by IL2CPP on b7

Discussion in '5.5 Beta' started by AlkisFortuneFish, Oct 14, 2016.

  1. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    Hey,

    just a quick one, it would appear that IL2CPP strils out Profiler.BeginSample() on b7, when doing iOS development builds.

    Looking at the generated code, BeginSample() gets an empty implementation, while EndSample() is emitting the icall as it should, causing spam about unmatched Begin/EndSample() pairs.
    Here are the implementations generated for BeginSample() and EndSample(), out of Bulk_UnityEngine.

    Code (csharp):
    1.  
    2. // System.Void UnityEngine.Profiling.Profiler::BeginSample(System.String)
    3. extern "C"  void Profiler_BeginSample_m1765402375 (Il2CppObject * __this /* static, unused */, String_t* ___name0, const MethodInfo* method)
    4. {
    5.     {
    6.         return;
    7.     }
    8. }
    9. // System.Void UnityEngine.Profiling.Profiler::EndSample()
    10. extern "C"  void Profiler_EndSample_m2246779369 (Il2CppObject * __this /* static, unused */, const MethodInfo* method)
    11. {
    12.     typedef void (*Profiler_EndSample_m2246779369_ftn) ();
    13.     static Profiler_EndSample_m2246779369_ftn _il2cpp_icall_func;
    14.     if (!_il2cpp_icall_func)
    15.     _il2cpp_icall_func = (Profiler_EndSample_m2246779369_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.Profiling.Profiler::EndSample()");
    16.     _il2cpp_icall_func();
    17. }
    18.  
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    Thanks for submitting this bug report. Nothing in the IL2CPP toolchain should strip the method body and leave the method definition, so I'm really wondering what is happening here. We will investigate this issue.
     
  3. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    The problem seems to be further up the chain than that, the method is not an extern marked as an internal call already at the IL level.

    Code (csharp):
    1.  
    2. .method public hidebysig static
    3. void BeginSample (string name) cil managed
    4.  
     
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    Indeed, it's not even in the build process, it's the dll in PlaybackEngines/iOSSupport/Managed/UnityEngine.dll.

    Edit: And in fact in all the playback engines that I checked.
    Edit 2: In editor, BeginSample calls BeginSampleOnly(name).
     
  5. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    So, yeah, your team is in the clear for this! :p
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    It seems that BeginSample should forward to the private method BeginSampleOnly, and the latter is an icall. Did this just appear in 5.5b7?
     
  7. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    It looks like it broke in b4. It calls the right method in b3. I had just skipped running our full project for a few betas, so missed it.
     
  8. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    I just put all this information on the bug report.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,930
    Excellent, thanks!