Search Unity

Worker Threads for WebGL

Discussion in 'Web' started by nsmith1024, Jul 12, 2018.

  1. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Anybody knows when worker threads will hit WebGL?

    I have a huge problem when loading images, the whole thing freezes, and people complaining to me about that all the time.

    Sometimes it has to load maybe 10 or 20 images at the same time from the server, then the whole thing keeps stuttering for a while.

    I believe worker threads would help?
     
  2. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
  3. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Oh thank God! it would certainly help many people, including myself!

    And i hope they throw in animated GIFS too, would be great!!
     
    Last edited: Jul 13, 2018
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    We are working on WebAssembly threads support as we speak. Just a reminder that as of today what's needed to get this to work is disabled by default in browsers.
     
  5. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Great, i cant wait, the stutter while downloading images is giving me hell over here!!

    Would the worker threads (for example threaded download of images) be done automatically, or do we have to change our code to make it work?

    Not only downloading images, but image processing, like decoding images, and stuff like GetPixels Set Pixels, and ImageResizing etc need to be threaded so that it doesnt cause stuttering when doing that on large images.

    I wonder why browsers would want to disable threads by default, isnt every language on earth already using threads already? So whats up with that?
     
  6. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I don't think you will have to change your code, however, initially we won't support managed code threads.

    security concerns.
     
  7. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    I glanced the article, seems its a hardware problem where its not stopping one program from reading data from another program.

    Doesn't this affect every program not only browsers? Cant a hacker use ONE thread to do the same thing, so why block multiple thread capability in browsers, if they can do the same hacking with just one thread?

    Is It that the secondary browser thread hangs around following you from site to site stealing your data where ever you go (I probably shouldn't have said that.... giving hackers ideas)

    The browser should kill off all the threads when it leaves a site.
     
  8. Baraphor

    Baraphor

    Joined:
    Nov 16, 2016
    Posts:
    32
    SharedArrayBuffers?

    Chrome Announced on July 11th that they are coming back, I am not sure exactly when, it is hard to get a clear answer, but they also mentioned the other browsers are working on things as well. I would think it is reasonable that we would see at least the 4 major browsers all having support back by default by the end of the year.

    https://security.googleblog.com/
     
  9. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    While I wish it were true, I have serious doubts about SharedArrayBuffers coming to Edge/Safari before 2019 (or WebGL 2 for that matter). I'd guess we're still a year+ out before we can reasonably rely on ~all end users having threads/simd support. :(
     
  10. Dan_NextRevC

    Dan_NextRevC

    Joined:
    Apr 18, 2018
    Posts:
    19
    Chrom Bug was resolved yesterday, so we might see it coming soon. Been following that for a while.