Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Did anyone get multithreading to work?

Discussion in 'PSM' started by Kriechgebuesch, Jun 9, 2014.

  1. Kriechgebuesch

    Kriechgebuesch

    Joined:
    Nov 8, 2010
    Posts:
    7
    I'm running a second thread that generates noise (with times up to 300ms on the Vita). When I run the game on my PC it definitely runs the noise function in a separate thread as even calculation times as high as 4000ms do not interfere with the framerate. On the Vita however it seems to run everything in the main thread as frame rate appears to be strongly affected. Has anyone gotten multithreading to work on the Vita yet? Is this even a supported functionality?
     
  2. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    There could be other reasons why it's stalling. A second thread should have the possibility to run in parallel with the main thread.

    Any chance you could attach your project to a bug report?
    That way we can have a look and see what is the problem..
     
  3. Kriechgebuesch

    Kriechgebuesch

    Joined:
    Nov 8, 2010
    Posts:
    7
    Thanks, I have attached the project to a bug report now (Case 612673). Interestingly I found out that the noise generation thread seems to run as intended once I run an expensive call that creates a Texture2D object out of the generated noise data in the main thread. Is it possible the Vita automatically assigns secondary threads to the main thread if it isn't busy enough?
     
    Last edited: Jun 9, 2014
  4. ng93

    ng93

    Joined:
    Aug 31, 2012
    Posts:
    40
    Kriechgebuesch, did you manage to fix the problem? I'm having the same issue (have filed a bug report), but wondering if there may be a workaround.
     
  5. Kriechgebuesch

    Kriechgebuesch

    Joined:
    Nov 8, 2010
    Posts:
    7
    Sorry for the late answer ng93 but unfortunately I have not. Haven't heard anything about my bug report either so far.
     
  6. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Hi guys - thanks for the bug reports.
    The reason why you see those stalls is because your worker thread "steals" cycles from the main thread (because your main thread is pretty much idle a bit part of the frame update).
    I've adjusted the thread priorities a bit to make sure this doesn't happen, and we are planning a hotfix release which will include this fix.
    Sorry for the inconvenience.
     
  7. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    ooh a hotfix, what else is included with it? fog? :D
     
  8. Kriechgebuesch

    Kriechgebuesch

    Joined:
    Nov 8, 2010
    Posts:
    7
    Ah! Great to hear! :)

    Positively surprised this wasn't just me being stupid and overlooking something obvious. Also no need to apologize, I except little convenience for free products, especially when they are in Beta! ;)
     
  9. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Not fog, no (fog can quite easily be added to a shader ;)
    But GPU crash fixes, the AssetBundle Caching API, and some other things..
     
  10. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
  11. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
  12. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Hi Erique,

    This hotfix is great but doesn't solve the issue with multithreading, should it have been included in this hotfile?

    Thanks,

    Jon
     
  13. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Also FYI, while the hotfix seems to resolve the cache issue asset bundles still do not work:

    The unity3d file is not a valid asset bundle

    Is posted into the log when attempting to load a scene from an asset bundle :(
     
  14. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    It solves at least the two issues mentioned earlier in this thread.
    Could you be a bit more specific on what doesn't work and/or report a bug with a small project that shows the problem?

    As for the problem with AssetBundles - that is off-topic, and there is already a thread about that.
    I'll see what I can do about posting an example to that thread.
     
  15. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Thanks Erique, the situation with the threads relate to spawning a temporary thread to process a task once it completes it closes and a new one is spawned 0.25 seconds later... I notice around a 0.1 second pause every 0.25 seconds. I'm assuming it's the thread running...but it could be that spawning a thread on PSM actually causes a delay...is this likely do you know? I'll try and create a bug report, but it's quite a complex project, I'll try and strip it down....if not are you okay with the whole project if I give you repro instructions?