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

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 →

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:1636909**ZN19ScriptingInvocation6InvokeEPP18ScriptingException() WebGL.js:1636837**ZN25ScriptingInvocationNoArgs13InvokeCheckedEv() WebGL.js:1637134**ZN13MonoBehaviour13AwakeFromLoadE17AwakeFromLoadMode() WebGL.js:1628872**ZN18AwakeFromLoadQueue28InvokePersistentManagerAwakeEPNS_4ItemEj17AwakeFromLoadMode() WebGL.js:1680248 **ZN18AwakeFromLoadQueue30PersistentManagerAwakeFromLoadEv() WebGL.js:1680075**ZN17PersistentManager27IntegrateAllThreadedObjectsEv() WebGL.js:1684132**ZN17PersistentManager10ReadObjectEi17AwakeFromLoadMode() WebGL.js:1685093**Z31ReadObjectFromPersistentManageri() WebGL.js:972787 ZN5Unity8Material15BuildPropertiesEv() WebGL.js:1724290 ZN5Unity8Material13AwakeFromLoadE17AwakeFromLoadMode() WebGL.js:1725038ZN18AwakeFromLoadQueue34PersistentManagerAwakeSingleObjectER6Object17AwakeFromLoadMode() WebGL.js:1680550 ZN17PersistentManager48IntegrateObjectAndUnlockIntegrationMutexInternalEi() WebGL.js:1685055 **ZN27TimeSliceAwakeFromLoadQueue19IntegrateTimeSlicedEi() WebGL.js:1552775**ZN13LoadOperation19IntegrateTimeSlicedEi() WebGL.js:1552554**ZN14PreloadManager26UpdatePreloadingSingleStepENS_21UpdatePreloadingFlagsE() WebGL.js:1519639**ZN14PreloadManager16UpdatePreloadingEv() 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 →

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) →

Can anyone help me with this ?

Problem persists in U5.1.1f1

would you be able to submit a small repro ?

WebGL build with with Enable Exceptions Explicitly Thrown Exceptions Only can be found here → https://dl.dropboxusercontent.com/u/26408378/MineClone/WebGL/index.html

I hope i answered Your question. :slight_smile:
Otherwise, please paraphrase.

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.

Web plugin build is stable and works in production.

You are basically my last resort here besides building and commenting out line by line.

Bug is reported here → http://fogbugz.unity3d.com/default.asp?708696_vk76999vck88g66c

thanks for submitting the bug report, we’ll take a look at it.

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”);

Where do I implement this? Can you guide stepwise please. Thanks in advance

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.

Forgot to answer to You. All went well at the end. Game is published

Nice. Do you have a link to the published game for us to try?

tôi đang gặp lỗi này ai giúp tôi được không