Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

WebGL Roadmap

Discussion in 'WebGL' started by jonas-echterhoff, Jun 18, 2015.

  1. lukemunn

    lukemunn

    Joined:
    Sep 5, 2017
    Posts:
    1
    Not sure if this is the correct place for this, but I'd like to know how Web Assembly affects audio features in web builds.

    My understanding is that WebGL builds in Unity currently only support a very limited subset of the audio commands, e.g. volume, falloff, etc but not Reverb and Reverb Zones, which is really want I need for my project. The reason for this given in the Docs is no thread support.

    So my assumption is that Web Assembly bypasses this limitation and makes more audio functionality possible? Is this true? And if so, when will it become available?
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Currently, the same audio limitations also apply to WebAssembly builds. However, things should change when we have threads.

    Basically, FMOD requires threads which were not available in asm.js when we started working on the Unity WebGL target, so we implemented a very simple FMOD replacement with limited functionalities.

    Now asm.js supports Shared Array Buffers (required for threads) but WebAssembly does not yet. WebAssembly was released earlier this year, and now browser vendors are working on adding Shared Array Buffers support. In fact we (at Unity) are starting to do some groundwork in preparation for that.
     
    De-Panther and yuliyF like this.
  3. xAvatarchikx

    xAvatarchikx

    Joined:
    Aug 17, 2012
    Posts:
    60
    Hi! Are there any prerequisites when webgl can compare with webplayer in performance? Is there any news about the thread?
     
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    At the moment, Unity webgl content is still single-threaded, so there is still a significant performance gap compared to webplayer/native. Work is underway to get multi-threading working but we don't have an official update on this front yet.
     
  5. jkh-sumdog

    jkh-sumdog

    Joined:
    Jul 4, 2017
    Posts:
    7
    Hi, I know that the release of 5.6 added experimental support for WebAssembly. I'm just wondering what that means?

    We're currently upgrading our project to work in Unity 2017. Is the experimental support good enough that we should, in theory, be able to do a WebAssembly build?

    Is there any documentation as to which WebAssembly APIs unity does or doesn't support?

    Many thanks
    James
     
  6. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    WebAssembly is a new standard that requires support in the browser. In addition, wasm-content need to be generated with a specific tool-chain which did not exist before.
    So, the main reason for the experimental label was that it was new and unproven.

    As of the upcoming Windows fall update, Edge will add Wasm support too so we all major browsers will be able to run wasm-content.

    Removing the "experimental" label is something we have been considering (support in all major browsers being one of the requirements) but in the meantime there is nothing preventing you from shipping wasm-enabled content.
     
  7. jkh-sumdog

    jkh-sumdog

    Joined:
    Jul 4, 2017
    Posts:
    7
    Great to hear! Thanks for the quick response.
     
  8. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    69
    To me it seems the biggest hindrance to WebGL success are slow load times. After some tests I noticed that the reason is mainly lacking browser caching, which is relatively straight forward to fix, by setting correct HTTP caching headers and splitting some oversized data-files into smaller pieces (separate requests).

    So I created this issue / feature request for it:
    https://feedback.unity3d.com/sugges...-supporting-browser-caching-solution-proposal

    I got a very fast response saying that this type of optimization is already under works, which is fantastic :)!
    I'm writing this here in case other people are interested in the proggress of fixing the load times, or want to comment on it here or in the issue above.
     
    Last edited: Nov 6, 2017
  9. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    82
  10. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    725
  11. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    At this time we are not planning to add any support for virtual keyboards. Perhaps you could use html elements and pass text to the unity instance via plugin. Maybe open a new thread about this topic as someone else might have already have a solution.
     
  12. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    82
    oh man! Thats a bummer!
    I am using a virtual Keyboard in my Unity App, but due to screen size, it just doesn't look good. I will keep plugging away at it.
    Thank you for the update! I really appreciate it!
     
  13. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    82
    Just open your WebGL app in a mobile browser and see if works!
    You will need to have a website that you can use to host your WebGL app, then copy your app to the website, include it in a web page and open the page in a browser.

    :)
     
  14. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    725
    Thanks for the reply.
    Just worry part is why unity document showing unityWebgl not support mobile.
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,254
    WebGL isn't supported there since mobile devices haven't had the hardware/software necessary to run Unity WebGL content effectively. That doesn't mean it won't work, but if it does, it would have to be the newest devices running the newest browsers, and there's still no guarantee, so basically you're on your own for now.

    --Eric
     
  16. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    that pretty much sums it up.

    As it's being said here, give it a try and see if it works for your use case. It really depends on type of project, device, browser, etc...
     
    roseportalgames likes this.
  17. twinmatrix

    twinmatrix

    Joined:
    Sep 6, 2012
    Posts:
    30
    Is it possible that it won't run on Android 5.0 even if Chrome would be up to date?

    If I get a black screen after the UNITY Logo appears in the center, does that mean it's because the phone doesn't have the "hardware/software necessary to run Unity WebGL content effectively"? Or is it a different thing?
     
    Last edited: Dec 25, 2017
  18. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    7,548
    Have you tried other webgl game development systems for comparison, then you can get a better idea if it's a technology or Unity limitation?
     
  19. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    133
  20. rogueknight

    rogueknight

    Joined:
    Feb 16, 2014
    Posts:
    44
    Hey just wanted to send a huge thank you to the Unity team for your work on the WebGL side of things. I haven’t personally used it to ship a game yet, but I’m super excited to work with it. Especially now that it seems the loading times have improved. Thanks again!
     
  21. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    152
    huge problem in Unity3d WebGL : very slow loading on startup (and yes we used bundles).. can it be fixed in the first place?
     
    arumiat likes this.
  22. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Data caching has been fixed in 2017.3 so second loads should be faster (5.6, 2017.1 and 2017.2 back-port are pending).
    Hot reload will improve further in 2018.1 which will also cache the WebAssembly compiled module.
     
    ilmario, deniax, andrzej_cadp and 2 others like this.
  23. tmars

    tmars

    Joined:
    Jul 26, 2013
    Posts:
    18
    Hi Marco,

    Any news on multi-threading?
     
    yuliyF likes this.
  24. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    216
    A critical .js feature which was required for this (Shared Array Buffers) was pulled from Chrome/Firefox recently due to the Spectre CPU bug as a mitigation. Hopefully it'll come back, but that might have set it back.
     
  25. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    That's correct. The plan was to ship WebAssembly SAB support in 2018-Q1 but due to these events this is not going to happen yet. Browser vendors are now working on putting all mitigations in place.

    It seems this is only a delay on the original plan but it's still early days.
     
  26. bpaterson2000

    bpaterson2000

    Joined:
    Aug 18, 2016
    Posts:
    1
    Re: Audio

    FMOD Studio has an external integration with Unity, that can be used in place of the built in audio.
    FMOD Studio also has a HTML5 port.

    FMOD Studio + HTML5(WebGL) Unity though has taken some time to get to work, but it is ready now, and should be coming out soon, in FMOD Studio 1.09.12 and 1.10.04

    We will have a demo project hosted on our website showing it working.
     
  27. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    I would give my left ... anyway ... to see this decently working before the universe ends. Come on bright future
     
  28. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    2,599
    any news on this? really need threading for our projects
     
  29. turtlesquadron

    turtlesquadron

    Joined:
    Nov 26, 2014
    Posts:
    11
    My team is also looking into to this, we are moving from webplayer to webgl and are looking into using threading so it would be useful to know if you have an eta on this.
     
    MadeFromPolygons likes this.
  30. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    972
    The browser vendors have Shared Array Buffers still disabled by default to mitigate the Intel CPU attacks. Until that changes we can't move forward ourselves with this.
     
  31. turtlesquadron

    turtlesquadron

    Joined:
    Nov 26, 2014
    Posts:
    11
    Makes sense, however chrome has a flag for enabling the Shared Array Buffer and is working on Strict site isolation which would get around some of the specter problems is there no way to add it experimentally to use with these flags?
     
  32. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    2,599
    @Marco-Trivellato @Schubkraft is this something we could get? An entire team here cobbled by this, we cannot deploy without a web based solution, and we really need threads for the scope of most of our projects to be feasible.
     
    Last edited: Apr 17, 2018
  33. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    You can have a play with the Emscripten thread support (USE_PTHREADS flag). The version of Emscripten Unity uses doesn't support threads with Wasm. You can ~sort of~ replace the existing Emscripten version with a newer version for some limited wasm support but you'd obviously get no unity support and risk breaking things.

    I've had some success getting Unity to compile with the pthreads flag but the actual build has some issues booting up correctly. I'm tempted to keep playing with it outside work to see if Mono actually uses pthreads after the IL2CPP process or not to see if it's even feasible. What's painful is that the pthreads flag isn't compatible with Unity's development build (since that uses the Emscripten LINKING=1 flag) so it's a bit of guess work when an error pops up in the browser.

    It's just a bit of tinkering so don't expect anything useful to come out of it, it'll be a hacked together mess, and as Marco said, actual players wont be able to benefit due to it needing browser flags enabled manually as well.
     
  34. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    It's possible to re-enable SAB support in Chrome and Firefox, which will allow you to test "multi-threaded" builds. However, enabling USE_PTHREADS flag in emscripten won't be enough to generate code that spawns threads and utilizes synchronization primitives such as atomics because Unity was compiled assuming a single-threaded execution. We literally have a SUPPORT_THREADS define, which is currently disabled (on this target platform). All code that relies on threading is wrapped around that. That means we don't even try to call pthread_create(), for example.

    You might be wondering, why can't we enable SUPPORT_THREADS? Because it's in Unity source code which is compiled and shipped to you as a library, then linked at Unity Project build-time with your own code (generated by your scripts).

    Hope that makes sense.
     
    JJJohan likes this.
  35. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    2,599
    This is unfortunate. So basically the only option for companies using this for commercial projects is to shell out a ton for source code simply to remove a flag? Not impressed with that outlook on things. Anyway, thanks for the official response, but unfortunately this means that the only way to release programs for WebGL using Unity is by running everything from a single thread which for simulation and serious games such as what we do, is just not viable a lot of the time.

    @Marco-Trivellato @Schubkraft So what is the official unity response on what is being done on this matter? Surely there is something being worked on to ensure that web technology is still a viable deployment target? I understand that you potentially need to be diplomatic with your answer but a straight "no" or "yes" is really needed because we have already wasted a lot of time trying to get around this.

    Thankyou for any info you can share on this

    EDIT: or if you have any info you can divulge on the WebGL-Next/WebGPU proposals and what/if any work is being done unity side to support this, this would also be useful. So far it seems that the WebGL-Next/WebGPU proposals are not very far along which is disconcerting as far as a "fix" or "workaround" regarding this goes.
     
    Last edited: Apr 17, 2018
  36. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    No, even if you had source code access there would be work to be done to get everything working. It's not just a matter of flipping a flag.

    The reality is that there is still no shipping browser with SAB-support enabled.

    I am not sure whether it helps you but I can tell you that this will not make it into 2018.1 and probably not in 2018.2 either.

    No info at this time as it is still being worked on by the W3C community group.
     
    Last edited: Apr 18, 2018
    Ostwind likes this.
  37. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    2,599
    Okay thankyou for all the info it is much appreciated!
     
  38. anastrophe

    anastrophe

    Joined:
    Feb 8, 2017
    Posts:
    9
    Does this WebGL Roadmap have some documentation on using a single UnityLoader.js to load content created with older/any versions of Unity?

    I'm working on an idea for education and have about 30 or so small interactive Unity kids games that I want to load dynamically within a web page - it can be done in an iFrame pointing to the index.html for each bit of content, but that's the sort of thing we would do back in the 90's and has a big impact on the UX.

    I've tinkered a bit with this and is seems that the newer UnityLoader.js file looks for entries in the contents .JSON file that don't exist on older builds - and then errors out.

    Is there any documentation on this? (I already read the discussion relating to the pre-5.6 UnityLoader concepts supporting multiple instances on a page - but it makes no reference to these being from the same build etc.)
     
  39. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I don't think it's officially documented but our goal is to maintain backwards compatibility between the UnityLoader.js of a new version of Unity and previously released content. If you see this is not the case, please open a new thread in the forum with more details about the issue (this thread is roadmap-specific).
     
  40. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    160
    In the announcement at GDC it was disclosed that a new export(i guess), maybe canvas based, was coming. The new solution was allegedly extremely lightweight and would allow for easy deving of instant games.
    Now 2 questions stand for me,
    1. Is this new tech going to also find it's way to the webgl export, meaning the export size will also be reduced, and startup times improved?
    2. Does this mean that Unity will finally officially support html5 on mobile?(in some way or shape)

    Hoping that at least n°2 is a thing.
     
  41. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    What we announced will be a separate build target.
    The goal of the lightweight runtime is to be able to run on the widest range of browsers/devices but don't quote me on this since it is still in development. I am sure we will have more info to share in the coming months and hopefully have a dedicated forum section for that.
     
    supron and Kiori like this.
  42. Go2ready

    Go2ready

    Joined:
    May 8, 2015
    Posts:
    29
    What will be the new build target be? Is it still going to be webgl based? Or even web based?
     
    game_apps likes this.
  43. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    It will be based on the web technology stack. I am sure we will share more details in the coming months.
     
    chriszul and supron like this.
  44. Go2ready

    Go2ready

    Joined:
    May 8, 2015
    Posts:
    29
    Thanks, Marco, based on the GDC presentation I like the new target will be a canvas based component, keep up the good work!
     
  45. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    22
    So from your anwser and what was said in the unity gdc keynote, i guess that i shouldn't hold my hopes high that web 3D is going to get a lot better, right ? I mean like getting to the point where it is at least somewhat competitive to playcanvas/threejs regarding compability (especially mobile), loading times & performance. I know you can't disclose much more information but i kinda have to decide now wether i stay with unity in the hopes that things will improve or switch to something more native to the web like threejs or playcanvas. Would really appreciate a hint ;)
     
    username132323232 likes this.
  46. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I think it depends on timing. If you need to start production in the near future, the only options in Unity are native Android/iOS targets. Unity WebGL, although not officially supported, could also be used by success rate depends on content/device/browser.
     
    gmckvision likes this.
  47. gmckvision

    gmckvision

    Joined:
    Feb 15, 2018
    Posts:
    2
    Hi Marco, is dynamic resolution already supported and if not, when do you plan to have it?
     
  48. MikaelKorp

    MikaelKorp

    Joined:
    Jan 9, 2018
    Posts:
    9
    Hey,

    Don't know if this one is asked, but is there a 64 bit support coming for WebGL builds?
    The thing that you can make desktop app and then realize that the software you have been working on doesn't work on WebGL is huge turnoff.

    I know 32 bit is a limitation by emscripten, but looking at the documentation there is support for 64 bit integers(but not with typed arrays?).
    Is there any way to get 64 bit work with extensions? Like the one you would use when building native WebGL.

    Any road map on that or for 2018-2019?
    Sorry for the huge amount of questions, but these are things that the organization I work for need to know, if we wan't to consider Unity as a new renderer/tool/platform. I have been using Unity as a tool since 2.0, but this WebGL stuff is completely new to me. Never have had this kind of problems with memory.

    I also made a thread for it
    https://forum.unity.com/threads/out...agement-some-help-please-woud-be-nice.532007/
     
  49. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,439
    Well at least there is an intent to implement WebGPU in Chrome, another sign that this will have legs, eventually.

    https://groups.google.com/a/chromium.org/forum/m/#!topic/blink-dev/dxqWTSvyhDg
     
    supron and MadeFromPolygons like this.
  50. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    Does anyone have any idea of what the timeline on SAB is? I have been trying to do research on it and it has been 6 months since the attacks, how are things standing in terms of mitigating the issues around it?
     
unityunity