Search Unity

Low performance

Discussion in 'Web' started by Macode, Sep 3, 2018.

  1. Macode

    Macode

    Joined:
    Nov 28, 2013
    Posts:
    38
    Greetings, I have build for WebGL and it takes ~160 ms per frame rendering, while the same project with PC build takes ~8ms and runs smoothly in editor.






     
    Last edited: Sep 3, 2018
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I suggest you expand "Drawing", "UpdateDepthTexture" and so on until you find out what's actually expensive.
     
  3. Macode

    Macode

    Joined:
    Nov 28, 2013
    Posts:
    38
    Hi Marco-Trivellato, thanks for suggestion, but I didn't do that because even drawing part takes up to 50ms
     
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Could it be that there are just too many objects in your scene? It's really hard to tell what's the problem without any more info.
     
  5. Macode

    Macode

    Joined:
    Nov 28, 2013
    Posts:
    38
    I don't think so, since PC build runs smoothly. Could you tell which data would be helpful here? Profile log?
     
  6. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Standalone builds are native applications and use multi-threading, whereas Unity WebGL runs single-threaded in a VM inside the browser. This page will tell you what you can expect from Unity WebGL in terms of performance.
     
  7. Macode

    Macode

    Joined:
    Nov 28, 2013
    Posts:
    38
    Yep, I read it in right before getting to forum and in the top there is a line "the WebGL graphics API uses your GPU for hardware accelerated rendering", so this is the main reason why I don't take into consideration any CPU/multi-threading issues, since profiler shows me 20 times bigger rendering time for WebGL than PC build.
     
  8. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Could you describe what's in your scene?
     
  9. Macode

    Macode

    Joined:
    Nov 28, 2013
    Posts:
    38
  10. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Try switching to deferred rendering. UpdateDepthTexture and UpdateDepthNormalsTexture are very expensive for forward rendering but you get them for "free" in deferred. Alternatively, stick with forward rendering and figure out what is causing the Depth/Depth Normals to be generated and remove it(probably cascading shadows, a shader, and post effect)
     
  11. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Try checking if browser is using the GPU
     
  12. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    My Unity app loads many images from the internet, often. I created a native build, when ever it loads an image from the internet the whole game freeze for up to5 seconds. I solved that problem with the WebGL build by using worker threads, but native builds dont have javascriot so cant use worker threads to solve the freeze problem.

    For a native build, do you know how to create a background thread to download a texture from a URL then apply the texture to a gameobject?