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.
I suggest you expand "Drawing", "UpdateDepthTexture" and so on until you find out what's actually expensive.
Hi Marco-Trivellato, thanks for suggestion, but I didn't do that because even drawing part takes up to 50ms
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.
I don't think so, since PC build runs smoothly. Could you tell which data would be helpful here? Profile log?
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.
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.
Nothing but this kit https://assetstore.unity.com/packages/templates/systems/action-rpg-starter-kit-9076 I decreased far clip plane for the rendering camera, and it indeed reduced time per frame to 60+ms, but this heavily affects gaming experience, so I suppose that the amount of objects to be rendered is far from being acceptable for WebGL.
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)
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?