Search Unity

Burst, Jobs in WebGL build

Discussion in 'Entity Component System' started by MikeUpchat, May 14, 2021.

  1. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Hi There
    What is the state of Jobs and Burst in a WebGL build? Should it be running the same speed as you get in a standalone PC build? When I build my test project for standalone it runs fine, hundreds of FPS using Jobs and Burst for some complex processing, but the same build for WebGL runs really slowly. I have the project settings set the same for both so Burst and Jobs should be compiled just the same. Am I missing some setting, or do Jobs and Burst just not work well in WebGL builds?
     
  2. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    Hello, Burst should be fine in WebGL build but multithreading support in Web browser is not "mainstream" yet.
    So you most likely don't run jobs in your WebGL build.
     
    Nyanpas likes this.
  3. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    How about interfacing with JS-Webworkers?
     
  4. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    I think it's the plan but last I tried a few month ago it required manually activating some things in the browser which is not ideal in term of end user experience.

    I'm actually amazed the OP project worked. Mine simply failed when having any schedule in my code. Maybe Unity did something in the build pipeline for web gl to replace schedule by run?
     
  5. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Here's an exampulatory WebGL-project that I have that runs with Burst + Jobs:
    https://quakeulf.itch.io/chairs

    It's of course singlethreaded as of now if what is being stated is correct, but the object generation/manipulation is all done using the Job System.
     
  6. Stormer2020

    Stormer2020

    Joined:
    Sep 14, 2020
    Posts:
    92
    If you build on Windows. And have not set this:
    JobsUtility.JobWorkerCount = 5;
    JobWorkerCount will be auto.

    If you build on WebGL.
    JobWorkerCount default 0, And it must be 0 .

    So, same code, WebGL more slower. (Just single thread)
     
  7. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    starock2020 where do you set JobWorkerCount in code?