Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Why is my game so much slower on WebGL than on desktop?

Discussion in 'Web' started by JoeStrout, Jan 19, 2020.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I've made a benchmark program that does various operations, mostly running Mini Micro code (which is implemented as plain old C# code). Running this in the WebGL build, on the very same MacBook Pro as the desktop build, everything takes substantially longer:

    upload_2020-1-19_8-7-26.png

    And this doesn't seem to have anything to do with graphics per se; some of the worst offenders (Semiprime and Race Sim) generate no output at all while they're cranking away. It's all just math and looping.

    Any idea why the same code running on the same hardware should be 2-4 times slower in a WebGL build?
     
  2. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    C# vs Javascript...?
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Doesn't Unity compile to web assembly? Or is it still building to JS? (This was made with Unity 2018.2.2 in case that matters.)

    I've been assuming web assembly's VM is not so different from C#'s VM in terms of performance, but maybe that's not true. I should have also mentioned the browser I was testing in (Firefox), and I guess I should test with other browsers, in case not everyone's webasm is created equal.
     
    wetcircuit likes this.