Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Problem with WebGL build ArgumentNullException: Argument cannot be null. Parameter name: type

Discussion in 'Web' started by Sacristan_G, Jun 27, 2015.

  1. Sacristan_G

    Sacristan_G

    Joined:
    Nov 30, 2012
    Posts:
    12
    Hi, everyone!

    Here i have a problem (or many) with WebGL.

    WebGL builds ok. It launches MainMenu ok, but when it loads Game (Minecraft-like procedural terrain at runtime) - exceptions are thrown - everything works perfectly for Web plugin, Standalone builds.

    I tried to debug it and with Explicitly Thrown Exceptions Only (see builds lower), but the error is not giving any info where to look for problem (probably somewhere in MonoBehaviour.Awake or Start).

    Build config:
    Optimization Level: Slow(fast builds);
    Development build: false
    Web GL Memory Size: 276 MB
    Data caching: false
    Stripping: None
    .NET 2.0 Subset

    How it went with Enable Exceptions None:
    It just throws JS alert "An exception has occured, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project's WebGL player settings to be able to catch the exception or see the stack trace."

    Full JS Console log -> http://hastebin.com/ayeyivebog.md

    Ingame screenshot ->
    SCREENSHOTEnable Exceptions None.png

    How it went with Enable Exceptions Explicitly Thrown Exceptions Only:

    error is thrown:
    Error Message:

    "ArgumentNullException: Argument cannot be null. Parameter name: type"

    Stack:

    _JS_Log_Dump() WebGL.js:8771Z40DebugStringToFilePostprocessedStacktracePKcS0_S0_iS0_iiiiPFvRK11CppLogEntryE() WebGL.js:1765540ZN9Scripting12LogExceptionEP18ScriptingExceptioniRKNSt3112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE() WebGL.js:1646106 ZN19ScriptingInvocation6InvokeEPP18ScriptingExceptionb() WebGL.js:1636909ZN19ScriptingInvocation6InvokeEPP18ScriptingException() WebGL.js:1636837ZN25ScriptingInvocationNoArgs13InvokeCheckedEv() WebGL.js:1637134ZN13MonoBehaviour13AwakeFromLoadE17AwakeFromLoadMode() WebGL.js:1628872ZN18AwakeFromLoadQueue28InvokePersistentManagerAwakeEPNS_4ItemEj17AwakeFromLoadMode() WebGL.js:1680248 ZN18AwakeFromLoadQueue30PersistentManagerAwakeFromLoadEv() WebGL.js:1680075ZN17PersistentManager27IntegrateAllThreadedObjectsEv() WebGL.js:1684132ZN17PersistentManager10ReadObjectEi17AwakeFromLoadMode() WebGL.js:1685093Z31ReadObjectFromPersistentManageri() WebGL.js:972787 ZN5Unity8Material15BuildPropertiesEv() WebGL.js:1724290 ZN5Unity8Material13AwakeFromLoadE17AwakeFromLoadMode() WebGL.js:1725038ZN18AwakeFromLoadQueue34PersistentManagerAwakeSingleObjectER6Object17AwakeFromLoadMode() WebGL.js:1680550 ZN17PersistentManager48IntegrateObjectAndUnlockIntegrationMutexInternalEi() WebGL.js:1685055 ZN27TimeSliceAwakeFromLoadQueue19IntegrateTimeSlicedEi() WebGL.js:1552775ZN13LoadOperation19IntegrateTimeSlicedEi() WebGL.js:1552554ZN14PreloadManager26UpdatePreloadingSingleStepENS_21UpdatePreloadingFlagsE() WebGL.js:1519639ZN14PreloadManager16UpdatePreloadingEv() WebGL.js:1519804 Z10PlayerLoopbbP10IHookEvent() WebGL.js:1518184 ZL8mainloopv() WebGL.js:2651004 dynCall_v() WebGL.js:4079077 Runtime.dynCall() WebGL.js:294 Browser_mainLoop_runner/<() WebGL.js:9615 Browser.mainLoop.runIter() WebGL.js:11176 Browser_mainLoop_runner() WebGL.js:9611


    Full JS Console Log : http://hastebin.com/onenaroraw.md
    Ingame Screenshot ->
    SCREENSHOTEnable Exceptions Explicitly Thrown Exceptions Only.png

    How it went with Full Exceptions:

    With this it actually works, but performance is super low (doh!). Why with full exceptions the build is working ? Exception is not thrown as can be seen from logs

    Full JS Console Log : http://hastebin.com/vilizituyu.md
    Ingame Screenshot (it works) -> SCREENSHOTFULLERRORS.png

    Can anyone help me with this ?
     
  2. Sacristan_G

    Sacristan_G

    Joined:
    Nov 30, 2012
    Posts:
    12
    Problem persists in U5.1.1f1
     
  3. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    would you be able to submit a small repro ?
     
  4. Sacristan_G

    Sacristan_G

    Joined:
    Nov 30, 2012
    Posts:
    12
  5. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I meant if you could submit a bug report with a small project attached so we can investigate. Anyway, in the meantime:

    Could you please confirm that there are no errors/warning when you run the standalone version ?
    Which version of Unity are you using ?

    you could also try a "Development build" to see if you get more information.
     
  6. Sacristan_G

    Sacristan_G

    Joined:
    Nov 30, 2012
    Posts:
    12
  7. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    thanks for submitting the bug report, we'll take a look at it.
     
  8. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    After some investigation we found that there is a problem with Type.GetType on WebGL. As a workaround you can use this instead:

    Assembly.Load("Assembly-CSharp").GetType("MyClassName");
     
  9. WikiMalik

    WikiMalik

    Joined:
    Nov 13, 2014
    Posts:
    16
    Where do I implement this? Can you guide stepwise please. Thanks in advance
     
  10. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    just replace GetType("MyClassName") with Assembly.Load("Assembly-CSharp").GetType("MyClassName")

    anyway, this is quite an old post. Are you running into the same issue? Perhaps, you could open a new thread explaining what is it that you are experiencing, with a Development callstack.
     
  11. Sacristan_G

    Sacristan_G

    Joined:
    Nov 30, 2012
    Posts:
    12
    Forgot to answer to You. All went well at the end. Game is published
     
  12. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Nice. Do you have a link to the published game for us to try?
     
  13. unity_OcE8Q6TU7X8LGA

    unity_OcE8Q6TU7X8LGA

    Joined:
    Jul 21, 2020
    Posts:
    3
    tôi đang gặp lỗi này ai giúp tôi được không