Search Unity

WebGL Roadmap

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

Thread Status:
Not open for further replies.
  1. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    with regards to Chrome you can follow this issue.
     
  2. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    Thank you for the link, looks like things are pretty far along! I hope that everything gets resolved soon :) It would be a game changer for WebGL content!
     
    Last edited: Jun 14, 2018
  3. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    Seems like you guys have put Multithreaded WebGL in the 2018.3 roadmap, definitely excited for it, do you think this will increase the initial loading performance as well? Downloading the content aside.
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Probably not since the multi-threading relates the actual running of WASM. The browser guys are working on loading separately in some way or another.
     
  5. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Just be aware that, assuming we manage to ship it in 2018.3, it will be experimental. In addition, as of today there is no browser with Shared-Array-Buffer support enabled by default, which is necessary to get multi-threading working.
     
    DragonmoN likes this.
  6. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    I know about the Shared-Array-Buffer issues been following that for a long time hoping it would get resolved. I understand it would be experimental, hoping that the site isolation issues get resolved and that the web can get multithreading. I'm excited to see any progress on it and thank you for referencing me to the Chromium issues Marco, I greatly appreciate it. I'm excited that it would mean it would be easier to dynamically load content with threading.
     
    Marco-Trivellato likes this.
  7. supron

    supron

    Joined:
    Aug 24, 2013
    Posts:
    67
    How do you want to keep backward compatibility? With Jobs system it's easy, because you can emulate jobs on main thread, but full multi threading seems like a real challenge. 2018.3 will have only Jobs system right?
     
  8. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Let me clarify. We are working on experimental support for WebAssembly threads, which will allow the engine to run in multi-threaded mode. This will just work for end users, as long as the project is deployed with threads support and that the content runs on a browser with WebAssembly and Shared-Array-Buffers support, otherwise it will run in single-threaded mode.
    Though, this is specific to native threads. C# threads will come a bit later. How we we are going to solve the problem of running your code with or without threads is something we have not looked into yet but chances are we will need to compile your code twice and use single-threaded or multi-threaded version depending on browser support.

    Does this answer your question?
     
  9. supron

    supron

    Joined:
    Aug 24, 2013
    Posts:
    67
    So in 2018.3 we will have engine running in multi-threaded mode, but does it mean only engine core or core + jobs system? AFAIK jobs are not C# threads, because they require native-like code (no reference types, no garbage collector). Full C# threads support is not that important since ECS and Jobs are getting more and more features. I think unity should focus on Burst and jobs rather than C# threads. But that's just my opinion, maybe I'm wrong :)

    I'm fine with compiling two versions (ST and MT), but it has to be an option in player settings, just like you did with linker targets: asm.js, wasm or both (so here: single-threaded, multi-threaded, both). It is extremely useful, because you can have faster build times for test builds.
     
  10. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    the internal job system should just work when we get multi-threading working;)

    Yes, that's the idea.
     
    Dan_NextRevC and supron like this.
  11. jonmarxent

    jonmarxent

    Joined:
    Jan 25, 2017
    Posts:
    7
    Question. I have been using WebAssembly on Unity 2018.2. On firefox, this drastically reduced our startup time. However, on chrome, it actually increased the startup time. Any idea as to the reason for the disparity?

    Also, couldnt find anywhere in the UnityLoader.js that you guys are actually calling WebAssembly.instantiate. How are you guys actually instantiated the web assembly object? Was trying to find it to see if you guys are using instantiate vs instantiateStreaming for performance
     
  12. PrisedRabbit

    PrisedRabbit

    Joined:
    Aug 14, 2012
    Posts:
    63
    good news https://v8project.blogspot.com/2018/08/liftoff.html
     
  13. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
  14. TOBetterMan

    TOBetterMan

    Joined:
    Jul 26, 2017
    Posts:
    6
    Now my game use LuaJit in webGL platform. what should i do,that i want to export my game.
     
  15. vb2s360

    vb2s360

    Joined:
    Oct 7, 2015
    Posts:
    34
    Hi. Does anyone knows if we can expect OpenGLES 3.1 (with compute shaders) with WebAssembly in the coming months or years ?
     
  16. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    You will have to wait for webgpu for compute shaders; I'd bet still years away. At this point I'll take Edge and Safari supporting WebGL 2...
     
  17. wbl1

    wbl1

    Joined:
    Apr 22, 2009
    Posts:
    159
    Hey - hope its ok to post this here ...

    We are building an educational application to teach kids about solar energy. We have panels on a home and are simulating movement of the sun. In the editor, shadows and the sun's reflection on the panels add great context. But when we export the project using WebGL, none of this works in the browser (neither shadows or the reflection).

    I've seen similar posts about WebGL, but those are at least two years old now. Thought those issues would have been worked out by now ...? I am aware of the quality settings and think I've done things right on my end, but maybe not ...

    Any advice or is it just the case that these features still don't work (well) in WebGL?

    Thanks
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Shadows and reflections work fine in WebGL. If you do in fact have the quality levels set properly, perhaps you used custom shaders that aren't compatible.

    --Eric
     
  19. wbl1

    wbl1

    Joined:
    Apr 22, 2009
    Posts:
    159
    Pretty sure I've applied the quality settings correctly, but am attaching current settings just in case I've missed something. Beyond this I am simply using a point light with soft shadows enabled. And, just in case there could be something with shaders, I just output a build with two simple cubes (standard/default materials and shaders) with one cube casting a shadow onto the other. Works fine in the editor - does not work in the WebGL build.

    For whatever its worth, the point light is simulating the movement of the sun. So the light and all shadows should be moving continuously. I wouldn't think that would add too many complications, but ...

    Lastly, in the event there was something up with my use of a point light, I added a simple directional light casting a soft shadow (no movement). Again, the soft shadows show in the editor but not in the WebGL build. Considering all these tests, it would seem that the light and objects (simple cubes) are not the problem. What else am I missing?

    Anything else I can look into? Losing my mind a little ...

    quality_settings.png
     
  20. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    So your webGL settings are on the lowest possible, which may be the source of the issue (see the green checkmark). They aren't actually using the 'Good' Values. I agree that this is a confusing thing with the UX.

    Click the arrow and change them to a higher quality setting
     
    JamesArndt likes this.
  21. wbl1

    wbl1

    Joined:
    Apr 22, 2009
    Posts:
    159
    Wow - that was it! On behalf of all the idiots in the world, I can't thank you enough;)
     
    arumiat likes this.
  22. yoannG

    yoannG

    Joined:
    Jul 14, 2013
    Posts:
    15
    I was wondering if we can expect or not that Unity with Webgl in webassembly mode will at some point catch up with a webgl solution made through something like playcanvas (in terms of performances, but also build time and so on).
    Playcanvas is really not my cup of tea, as it is lightyears away from Unity in terms of functionnalities, but build times are quasi instant and it works on mobile.
    What can we expect from unity in the future when it comes to building for browsers and mobiles? Is that a door closed for a long timeframe? Will we see for example a Unity for mobile first or something ?
    Sorry for the possibly very uneducated questions!
     
    vb2s360 and StaffanEk like this.
  23. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    @yoannG There was an article here that the Unity team wrote about performance. With the upcoming improvements and the ability to have managed multithreading in about a year, maybe less, they're starting with internal threads and the Unity jobs system first, I think that Unity WebGL would be something to be on. I even wrote a post on performance and it's improvements, here. With this being said, you will have to do a lot of optimization to your game to get it running smoothly on WebGL, and loading as fast as possible but that is the case with any platform anyone publishes to.
     
  24. yoannG

    yoannG

    Joined:
    Jul 14, 2013
    Posts:
    15
    @Dan_NextRevC
    "With this being said, you will have to do a lot of optimization to your game to get it running smoothly on WebGL, and loading as fast as possible but that is the case with any platform anyone publishes to."

    This is where i don't know what to think.
    If i have an empty scene in playcanvas and an empty scene in Unity, the difference in build times and loading is tremendous... or is there a way to make Unity reach the same perf in some ways already?
    That is the bottom line.. either Unity gets to be as performant as PlayCanvas, or it is forever doomed as a possible solution.

    As it is now, i have no means to pitch Unity as a game changer for web to big companies..
    I was in an interview at a 400+ people design company, and they were skeptical for good reasons..

    Bottom line: what is the roadmap of Unity to change this ? Is it even achievable ? When ? 2 years ? 4 years ?
    What is the vision of Unity on the matter ?
     
    Last edited: Oct 9, 2018
    arumiat and game_apps like this.
  25. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    @yoannG I do have to disagree with you. As stated in my article I wrote describing how I got an empty scene loading down to under 3 seconds on all desktop browsers that I tested on, I tell you what I took out and how I reduced the build size as well as the loading times across multiple browsers, additionally in the article written in the Unity Blog describes the improvements. I recommended to my company to move over to Play Canvas, for the time being, for our initial launching of a product, due to it's speed, we are now working towards transitioning back to Unity and my tests were one of the steps taken to prove that Unity had speed. Unity is easier for artists and has a lot more plugins and is more mature as a game engine so we are eager to move back. Once there are managed native threads available which I expect 2019, and there will be internal ones available through the jobs system in 2019.1, if you look through this thread. I do expect Unity to gain even more engine initialization loading speed after managed threads area a thing. What I expect you are doing and seeing is the fact that Unity first downloads the content of the project, which can be streamlined by downloading certain things after the experience has been started, or you are using complex shaders, which would slow down any engine to compile. Additionally Firefix loads it the fastest so I recommend that any demos you do are on there. If you upload a 200mb project you are going to have to download 200mb then start the engine. I do recommend you look into what exactly is in the loading speeds and what type of projects you are going for. Build time is slow, yes I agree there, Web Assembly is something the internet is excited for and companies are banking on it.
     
  26. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    That´s what I did and still do unless Unity WebGL stays incompatible to mobile.
     
    JamesArndt likes this.
  27. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    yoannG and 39thstreet like this.
  28. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    @Cascho01 From my experience and the Unity Technology folk can correct me here. Unity's incompatibility to mobile is that they do not support the full feature set. As mobile browsers improve I would suspect that Unity will support them. Also, you can run WebGL on mobile, as I said, with heavy optimizations because build should be about 20mb and download the rest during runtime. The warning message is there but you can remove it with a custom loader.js.
     
  29. CocosGames

    CocosGames

    Joined:
    Aug 31, 2014
    Posts:
    38
    Please do it, I can't wait!
     
  30. 39thstreet

    39thstreet

    Joined:
    Jan 30, 2012
    Posts:
    104
    This is great news!

    Is there a current closed beta of any sort that we can apply to be a part of? Have a significant client project I'm testing for now, and I would very much like to use Unity, but the current webgl builds are too big and slow. Would love to get involved / help test the new Instant Games platform.
     
    CocosGames likes this.
  31. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Sorry, but the private beta is very limited right now and also not something to base a commercial project on just yet since a fair amount if still bound to change, so you might get stuck with an unsupported version very fast. Once there is something available to the public to to apply for there'll be an announcement :)
     
    39thstreet likes this.
  32. CocosGames

    CocosGames

    Joined:
    Aug 31, 2014
    Posts:
    38
    Does it have to be based on Unity ECS?
     
  33. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    This thread is too long.
    Is there a way to check the current state of Unity WebGL?

    Browsers support, Web API support(Web assembly, Web Workers, Web Audio...), Unity features support(LRP, ECS, C# Jobs System...)

    Thanks
     
  34. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,664
    Check out WebGL Browser Compatibility :)
     
    De-Panther likes this.
  35. yoannG

    yoannG

    Joined:
    Jul 14, 2013
    Posts:
    15
    Unity strikes again big. I can forget PlayCanvas now :))))
     
  36. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Thanks.
    There's no mention for Web Workers. Is there work in progress to use them for threads?
     
  37. tmars

    tmars

    Joined:
    Jul 26, 2013
    Posts:
    42
    With the 2019.1 alpha just landed any chance to see multithreading support in this release cycle?
     
    OneManArmy3D and Dan_NextRevC like this.
  38. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    @De-Panther It would be interesting to see if you could write a js plugin that enables web workers and you can send managed code to them. It would probably involve C and JS in terms of languages for the plugins, I remember seeing a thread about something similar. It looked pretty complicated and I didn't have the time to dive deeper into it. Here is a medium article about it. If you do some searching I am certain you can find the thread I was talking about. If you manage to do anything on that end, I would love to know and hear about any progress.

    Medium Article
     
  39. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    @Dan_NextRevC
    I prefer not to work on this on my own, unless I must use it. From past experiences(search "WebGL Streaming"), custom solutions like that tends to break after a while...

    Currently I mostly interested in the current state regarding to web standards, and how well the WebGL build runs on mobile.(Your empty scene helped to test it, thanks)
     
  40. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    I believe you (we) don't want web workers for threads as they are not allowed to share memory between them. This greatly limits their usefulness to Unity. Really you want "shared array buffer" support in web assembly which only exists in Firefox and Chrome. So even if 2019.1 has support for threads, you still can't reliably use threads (at least not yet).
     
    De-Panther likes this.
  41. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    @kognito1 They seem to have shipped in edge, safari, and firefox according to this, although I cannot find any resources for their bug tracking (edge and safari) regarding it being disabled and re-enabled. Also using web workers would be a nice workaround for now until we get threads and then eventually managed threads.
     
  42. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    That link is technically for javascript implementations, not web assembly. :) At any rate it seems I was mistaken, even Firefox still has it disabled in javascript/wasm (https://caniuse.com/#feat=sharedarraybuffer). I'm not trying to be a debbie downer here, but Unity probably won't be the bottleneck on when we can use threads.

    I'm not sure there's any value for Unity in web workers that can't share memory. Managing one heap seems quite the challenge already. :)
     
  43. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    Awesome share thanks for that tracker. I would be okay with being browser delimited so long as when support rolls out we can just pull the trigger on it, or at least only be partially supported. I agree with web workers, but as I said, it's a real band-aid solution.
     
    De-Panther likes this.
  44. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    Also just a note, loving the number of conversations about WebGL mobile and WebGL with regards to the shared array buffer bug, been tracking that one for a long time.
     
    CocosGames and De-Panther like this.
  45. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    It's a bit unfortunate to read on the Emscripten GitHub page that WebAssembly memory growth will be disabled when threading is used. At least it isn't permanent. See this issue for details.
     
  46. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    Yeah I saw that, a deal breaker I think. Memory growth is a pretty nice way to ensure (or limit on 32-bit browsers) no memory crashes. I'd rather have that than more performance, but I can see not everyone arriving to the same conclusion depending on their use case. Unity should make this clear to end users though that opt into threading.
     
  47. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    The latest Unity 2019.1 alpha lists "WebGL: Add WebAssembly streaming instantiation support". What is this?
     
  48. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    A great thing if it's what I'm thinking it is! I suspect this will allow the browser to start compiling the wasm binary while it's being downloaded instead of having to first download the whole file. Probably won't DRASTICALLY reduce load times, but hopefully it will be a non-trivial benefit. :)
     
    jRocket likes this.
  49. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    The only non-trivial gotcha with the streaming instantiation is that you need to make sure you serve the generated 'wasm' file with the correct MIME type or it'll error out during loading. Unfortunately this is causing some issues for me when serving the content via Amazon S3 (it seems to not play nicely when I explicitly set the Content-Type HTTP header) but that's not really a Unity issue. It'd definitely benefit end users with slower download speeds and/or any larger WebGL builds.
     
    jRocket likes this.
  50. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    When this is enabled, the wasm binary is compiled whilst it's downloaded. However, for this to work you need to add application/wasm mime type to your server configuration.
     
    jRocket likes this.
Thread Status:
Not open for further replies.