Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

WebGL demangle support

Discussion in 'Unity 5 Pre-order Beta' started by made-on-jupiter, Jan 2, 2015.

  1. made-on-jupiter

    made-on-jupiter

    Joined:
    May 19, 2013
    Posts:
    25
    In the process of porting a unity web-player app to WebGL I'm running into some issues:

    There are runtime errors and the mangled stacktraces make it very hard to understand what is going on.
    In the player settings I have enabled Soft Null exceptions and have set Scripting Define Symbols to "DEMANGLE_SUPPORT=1;ASSERTIONS=2".
    Yet I get warnings like these in my browser:
    a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling
    Build with ASSERTIONS=2 for more info.
    I'm building via BuildPipeline.BuildPlayer with BuildOptions.AllowDebugging | BuildOptions.Development

    These are the sort of stacktraces I get: http://i.imgur.com/ip2yHAR.png

    What is the process of enabling demangling and getting proper stacktraces?
    Is it possible to hook into the webGL build process at a certain stage?
    It is very hard to construct a minimal failure case if it is hard to figure out where the error lies.
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,559
    DEMANGLE_SUPPORT and ASSERTIONS are parameters passed to emscripten, not scripting defines. While it is possible to set these from an editor script:
    Code (csharp):
    1. PlayerSettings.SetPropertyString(""emscriptenArgs"", ""-s DEMANGLE_SUPPORT=1"", BuildTargetGroup.WebGL);
    , this will not help much in your case, as this does not affect demangling of C# code. We will work on making this nicer, but you can usually tell the function names from the mangled strings as it is now fairly well.

    From your stack trace, I can see that the failure you are looking at happened in a constructor of a class called something like Sessions.Node.
     
    twobob likes this.
  3. Sarah-Mainwaring

    Sarah-Mainwaring

    Joined:
    Feb 24, 2014
    Posts:
    9
    Is the following kind of a parameter value correct?

    Code (CSharp):
    1. PlayerSettings.SetPropertyString("emscriptenArgs", "-s DEMANGLE_SUPPORT=1 ASSERTIONS=2 -Werror", BuildTargetGroup.WebGL);
    When I set the emscriptenArgs with the above I get the following areas:

    Failed running "C:\Program Files (x86)\Unity 5.0.0b19\Editor\Data\PlaybackEngines\webglsupport/BuildTools/Emscripten_Win/python/2.7.5.3_64bit/python.exe" "C:\Program Files (x86)\Unity 5.0.0b19\Editor\Data\PlaybackEngines\webglsupport/BuildTools/Emscripten/emcc" @"C:/Users/sarahm/workspaces/sarahm_default/MiniConstruction/Unity5TestBranch/Unity/Assets/../Temp/emcc_arguments.resp"

    stdout:
    WARNING: sanity check failed to run [Errno 13] Permission denied: 'C:\\Program Files (x86)\\Unity 5.0.0b19\\Editor\\Data\\PlaybackEngines\\webglsupport/BuildTools/emscripten.config_sanity'
    stderr:
    WARNING root: did not see a source tree above the LLVM root directory (guessing based on directory of C:\Program Files (x86)\Unity 5.0.0b19\Editor\Data\PlaybackEngines\webglsupport/BuildTools/Emscripten_FastComp_Win\llc), could not verify version numbers match
    INFO root: (Emscripten: Running sanity checks)
    WARNING root: java does not seem to exist, required for closure compiler, which is optional (define JAVA in ~/.emscripten if you want it)
    ERROR root: ASSERTIONS=2: No such file or directory ("ASSERTIONS=2" was expected to be an input file, based on the commandline arguments provided)

    UnityEditor.HostView:OnGUI()

    How do I properly include demangling, assertions and werror?
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,559
    you would have to pass "-s ASSERTIONS=2" (the -s is important). That said, I don't think that DEMANGLE_SUPPORT and ASSERTIONS=2 would provide much additional helpful information for debugging Unity builds. What is the actual issue you are trying to debug?
     
    twobob likes this.
  5. Sarah-Mainwaring

    Sarah-Mainwaring

    Joined:
    Feb 24, 2014
    Posts:
    9
    Sorry for the late reply here. I was having trouble building a project and interfacing it with calls to page JavaScript. I have however gotten past this problem. I was asking mainly because I could add one define using the method you listed above but not all three (Demangle, Assertions and Werror).
     
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,559
    Adding one define but not both is because you need the -s for both of them - ie, "-s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2", instead of "-s DEMANGLE_SUPPORT=1 ASSERTIONS=2"
     
    twobob likes this.
  7. Sarah-Mainwaring

    Sarah-Mainwaring

    Joined:
    Feb 24, 2014
    Posts:
    9
    Ok I see now. Thank you for clearing that up.
     
  8. made-on-jupiter

    made-on-jupiter

    Joined:
    May 19, 2013
    Posts:
    25
    On a related note: how can one set the WebGL exception handling level in an editor script?
     
  9. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,559
    Code (csharp):
    1. PlayerSettings.SetPropertyInt("exceptionSupport", BuildTargetGroup.WebGL, i);
    (Where i is a value from 0 to 2)
     
    twobob and made-on-jupiter like this.
  10. made-on-jupiter

    made-on-jupiter

    Joined:
    May 19, 2013
    Posts:
    25
    Thanks Jonas!

    Small correction for the record...

    You need to swap the last two arguments:

    PlayerSettings.SetPropertyInt("exceptionSupport", i, BuildTargetGroup.WebGL);
     
    Last edited: Mar 3, 2015
  11. made-on-jupiter

    made-on-jupiter

    Joined:
    May 19, 2013
    Posts:
    25
    Getting off-topic, but out of curiosity:

    - exceptionSupport 0 ('None') sets the emcc flag DISABLE_EXCEPTION_CATCHING=1

    - exceptionSupport 1 ('Explicitly Thrown Exceptions Only') and
    - exceptionSupport 2 ('Full')
    both set the emcc flag DISABLE_EXCEPTION_CATCHING=0

    I couldn't find a difference between the latter two in the emcc flags. So what causes the difference in error reporting?
     
  12. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,559
    DISABLE_EXCEPTION_CATCHING tells the emscripten compiler to generate try/catch blocks in the generated JavaScript code (which works, but will cause some code to to drop out of asm.js optimizations). If you enable "Full" exception support, we also emit code in IL2Cpp to do check for null on each reference access and throw a NullReferenceException if needed.
     
    twobob and made-on-jupiter like this.