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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[WebGL] [Plugin] Node Canvas crash with Web GL runtime

Discussion in 'Unity 5 Pre-order Beta' started by matthewn, Feb 12, 2015.

  1. matthewn

    matthewn

    Joined:
    Dec 15, 2014
    Posts:
    7
    Hey,

    So I got a very simple test case that causes a runtime crash with WebGL (other targets run without an issue) in Unity 5 Release Candidate 1, hopefully this will help diagnose / narrow down the cause.

    (Case 671750)

    Github:

    https://github.com/newcommat/NodeCanvasWebGLTest

    or directly:

    https://github.com/newcommat/NodeCanvasWebGLTest.git

    So a brief description of the code (note this assumes understanding of the Node Canvas plugin). I have my custom class which derives from MonoBehaviour. I also have a serialised BB Variable for this class (CollectibleObject.cs)

    I have two actions, NullGameObject which calls BBObject.value = null;
    and NullCollectibleObject which calls BBCollectible.value = null;

    There is one gameobject in the scene with the BT, it has a blackboard variable of type UnityEngine.Object. This is then further specified (via custom Preferred Types) to be of type Collectible.

    If I call BBCollectible.value = null then it will crash on that provided variable, however if I just call BBObject.value = null then it will not crash (you can test this with both actions).
     

    Attached Files:

  2. matthewn

    matthewn

    Joined:
    Dec 15, 2014
    Posts:
    7
    So interestingly, if I set exceptions in player settings to 'None' it crashes, however if I set exceptions to any other setting, it doesn't crash
     
  3. RalphH

    RalphH

    Administrator

    Joined:
    Dec 22, 2011
    Posts:
    592
    Hi. That's expected behaviour; what "exceptions" means in that context is really exception and null reference handling. If it's set to none, we (well, rather Emscripten) will not emit any exception handling code, but rather abort when normally an exception would be thrown.

    When enabling "full exception handling" this effectively does emit all the code for exceptions, plus on top of that soft checks for null reference exceptions (we need to actually check for that in the emitted code, hence the "soft").

    Because you are saying the code keeps running when you set it to "any other setting" that probably means it's not a null reference exception. You can see the exception thrown (and caught by Unity), in the console for the browser.

    The reason we have that option there, is because in asm.js (what Unity WebGL targets), exception handling effectively means the code can't be optimized by the asm.js AOT, and runs significantly slower. This is only the code that actually handles the exceptions.

    I'd advice you to first check in the editor, and see if you can see exceptions being outputted to the console. If that's not the case, there's a code path difference when ran on WebGL, in which case you should check for exceptions in the javascript console of the browser. They come with a full managed callstack, which should generally give you a good idea where in your code the exception is being thrown.
     
  4. matthewn

    matthewn

    Joined:
    Dec 15, 2014
    Posts:
    7
    Hi Ralph, Thanks for your detailed response, the issue is I can't see a call stack when exceptions are turned to full. Running this project, below is everything in the developer console when exceptions are switched on. In other words there are no reported exceptions in the console at the point at which the Web GL app will crash when exceptions are turned off.

    There are also no exceptions in the editor itself.

    This makes it tough to actually diagnose the issue.

    Successfully compiled asm.js code (total compilation time 12006ms; not stored in cache; 3 functions compiled slowly: __Z16CarveNavMeshTilePPhPiPKhijPK16NavMeshCarveDatafff:2310220:9 (266ms), _TT_RunIns:2785312:9 (267ms), __Z23OpCodeNames_cctor_m9967P9Object_t4:3805553:9 (271ms)) bin.js
    "run() called, but dependencies remain, so not running" localhost:3896:33
    Module.printErr() localhost:3896:33
    run() bin.js:5109513
    <anonymous> bin.js:5109625

    "pre-main prep time: 303 ms" localhost:3896:33
    Module.printErr() localhost:3896:33
    doRun() bin.js:5109533
    run/<() bin.js:5109549

    "PlayerConnection initialized from (debug = 0)" localhost:3896:29
    "PlayerConnection disabled - listening mode not supported" localhost:3896:29
    "Initialize engine version: 5.0.0f1 (8a4fe2379c5e)" localhost:3896:29
    "Renderer: Mozilla" localhost:3896:29
    "Vendor: Mozilla" localhost:3896:29
    "Version: WebGL 1.0" localhost:3896:29
    "GLES: 0" localhost:3896:29
    "ANGLE_instanced_arrays GL_ANGLE_instanced_arrays EXT_blend_minmax GL_EXT_blend_minmax EXT_frag_depth GL_EXT_frag_depth EXT_shader_texture_lod GL_EXT_shader_texture_lod EXT_texture_filter_anisotropic GL_EXT_texture_filter_anisotropic OES_element_index_uint GL_OES_element_index_uint OES_standard_derivatives GL_OES_standard_derivatives OES_texture_float GL_OES_texture_float OES_texture_float_linear GL_OES_texture_float_linear OES_texture_half_float GL_OES_texture_half_float OES_texture_half_float_linear GL_OES_texture_half_float_linear OES_vertex_array_object GL_OES_vertex_array_object WEBGL_compressed_texture_s3tc GL_WEBGL_compressed_texture_s3tc WEBGL_depth_texture GL_WEBGL_depth_texture WEBGL_lose_context GL_WEBGL_lose_context MOZ_WEBGL_lose_context GL_MOZ_WEBGL_lose_context MOZ_WEBGL_compressed_texture_s3tc GL_MOZ_WEBGL_compressed_texture_s3tc MOZ_WEBGL_depth_texture GL_MOZ_WEBGL_depth_texture" localhost:3896:29
    "Creating OpenGLES2.0 graphics device"