Search Unity

Profiling Experts Needed :p

Discussion in 'Editor & General Support' started by NestorAlgieri, Mar 24, 2018.

  1. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    Hi.

    I have a game that runs just fine performance wise. I test on lower end devices to ensure max compatibility.
    The weird thing is the game would go through a period of good fps and then drops 50% fps for a period, then goes back up. It would just go back and forth.

    I would just stand still in the scene and stare at the scene. Then I decide to look away from all the objects so nothing is on the screen except an empty terrain and I would not move and see if this happens. There's no AI or anything going on. And this weird low/high fps swapping would still keep happening. So I profile it to try to find out what is going on. This only happens on the actual low end device not in the editor.

    I wonder if it's because I'm reading the profile wrong or is it something in the device running in the background causing this and nothing to do with the game itself? So I have attached the screenshots to get some opinions on what this low/high fps swapping is cause by. Hopefully I can get some help:

    Here's the profiler screen cap with just rendering and script and physics enabled to show it's not so much the scripts that's causing lag but the rendering, the GC also doesn't seem to be the cause:
    upload_2018-3-24_11-9-37.png


    Here's enabled with "Others"... seems like "Others" is also taking a chunk of time, what is "Other"?? "Audio" is getting affected during the same period?
    upload_2018-3-24_11-8-17.png

    I'm not allowed to add more images so I'm posting more in the next post <to be continued>
     

    Attached Files:

    Last edited: Mar 24, 2018
  2. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    So to conclude my dumbness. I have no idea what to make of this. I mean I'm staring at the terrain and not moving, why is the fps changing? I can understand if I'm looking at lots of objects then looking away then the fps would change but I'm not. And scripts are not doing anything, just the overall performance is going up and down, especially the rendering. p.s. it's just a static screen with some buildings on a terrain, all objects are marked static.

    good fps frame:
    upload_2018-3-24_11-20-58.png

    bad fps frame:
    upload_2018-3-24_11-21-17.png

    Thanks for any help in advance!
     

    Attached Files:

    Last edited: Mar 24, 2018
  3. EdKirby

    EdKirby

    Joined:
    Nov 15, 2013
    Posts:
    43
    I don't have an answer for you per se, but I noticed about a 60% increase in cpu load that coincides with your 50% drop in frame rate. If it wasn't cycling like that I'd suggest it might be related to rendering and the need for atlases and batching and the like but this is strange. Just spit balling but is there anything running in any Update() functions that could be doing it?
     
  4. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    Well I do have code in Update() but they would be run every tick consistently not in waves. So I suspect it cannot be due to game code. p.s. This only happens on this low end "LG Cricket" phone. I don't experience this behavior on something like a LG G4.
     
  5. EdKirby

    EdKirby

    Joined:
    Nov 15, 2013
    Posts:
    43
    Interesting. I'm not an android guy, my game is going on iOS first, so I'm not sure what's going on here. What about the quality setting such as vsync? Have you tried turning vsync off (or on)? How about forcing framerate with Application.targetFrameRate = 60 and seeing what happens? I think you have to turn vsync off for that to work but not sure.
     
  6. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    I appreciate it. Thx for trying anyhow. I did turn off vsync, and tried Application.targetFrameRate = -1 as some suggest. It didn't change anything.
     
  7. EdKirby

    EdKirby

    Joined:
    Nov 15, 2013
    Posts:
    43
    You're welcome! I wish I had a quick answer for you. How long does it take before the frame rate begins to drop and what is the duration? Could the device be over heating?
     
  8. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    Hi it lasts anywhere from 10-20 seconds in either the slow or fast period. The device isn't hot, this behavior starts as soon as the game starts. I wonder if there's some background job running in the OS.
     
  9. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    Hm.. the logcat has these logs, I wonder what the heck it is doing this for, it's not even hot! Haha at least I know it's not my code. I get the same thing with other games on this device. Thx for the help.

    03-24 20:03:42.534 361 450 I ThermalEngine: Mitigation:CPU[0]:1094400 Khz
    03-24 20:03:42.534 361 450 I ThermalEngine: Mitigation:CPU[1]:1094400 Khz
    03-24 20:03:42.534 361 450 I ThermalEngine: Mitigation:CPU[2]:1094400 Khz
    03-24 20:03:42.534 361 450 I ThermalEngine: Mitigation:CPU[3]:1094400 Khz
    03-24 20:03:42.534 361 450 E ThermalEngine: ACTION: GPU - Setting GPU[0] to 409600000
    03-24 20:03:42.534 361 450 I ThermalEngine: Mitigation:GPU[0]:409600000 Hz
    03-24 20:03:47.535 361 450 I ThermalEngine: Mitigation:CPU[0]:533333 Khz
    03-24 20:03:47.536 361 450 I ThermalEngine: Mitigation:CPU[1]:533333 Khz
    03-24 20:03:47.536 361 450 I ThermalEngine: Mitigation:CPU[2]:533333 Khz
    03-24 20:03:47.536 361 450 I ThermalEngine: Mitigation:CPU[3]:533333 Khz
    03-24 20:03:47.536 361 450 E ThermalEngine: ACTION: GPU - Setting GPU[0] to 200000000
    03-24 20:03:47.538 361 450 I ThermalEngine: Mitigation:GPU[0]:200000000 Hz
     
  10. EdKirby

    EdKirby

    Joined:
    Nov 15, 2013
    Posts:
    43
    NestorAlgieri likes this.