Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Smooth WebGL build loading

Discussion in 'WebGL' started by yavora, Oct 6, 2016.

  1. yavora

    yavora

    Joined:
    Jul 27, 2014
    Posts:
    7
    Hi there!
    I'm just wondering - is it possible to have smooth loading for webgl builds?
    I just released my game on Greenlight and received few feedbacks regarding web demo, that it's impossible to know if game is loading or not.
    Demo - http://www.konstructors.com/wayout_demo.html
    Also, can i change loading screen design somehow?

    Any tips/recommendations re this topic?
    Thanks!
     
  2. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    As far as I know there is not. I wish for the same. It is very common in other game engines to see a circular loading indicator or progress bar on web games. I think Unity themselves would need to add that because as far as I know we can't do anything in code until it is all fully loaded.

    If that is not correct hopefully someone lets us know!

    I think the best you could do is create a very simple scene as your Loading Indicator and from it load the first real game scene. Use a co-routine in the Loading Indicator to do a simple color change on Loading.... or maybe even a sprite anim (no idea at which point those would be flushed) nor how long the co-routine would remain active.

    To be able to display a loading % indicator you'd need to basically not use scenes populated with GameObjects and instead manually load all resources so you know what needs to be loaded and how much remains. This is why it seems to me Unity would need to add it themselves. Be the best way. Their program will know exactly what all needs to be loaded and how much work remains.
     
    Last edited: Oct 6, 2016
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,495
    Could you not add something to the web page, and have your game make a JavaScript call to remove it after the load finishes?
     
  4. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Maybe. I have no idea if Unity can interact with a web page in this way. Also I don't know if any element in the web page would show up since the Unity game window would be there. I suppose it might be possible to create a custom Unity web page template that allows that. Still not sure about interacting with the web page elements from within Unity though. I figured that wasn't possible.

    Even if that stuff could be done the best we'd get is an animated Loading text or image because unless explicitly loading everything we'd have no clue how much loading we have done and how much is left to do. And I also don't know if any of this would be active in WebGL until the entire thing has loaded in.

    All of these things would need to be tested and I have no drive to do that now anyway. Need to get some progress done on my Halloweenish game.

    It seems like it would be much better for Unity to add the option to the Scene Management API.
    [ ] Show Scene Loading Progress Bar
    Also provide a way to enable/disable in code with the API.

    That would be a start. But it's more than that I think. Not sure but I think the delay is from actually loading in the Unity program (and libs etc) and probably decompressing that stuff so that is the part where I think Unity can do it and we cannot. The delay in WebGL I see is the wait to see the Unity Splash screen. Once it fades away everything is super fast from that point on.
     
    Last edited: Oct 7, 2016
  5. mikaelwallen

    mikaelwallen

    Joined:
    Jun 3, 2016
    Posts:
    56
    theANMATOR2b likes this.
  6. stephanwinterberger

    stephanwinterberger

    Joined:
    Aug 22, 2016
    Posts:
    27
    We are having a similar issue. As I wrote in another thread (https://forum.unity3d.com/threads/webgl-loads-painfully-slow-at-20-of-our-users.428378/#post-2817350) we are loosing many users before we can even display a loading screen. The main problem is that the browser freezes when it tries to parse the huge JavaScript file. Our file is 25mb big (we weren't able to cut it down further because we need some feature of the physics engine). This 25mb block the whole UI so until the 25mb are parsed and interpreted by the browser you can not display anything. Even our animated svgs freeze. The only thing which worked for us was a hack with a video but this is very suboptimal and not a real acceptable solution for us.
    Would be great to hear if somebody solve the problem with freezing the whole browser. This is not really a nice user experience!
     
  7. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    475
    The whole situation does seem ridiculous.

    if you make an empty, minimal Unity project and make it into a WebGL module. Ensure you gave compressed it, fastest loading setting, etc etc.

    It takes a good 7 to 10 seconds to load in a browser.

    And there's no thermometer during that time, nothing whatsoever.
     
  8. PNUMIA-Rob

    PNUMIA-Rob

    Joined:
    Jan 7, 2015
    Posts:
    33
    Agreed -- While after the first scene is loaded we are able to track loading progress with asynchronous loads, the initial WebGL startup time, even if the first scene is nothing more than a splash image and script to load the next scene, is simply awful -- and that awfulness is a near showstopper because there's nothing but a black screen to stare at for that eternal-feeling 7-10 seconds. We have been looking for a solution or workaround for this for a while and have yet to find anything reasonable.

    Is there nothing that can be done?
    ... if not, hopefully the new Webassembly builds will solve this troublesome issue.
     
  9. bkachmar

    bkachmar

    Joined:
    Mar 15, 2013
    Posts:
    41
    Hi guys, in my case I just make whole Unity game invisible from the very beginning put my own Javascript preloader on top.
    The preloader works until it receives a custom message from Unity (in Start() function of one of gameObjects) and then destroys itself and makes gameInstance visible.
    The problem I have is that Unity freezes the whole window in addition to the fact that I don't have the correct loadaing progress data.
    But this is another question...
     
    angrypenguin likes this.
  10. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    I've found CSS animations don't seem to stutter or freeze in Chrome/Firefox unlike other ways of doing animations such as GIFs, JS-based animations, etc. so that might be worth a try. Also exporting to WebAssembly if possible.