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

[RESOLVED] System.Reflection.Emit problem on WebGL build [B14]

Discussion in 'Unity 5 Pre-order Beta' started by d12frosted, Dec 1, 2014.

  1. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    I have build the project for WebGL and found this happy error message in runtime:

    [Error] NotSupportedException: Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection.Emit/AssemblyBuilder.cpp(22) : Unsupported internal call for IL2CPP:AssemblyBuilder::basic_init - System.Reflection.Emit is not supported.

    _JS_Log_Dump (SV-dev.js, line 10084)
    _JS_Log_Dump__wrapper (SV-dev.js, line 6151924)
    dynCall_vii (SV-dev.js, line 6147376)
    invoke_vii (SV-dev.js, line 16097)
    __Z40DebugStringToFilePostprocessedStacktracePKcS0_S0_iS0_iiiiPFvRK11CppLogEntryE (SV-dev.js, line 2246298)
    dynCall_viiiiiiiiii (SV-dev.js, line 6056041)
    invoke_viiiiiiiiii (SV-dev.js, line 16193)
    __ZN9Scripting12LogExceptionEP18ScriptingExceptioniRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE (SV-dev.js, line 3818511)
    dynCall_viii (SV-dev.js, line 6141833)
    invoke_viii (SV-dev.js, line 14993)
    __ZN25ScriptingInvocationNoArgs6InvokeEPP18ScriptingException (SV-dev.js, line 4218115)
    __ZN25ScriptingInvocationNoArgs6InvokeEv (SV-dev.js, line 6064428)
    __ZN13MonoBehaviour16CallUpdateMethodEi (SV-dev.js, line 4032119)
    __ZN13MonoBehaviour6UpdateEv (SV-dev.js, line 6140252)
    __ZN20BaseBehaviourManager12CommonUpdateI16BehaviourManagerEEvv (SV-dev.js, line 3448142)
    __ZN16BehaviourManager6UpdateEv (SV-dev.js, line 6131679)
    dynCall_vi (SV-dev.js, line 6152013)
    invoke_vi (SV-dev.js, line 16273)
    __Z10PlayerLoopbbP10IHookEvent (SV-dev.js, line 448988)
    __ZL8mainloopv (SV-dev.js, line 5678428)
    dynCall_v (SV-dev.js, line 6154843)
    dynCall (SV-dev.js, line 203)
    (anonymous function) (SV-dev.js, line 10207)
    runIter (SV-dev.js, line 6961)
    Browser_mainLoop_runner (SV-dev.js, line 10203)

    Well, first of all, this message is not very informative. I can't find any 'using System.Reflection.Emit' in our code, so probably it's somewhere in dll files. Probably it's possible to improve those error messages to help out a little bit?

    Update. Our game runs perfectly on iOS, so we don't use Reflection. Therefore, if anything still is using reflection, it's because of a compiler flag that needs to be edited to include UNITY_WEBGL just like UNITY_IPHONE. So wee need to figure out where and what is doing it.
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Could you give us a list of the third party assets you're using? We might be able to help you narrow it down. For instance, if you're using my JSON .NET for Unity asset, it does not yet have flags for WebGL.
     
  3. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    (I'm working on the same project as the original poster)
    • JsonFX - https://github.com/scopely/jsonfx-1.x
    • A bunch of Prime31 plugins (IAP, etcetera), but I don't think any of those would be included for web build since they're all for mobile
    • Tesh Mesh Pro
    • TK2D (2D Toolkit)
    • CCText
    • RageSpline & RageTools Pro
    • Official Facebook Unity plugin (they use Facebook.MiniJSON)
    • some random particle effect plugins (JMO Assets, Ultimate FX pack 1, PRJ Happy Fun Time Particles)
     
  4. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    We also have some various other advertising and tracking native code plugins that should only run on mobile, and they tend to use their own json plugin also. But, those should only be running on mobile, not on web or webGL builds.
    • CBJSON.cs (chartboost)
    • MiniJSON.cs (amazon mobile game sdk, facebook, does run on web builds)
    • SimpleJSON.cs (facebook, does run on web builds)

    It really could be anything. I'm hoping there is a way we can get more debugging info so we can get some hint about what C# code it is running when the exception happens.

    The DLL files that might be causing the reflection error:
    • HOTween.dll (tweening plugin)
    • P31RestKit.dll (prime 31, but we only use native code plugins so none of them should actually be doing anything on web builds)
    • Newtonsoft.Json.dll (not sure what is using this, it's in a WP8 folder so I'm assuming it's only for windows phone builds)
    • JMOAssets.dll (particle fx plugin)
    • TMPro_Plugin.dll (text mesh pro)
    • ICSharpCode.SharpZipLib.dll (zip file support)
    • IFacebook.dll (official facebook plugin)
     
  5. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    You're right that Newtonsoft will only run for WP8 otherwise I'd say that's the culprit. My guess would be either miniJson or JsonFX.
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I should also note that WebGL is still in Beta and there are Reflection bits that don't work. You actually are using Reflection on iOS, just not Reflection.Emit. My Newtonsoft port makes a lot of changes for iOS and Android to be able to construct objects without using Reflection.Emit but rather simply invoking the default constructor.

    I've been working on WebGL support but it has been slow going. I cannot get a WebGL Build to work in Beta 14 or 15. I can build fine in Beta 13 but deserialization doesn't work as it throws an exception (which isn't very descriptive) when trying to construct an object. WebGL support will be spotty for awhile because it's still very much in beta and will be hard for publishers to support just yet.
     
    tayl0r likes this.
  7. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I've narrowed it down a bit further but it's very hard to debug WebGL unless I'm missing something. Actually constructing the objects works fine. However there is some LINQ stuff that's breaking. Even using GetFields on a type works fine, but trying to add them to a generic list using AddRange appears to be blowing up.
     
  8. d12frosted

    d12frosted

    Joined:
    Feb 3, 2014
    Posts:
    43
    Thank you for trying to help us with our problem.
    But I think I found the root of problem. HOTween was causing this error. After I changed regular HOTween plugin to HOTweenMicro I have never faced that `Emit` error again.