Search Unity

WebGL port doesn't work

Discussion in 'Unity 5 Pre-order Beta' started by alexandru.badescu, Nov 1, 2014.

?

Does webGL generate ok games for you

  1. Yes, no problem

    4.7%
  2. No, none work

    57.4%
  3. Yes and No, depends

    34.0%
  4. Haven't tried it yet

    3.9%
  1. wbl1

    wbl1

    Joined:
    Apr 22, 2009
    Posts:
    156
    My port to WebGL is going pretty well. Congrats Unity people ... this is looking awesome!

    My problem is with GUILayout.TextField ... inside the editor this works file, but when output to WebGL, I cannot change the text in the input box. It may have something to do with how I am coding it, so here are some details:

    In one file, I have:

    radius = compoundControls.labeledTextField("Radius",radius);

    where radius is defined as a String. As you can see this references a function in another file called compoundControls ... so in compoundControls, I have the following:

    import UnityEngine.GUILayout;

    static function labeledTextField (label : String, inputText : String)
    {
    BeginHorizontal();
    Label(label);
    GUI.color = Color.white;
    var outputText : String = TextField(inputText);
    EndHorizontal();
    return outputText;
    }

    Is there something about this that WebGL doesn't like?
     
  2. Zaibach333

    Zaibach333

    Joined:
    Sep 4, 2011
    Posts:
    19
    I'm not at my computer at the moment, but I know the only thing I added were these scripts: https://github.com/paynechu/jsonfx-for-unity3d/tree/master/JsonFx/JsonFx.Json

    in an attempt to get rid of dll files and still have json serialization.
    not many tweaks were made to the namespace.

    does that help at all?
     
  3. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,606
    Note that we don't support IE yet - but it sounds like the browser is running our of memory. Is this 32 or 64 bit IE?
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,606
    Without taking a longer look at JsonFx: Does it use Reflection.Emit? If it does, it cannot work on il2cpp (or other AOT implementations for that matter).
     
  5. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,606
    I don't see anything there which is not expected to work, but if you file a bug, we will take a look at it!
     
  6. Zaibach333

    Zaibach333

    Joined:
    Sep 4, 2011
    Posts:
    19
    hmm, it does include System.Reflection...
    The log has some soft errors for Serialization depth limit, that's it for the log though... the project didn't change when it was upgraded to 5 but those apeared, they haven't impeded anything before. It could be related but that "failed building WebGL Player" error is very non-descriptive
     
  7. wbl1

    wbl1

    Joined:
    Apr 22, 2009
    Posts:
    156
    In my case, I am embedding the webgl file (index.html) within an iframe and this appears to cause the problem. I can edit the TextField if you simply launch the webgl content within a browser, but again if the webgl content is inside an iframe, the text is not editable.

    One obvious solution is to avoid using the iframe and just include the webgl content as part of the (much) broader web page. In my case, the "broader" web page is generated dynamically, so I fear I will have to do all sorts of complicated things to ensure that all files currently in the Data and Compressed directories are read in properly. And, then there is the issue of .htaccess and getting the compressed files ...

    I'd prefer not to mess with all this. Are you aware of the iframe issue and is there anything I can do to fix that?

    UPDATE: I tried using the new UI this morning and this has the same problem. Create some webGL output that includes a text box, then place that inside an iframe. I think you will find that the text is not editable. I will file a bug report as well.
     
    Last edited: Nov 22, 2014
  8. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,022
    I was able to get the new demo scene (the jar) to export to webGL..., but a basic scene of my own with one model (with blendshapes) export just writes an empty folder. Build says it's working but then... just an empty folder. o_O
     
  9. Zaibach333

    Zaibach333

    Joined:
    Sep 4, 2011
    Posts:
    19
    Have you looked at the console output during/after building? it might have an error (sorry if this is a dumb question).
     
    wetcircuit likes this.
  10. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,022
    not that I noticed... Maybe I will screen capture it and see what it is doing as it compiles...
     
  11. 2rusbekov

    2rusbekov

    Joined:
    Jul 12, 2013
    Posts:
    38
    Are there any optimization tips for webgl? I got very low fps. In webplayer was 50-60, In webGl is lower then 20. I think it's on gpu side.
     
  12. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,606
    Why would you think that? The GPU should specifically be what runs at full native speed in WebGL (compared to the whole engine code, which is hit by the conversion to JavaScript). Did you try profiling your code? Also, which browser is this? See here for a comparison of browser performance:

    http://blogs.unity3d.com/2014/10/07/benchmarking-unity-performance-in-webgl/
     
  13. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,763
    TLDR;
    My Bad. Delete python paths, Delete Old Shaders, Don't use unsupported features.

    ----------------------------------------------------------------------------------------
    After deleting all references to python from my paths. it built.

    however:

    Code (csharp):
    1.  
    2. An error occured running the Unity content on this page.
    3. See your browser's JavaScript console for more info. The error was:
    4. uncaught exception: abort() at jsStackTrace@http://localhost:12058/Data/WebGL.js:978:13
    5. stackTrace@http://localhost:12058/Data/WebGL.js:995:22
    6. abort@http://localhost:12058/Data/WebGL.js:3605669:25
    7. __Z43Register_UnityEngine_Microphone_GetPositionv [Register_UnityEngine_Microphone_GetPosition()]@http://localhost:12058/Data/WebGL.js:11301:93
    8. __Z32RegisterAllStrippedInternalCallsv [RegisterAllStrippedInternalCalls()]@http://localhost:12058/Data/WebGL.js:3544196:2
    9. __Z24RegisterAllInternalCallsv [RegisterAllInternalCalls()]@http://localhost:12058/Data/WebGL.js:998137:2
    10. _InitializeScriptingBackend@http://localhost:12058/Data/WebGL.js:1094132:2
    11. _main@http://localhost:12058/Data/WebGL.js:2070273:2
    12. asm._main@http://localhost:12058/Data/WebGL.js:3603044:10
    13. callMain@http://localhost:12058/Data/WebGL.js:3605545:15
    14. doRun@http://localhost:12058/Data/WebGL.js:3605602:7
    15. run/<@http://localhost:12058/Data/WebGL.js:3605614:7
    16.  
    So assuming the answer is "Microphones are not yet supported in the current beta" I am rebuilding without the audio components. Thought I should report.

    Code (csharp):
    1.  
    2.  
    3. Successfully compiled asm.js code (total compilation time 29384ms; stored in cache; 7 functions compiled slowly: __ZN5physx31setupFinalizeSolverConstraints4EPNS_21PxcSolverContact4DescERNS_18PxcNpThreadContextEPhffRKNS_6shdfnd3aos5Vec4VES9_S9_S9_:422123:2 (290ms), __ZN9ShaderLab11ShaderState21FromParsedShaderStateERKNS_17ParserShaderStateEP16PropertyNamesSet:1448773:35 (288ms), __Z7yyparsev:1435142:24 (709ms), _TT_RunIns:1982351:7 (895ms), __Z32Assembly_CSharp_LeanTween_updateP22mscorlib_System_Object:2154365:18 (1637ms), __Z34Assembly_CSharp_InventoryGUI_OnGUIP28Assembly_CSharp_InventoryGUI:2277209:27 (380ms), __Z76Assembly_CSharp_ParticlePlayground_PlaygroundParticlesC_ThreadedCalculationsP22mscorlib_System_ObjectP55Assembly_CSharp_ParticlePlayground_PlaygroundParticlesC:2217152:3 (2149ms)) WebGL.js
    4. "run() called, but dependencies remain, so not running" localhost:12058:63
    5.  
    6. "pre-main prep time: 452 ms" localhost:12058:63
    7.  
    8. "missing function: _Z43Register_UnityEngine_Microphone_GetPositionv" localhost:12058:63
    9.  
    10. -1 localhost:12058:59
    11. -1 localhost:12058:63
    12.  
    13. "Invoking error handler due to
    14. uncaught exception: abort() at jsStackTrace@http://localhost:12058/Data/WebGL.js:978:13
    15. stackTrace@http://localhost:12058/Data/WebGL.js:995:22
    16. abort@http://localhost:12058/Data/WebGL.js:3605669:25
    17. __Z43Register_UnityEngine_Microphone_GetPositionv [Register_UnityEngine_Microphone_GetPosition()]@http://localhost:12058/Data/WebGL.js:11301:93
    18. __Z32RegisterAllStrippedInternalCallsv [RegisterAllStrippedInternalCalls()]@http://localhost:12058/Data/WebGL.js:3544196:2
    19. __Z24RegisterAllInternalCallsv [RegisterAllInternalCalls()]@http://localhost:12058/Data/WebGL.js:998137:2
    20. _InitializeScriptingBackend@http://localhost:12058/Data/WebGL.js:1094132:2
    21. _main@http://localhost:12058/Data/WebGL.js:2070273:2
    22. asm._main@http://localhost:12058/Data/WebGL.js:3603044:10
    23. callMain@http://localhost:12058/Data/WebGL.js:3605545:15
    24. doRun@http://localhost:12058/Data/WebGL.js:3605602:7
    25. run/<@http://localhost:12058/Data/WebGL.js:3605614:7
    26. " UnityConfig.js:74
    27. "Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)" localhost:12058:63
    28.  
    29. "Build with ASSERTIONS=2 for more info." localhost:12058:63
    30.  
    31. 139 localhost:12058:59
    32. 139 localhost:12058:63
    33.  
    34. uncaught exception: abort() at jsStackTrace@http://localhost:12058/Data/WebGL.js:978:13
    35. stackTrace@http://localhost:12058/Data/WebGL.js:995:22
    36. abort@http://localhost:12058/Data/WebGL.js:3605669:25
    37. nullFunc_viii@http://localhost:12058/Data/WebGL.js:12931:469
    38. b139@http://localhost:12058/Data/WebGL.js:3600451:60
    39. __ZNK10FileSystem10ToAbsoluteEPKc [FileSystem::ToAbsolute(char*)]@http://localhost:12058/Data/WebGL.js:1422941:2
    40. __Z18IsDirectoryCreatedRKNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE [IsDirectoryCreated?S(undefined?N?&)]@http://localhost:12058/Data/WebGL.js:1429185:2
    41. __ZN14CachingManager5ResetEv [CachingManager::Reset()]@http://localhost:12058/Data/WebGL.js:1230948:8
    42. __Z23FileSystemMountCallbackPv [FileSystemMountCallback(void*)]@http://localhost:12058/Data/WebGL.js:2070209:2
    43. dynCall_vi@http://localhost:12058/Data/WebGL.js:3599629:7
    44. Runtime.dynCall@http://localhost:12058/Data/WebGL.js:255:14
    45. _JS_FileSystem_Mount/<@http://localhost:12058/Data/WebGL.js:12016:6
    46. done@http://localhost:12058/Data/WebGL.js:2829:13
    47. IDBFS.reconcile@http://localhost:12058/Data/WebGL.js:2179:1
    48. IDBFS.syncfs/</<@http://localhost:12058/Data/WebGL.js:1994:13
    49. @http://localhost:12058/Data/WebGL.js:2082:1
    50. UnityErrorHandler@http://localhost:12058/Data/UnityConfig.js:104:5
    51.  
    52. "warning: a problem occurred in builtin C++ name demangling; build with  -s DEMANGLE_SUPPORT=1  to link in libcxxabi demangling" localhost:12058:63
    53.  
    54. uncaught exception: abort() at jsStackTrace@http://localhost:12058/Data/WebGL.js:978:13
    55. stackTrace@http://localhost:12058/Data/WebGL.js:995:22
    56. abort@http://localhost:12058/Data/WebGL.js:3605669:25
    57. __Z43Register_UnityEngine_Microphone_GetPositionv [Register_UnityEngine_Microphone_GetPosition()]@http://localhost:12058/Data/WebGL.js:11301:93
    58. __Z32RegisterAllStrippedInternalCallsv [RegisterAllStrippedInternalCalls()]@http://localhost:12058/Data/WebGL.js:3544196:2
    59. __Z24RegisterAllInternalCallsv [RegisterAllInternalCalls()]@http://localhost:12058/Data/WebGL.js:998137:2
    60. _InitializeScriptingBackend@http://localhost:12058/Data/WebGL.js:1094132:2
    61. _main@http://localhost:12058/Data/WebGL.js:2070273:2
    62. asm._main@http://localhost:12058/Data/WebGL.js:3603044:10
    63. callMain@http://localhost:12058/Data/WebGL.js:3605545:15
    64. doRun@http://localhost:12058/Data/WebGL.js:3605602:7
    65. run/<@http://localhost:12058/Data/WebGL.js:3605614:7
    66.  
    67.  
    :) soon know...

    EDIT: Yup, that was it. My bad...

    It barfed on some of the legacy shaders I failed to remove (doh) but ran (kinda) anyways.

    Clearly I am stupid, remove the old junk!

    Code (csharp):
    1.  
    2. Warning: Creation of shader 'Hidden/GlobalFog' failed.
    3. WebGL.js:10457 -------- failed compiling vertex program:
    4.  
    5. (index):59 attribute stupidity _I cl34rly_4m
    6. (index):59 attribute vec4 _glesVertex;
    7. .... yada yada
    8. WebGL.js:10457 -------- GLSL error: ERROR: 0:34: '[]' : Index expression must be constant
    9. ERROR: 0:35: '[]' : Index expression must be constant
    10.  
    11.  
    12. (index):59 Warning: Creation of shader 'Hidden/GlobalFog' failed.
    13. (index):59 WARNING: Shader Unsupported: 'Hidden/GlobalFog' - Pass '' shader state not supported
    14. (index):59 WARNING: Shader Unsupported: 'Hidden/GlobalFog' - Setting to default shader.
    15. (index):59 WARNING: Shader Unsupported: 'Legacy Shaders/Diffuse' - Pass 'DEFERRED' shader state not supported
    16. (index):59 WARNING: Shader Unsupported: 'Legacy Shaders/Bumped Diffuse' - Pass 'DEFERRED' shader state not supported
    17. (index):59 Shader 'Legacy Shaders/Bumped Specular': fallback shader 'Legacy Shaders/Specular' not found
    18. 2(index):59 WARNING: Shader Unsupported: 'Legacy Shaders/Bumped Specular' - Pass 'DEFERRED' shader state not supported
    19. (index):59 WARNING: Shader Unsupported: 'Legacy Shaders/Self-Illumin/Diffuse' - Pass 'DEFERRED' shader state not supported
    20. (index):59 WARNING: Shader Unsupported: 'Hidden/TerrainEngine/Details/Vertexlit' - Pass 'DEFERRED' shader state not supported
    21. (index):59 WARNING: Shader Unsupported: 'Hidden/TerrainEngine/Details/WavingDoublePass' - Pass 'DEFERRED' shader state not supported
    22. (index):59 WARNING: Shader Unsupported: 'Hidden/TerrainEngine/Details/BillboardWavingDoublePass' - Pass 'DEFERRED' shader state not supported
    23. (index):59 WARNING: Shader Unsupported: 'Nature/Terrain/Diffuse' - Pass 'DEFERRED' shader state not supported
    24. (index):59 WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD' shader state not supported
    25. (index):59 WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD_DELTA' shader state not supported
    26. (index):59 WARNING: Shader Unsupported: 'Standard' - Pass 'SHADOWCASTER' shader state not supported
    27. (index):59 WARNING: Shader Unsupported: 'Legacy Shaders/Specular' - Pass 'DEFERRED' shader state not supported
    28. (index):63 exit(0) called, but noExitRuntime, so not exiting(index):63 Module.printErr
    29.  
    30.  
    I'll fix that stupidity then and try again. more coffee perhaps. Reconfiguring IIS to accept .data and .mem as octetstream, was a bit of a speedbump but not too tough.

    Will give this another go. Thanks. ERK!!!!! I AM 5 point releases behind. oops.
    Wow you have been busy... (goes off and kills another early AM hour)
     
    Last edited: Dec 5, 2014
  14. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,763
    EDIT TLDR;
    If you apply the .web and .data changes MANUALLY, remember to elide the web.config as this will result in dual keys. The clue here was my last line:
    I am struggling to get my beta to run on my webserver though

    http://kaycare.co.uk/games/glub5/ keeps 404 ing and 500 ing...

    Maybe I messed up the rewrite rules?

    The 4 version works ok http://kaycare.co.uk/games/glub

    Sigh. Any guides to setting up IIS7 ? I tried to import the .htaccess files in URL rewrite and that seemed to go fine. I also hard coded the mem and data octet stuff
    Got that problem sorted now. thanks :)

    Still not actually serving out the gzipped content yet, but , meh it's progress.

    EDIT: many hours later... I have escalated the question of HOW to http://answers.unity3d.com/questions/847635/correctly-configuring-iis7-to-serve-gzipped-conten.html since I can't be the only person who needs to know this. Docs? anywhere? Can't find em

    I have tried to make the rewrite rules work? but meh I really really can't get it going.

    EDIT EDIT: Posted the solution for the next person on that question.
    Enjoy
     
    Last edited: Dec 25, 2014
  15. 2rusbekov

    2rusbekov

    Joined:
    Jul 12, 2013
    Posts:
    38
    I wanted to write on cpu side. Issue is in draw calls. With ~1200 DCs I got those numbers of fps.
     
  16. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,606
    1200 draw calls should probably not be a bottleneck in WebGL (though it does depend a lot on the browser and hardware used). Like on any other platform, I'd advise profiling your project before drawing conclusions.
     
  17. mrekuc

    mrekuc

    Joined:
    Apr 17, 2009
    Posts:
    47
    I am having a whole lot of issues, but I am guessing it may be XML parsing? Is this compatible with WebGL?
    using System.Xml;
    using System.Xml.XPath;

    Where can I find a WebGL compatibility list to find out what is breaking my build?

    {EDIT] I updated to beta 20 and everything seems to be working! Awesome! I've been trying since pre beta 6! Gave up for a bit since their were no real threads since it was pre beta. beta 18 didnt work so I said to hell with it let's try 20!
     
    Last edited: Jan 24, 2015
    twobob likes this.
  18. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,763
    20 fixed up my transparency issues too yay r20