Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Games made with Unity 3D performs bad on iOS and on other platforms works flawless

Discussion in 'iOS and tvOS' started by Lomardii, May 13, 2014.

  1. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    Hi!

    I'm the creator of the games PONGO PONGO and Flappy Forever. The games work smooth and as expected on Windows Phone (520, 720, better not checked) and Android devices (Galaxy S2, HTC Desire HD, Some old Tablet). I have checked it on tablets and phones with one and two processors. However when it comes to iOS it performs very bad (checked on iPhone 4 and iPad 2, but not works smooth also on iPhone 5 - saw it on mate phone). After setting game to 60 fps it works better but other aspects goes wrong, like rigidbody movment which simply starts to jitter/stutter in movement. Xcode shows 31/30 fps and CPU reaches max 70% on flappy and 30% on PONGO PONGO. For 60 fps shows 47/50 fps.


    Here is a list of links to compare the effect:
    Pongo Pongo on iOS, Pongo Pongo on WP8, Pongo Pongo on Android
    Flappy Forever on iOS, Flappy Forever on WP8, Go Gacek, Go! (Flappy Forever extended) on Android

    On PONGO PONGO the ball movement is not smooth, can it be caused by hardware screen on iPhone? Maybe has better refresh rate what casues that we see all nuances?

    I'm not using vsynch. I remember to use kinematic on all rigidbodies where the movemnt is scripted (actually now there are no such cases) I'm using interpolation everywhere it is need. The camera is always static. The scroll effect in Flappy is achived by moving sprites across scene. Not using Instantianite in game (all are made on game load) and tried to optimise game by removing memory allocation on heap.
    Also I'm using avg. deltaTime for 120 frames, to get better smoothness than with smoothDeltaTime and deltaTime.
    I'm using Transform for some objects and others are just ridigbodes on which the force is oparating.
    Games are often mix of 3d and 2d. I didn't change Time settings. I use atlases for sprites.

    Do you any have clues? It is annoying that iOS positioned as most mature and optimiesed performs worst. I'm sure it could work better, everyday I see better and more sophisticated games which works flawless (but probably not written in Unity).

    Have read a lot official docs about optimizing but probably had missed something. Please help! Maybe you have some check tool which scans code and warns about hazard configuration/api use?

    Thanks in advance,
    Olek!
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    iPhone 4 is problematic device (one core CPU, weak GPU for resolution that big) so it is normal that physics heavy games or games that have lots of overdrawing give low FPS. But iPad 2 should run your games just fine performance wise.

    Best thing is to check Unity and Xcode profilers with iOS device and see what is causing all the CPU/GPU usage.
     
  3. hutch_jl

    hutch_jl

    Joined:
    Jan 8, 2013
    Posts:
    40
  4. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    Thanks!!! It is shame that they have not reproduced it.


    I have even created empty 3d project. Added white background for main camera, added one black 3d ball and added script to it:

    Vector3 startPosition;
    public float radiusY = 2.5f;
    public float floatSpeed = 2f;
    float angle = 0.0f;


    void Start () {
    Application.targetFrameRate = 50;
    startPosition = transform.position;
    }

    void Update () {
    angle += (floatSpeed * Time.smoothDeltaTime);
    float y = radiusY * Mathf.Sin(angle);
    float x = (radiusY / 2.5f) * Mathf.Cos(angle);

    Vector3 p = transform.position;
    p.y = startPosition.y +y ;
    p.x = startPosition.x + x ;
    transform.position = p;

    }

    and you know what? it is still jittering and chockes every 1.5 sec. (like it would be garbage collected).
    Test were done on iPhone 4 with newest iOS and Samsung Galaxy S2.
     
    Last edited: May 21, 2014
  5. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I'm waiting for Unity 4.5 really need hurry with it as it suppose fix number iOS specific issues
    Slow iphone 4 startup times for Unity games etc and hopefully other performance increases.
     
  6. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    This sounds like semi-known issue of iPhone 4 with latest iterations of iOS. iPhone 4 is the last single core device still getting OS updates, but as the amount of background tasks rises it fails to cope with them fluently. Many users reported that disabling various background services (like push notifications, background app refresh, etc.) makes this problem go away. Quick way to test if that's the same problem it is to put phone into airplane mode and see if it improves things.
     
  7. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    Is it possible to compile code for iOS 7 from Unity 3.5? Maybe I will back to the old Unity and compare the results?
     
  8. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    Ok.

    I have downloaded Unity 3.5.x and started above example project. The project compiled on iOS 7 and on iPhone 4 all was quite smooth and performed much better that existing game project.

    Now I have done the same on 4.3.4 and also achieved smoothness! Wow! ;-) It is a big progress! The example worked even better than with Unity 3.5.x. Don't know why didn't achieve it for the first try, maybe it was caused by doing only "new scene"...

    Next step was to start to striping the existing game from functionality to "catch" the difference. Stripped all to minimum and made sure that all configuration parameters were the same but with no luck. Probably the project stuck in "bad state".

    Today I will start a new project and start to copy elements from the existing game one by one. I hope I will get the smoothness. Then if on some progress things goes wrong I will report you what caused the problem. A lot of work to do. Maybe you could sponsor some reward ;-) Like a half year of license for Unity 4.3 Pro? ;-)

    Thanks and see ya later!
     
    Last edited: May 23, 2014
  9. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    I'm after recreating project. I have bad and good news. The good is that I get rid of stuttering. The object no more jitter when moving. The bad news is I don't know what was the cause, but its probably not in user code, but in project configuration. I have also some conclusions:
    - assigning audioclip to audiosource for playing effect can choke the game, just create separate objects with audiosource and play its sounds (it should be hidden from user by Unity by for example making "sound atlases")
    - run Garbage Collector every time you think it won't impact the gameplay or you will finish with choke in most important moment of the gameplay
    - always fight for 60 fps
     
    Last edited: May 24, 2014
  10. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    Hi!

    After rewriting project I had still some chokes and found the reason. It is only on iPhone 4. I use GUIText for displaying counted scores. Setting GUIText.text was causing serious chokes. It was simple update like guiText.text = score.ToString() (removing that assigment made chokes gone away!!!)

    The env. spec:
    - iPhone 4 with iOS 7.1.1
    - Unity 4.5
    - SDK 5.0
    - Fonts are dynamic with smooth render (maybe I should use os default?) at size 16
    - GUIText is pixel corret with rich text. Size of font is adjusted only at Start to meet device resoultion requirement.
    - On scene there are some 3D models with physics rigidbody and colliders.
    - Framerate is at 60 fps

    Hope you can confirm that and of course fix it or the iPhone 4 user will be disappointed....
    On iPad 2 and higher models there is no such issue....
     
  11. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Can you log a bug please, iphone 4 has always been a issue with Unity and most bugs are linked to the iphone 4
     
  12. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    How to do that? Unity Issue Tracker has no option to log a bug. There should be more explicty way of doing that.
     
  13. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Yes I agree, its a pain you cannot log bugs from the web, you need log from Unity3d goto help menu and log bug.
     
  14. Lomardii

    Lomardii

    Joined:
    Dec 17, 2013
    Posts:
    35
    Ok, found the reason and solution for the guiText. Don't know if it is a bug or by design. For each guitext where I've defined font I had also assign that font material. Note that when you change font you have always to change also font material or your text screws up.

    Chokes has gone and game works smooth! Sometimes it chokes a little but I guess it is caused by Ads in WebThread or GC.

    Now I'm ready to release my game at 60 fps ;-) !!!!