Search Unity

Horrible framerate in landscape mode on Lumia 830

Discussion in 'Windows' started by johandanforth, Nov 20, 2015.

  1. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I've seen some troubling posts about bad framerate on Windows Phone, and especially the 830, but this is so weird I have to post it here. I'm using Unity Version 5.2.2f1 (3757309da7e7) Personal and a dead simple scene with a slowly rotating cube. Building as Windows Store Universal 8.1 Windows Phone app with default player settings (autorotation etc).

    When running in portrait mode, I get a pretty good framerate of 30+ fps, but when I turn to landscape mode, framerate drops like a rock to ~10 fps. Compiled in Master mode. It doesn't matter if I force it into landscape mode. It's still the same. Totally unusable. I thought I might try and change the resolution, but it seems that 830 only has one reslution, and if I try to change into anything else, screen goes black. What else can I try here?

    Portrait mode:

    wp_ss_20151120_0008.png

    Landscape mode:

    wp_ss_20151120_0011.png
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    That is super weird. Even on portrait, the performance is much less than desirable (single cube should be easily hitting 60 fps).

    Did you try using Unity's profiler to see what's up? What does it say?
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    What OS (8.1? 10 Preview?) does the device run?
     
  4. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I'm using personal edition unfortunately... so no profiling :(
     
  5. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    Device is running a fresh install (+ official updates) of 8.1
     
  6. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I just tried it on my wife's Lumia 640 LTE, and get the EXACT same behaviour. That device is also running PW 8.1 update 2. So what's going on here...
     
  7. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    Ok, plot thickens... I did a build for Store -> Phone 8.1, but got the same bad framerates. THEN I did a build for the (soon unsupported) Windows Phone 8.0 (which is actually silverlight on wp), and guess what - 60 fps! On both portrait and landscape modes! Even if I change target phone os in application settings in Visual Studio to Windows Phone 8.1, I get good frame rates.

    So... *confused*... I'll probably focus on the Android + iOS platform anyway, but I like Windows Phone and would love to be able to publish our game on it as well :/
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Profiler is available on all Unity editions. Both personal and professional.

    Are you sure that you deployed using master config on WP8.1? The only thing I can think of why WP8.0 would perform better is that we don't ship "Debug" binaries there, so "debug" is actually same as "release" on WP8.0 (which is not the case on WP8.1).
     
  9. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    Oh, didn't know that! Will try!
     
  10. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    But isn't there is a huge difference between a Windows Silverlight 8.0 project and a Windows 8.1 and Universal project? Different runtimes? It also wouldn't explain why it works (pretty) well in portrait mode but not landscape.

    Well, I've selected "Master" configuration, ARM and Device, then go CTRL+F5, and there is no "Development build" showing in the screen. Or is there something else? I've not checked the "Development build" checkbox in Build Settings in Unity.

    master.PNG
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    I had the exact same behaviour, only with a Lumia 925 running Windows 10 phone preview.

    8.0 build -> 50-60fps
    8.1 build -> 15-20fps.

    So I was assuming that it had something to do with Windows 10 phone preview, but maybe not?

    (also I'm on 4.6.9p2, but it sounds like exactly the same issue)
     
  12. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    Ok, I've tried the profiler now. But I've never seen or used it Before so I'm a complete newbie on it. Anyway, in Debug mode, debuging from VS 2015 and deep profling on, I get a whopping 4-6 fps (wheeee) and the profile window looks like this, with occational spikes:
    profiling_830_1.PNG

    Usually seems to be "overhead 95%" on top. If I drill down on a "spike", you get this:

    profiling_830_2.PNG

    I guess that's the OnGUI script I added to get the framerate. My rotating cube scripts looks like this:

    Code (CSharp):
    1. public class Cube : MonoBehaviour
    2. {
    3.     private float deltaTime;
    4.  
    5.     // Update is called once per frame
    6.     private void Update()
    7.     {
    8.         deltaTime += (Time.deltaTime - deltaTime)*0.1f;
    9.         transform.Rotate(Time.deltaTime*100, Time.deltaTime*10, Time.deltaTime*10);
    10.     }
    11.    
    12.     private void OnGUI()
    13.     {
    14.         int w = Screen.width, h = Screen.height;
    15.  
    16.         var style = new GUIStyle();
    17.  
    18.         var rect = new Rect(0, 0, w, h*4f/100f);
    19.         style.alignment = TextAnchor.UpperLeft;
    20.         style.fontSize = h*4/100;
    21.         style.normal.textColor = new Color(0.0f, 0.0f, 0.5f, 1.0f);
    22.         var msec = deltaTime*1000.0f;
    23.         var fps = 1.0f/deltaTime;
    24.         var text = string.Format("{0:0.0} ms ({1:0.} fps) {2} x {3}", msec, fps, Screen.width, Screen.height);
    25.         GUI.Label(rect, text, style);
    26.     }
    27. }
     
  13. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I downloaded and installed the latest Unity 4.x version, created the same simple scene and built a universal 8.1 phone Project, and I get 60 fps out from it! Same thing with a more complex Project with a flying low-poly x-wing starship - 60 fps in a Unversal 8.1 Windows Phone app if build with Unity 4.6.9. If I create the exact same scene in Unity 5.2.3 I get 28 fps in portrait and 10 fps in landscape mode.

    Then I tried something else - I migrated the Project from Unity 4 to Unity 5, and built and deployed to the phone, and got 60 fps!
     
  14. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I've tried my best to compare the two Projects; the converted and the newly created, but there are few differences. Checked off shadows and realtime baking, but there is no difference. I'm off to bed now, I can't figure out anything else to try now, except throwing my Windows Phone in the trash and buy an Android :/
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You're supposed to attaching Unity profiler to the phone, not the editor. Profiling editor is useless.

    In either case, it does sound very fishy. Could you maybe submit a bug with the project attached so we could take a look? We definitely need to get this solved. If this is something not obvious in project settings that's causing it, we should find ways to make it clearer.
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Did you get it solved? If not, I'd be glad to help to get it resolved. WP8.1 apps should definitely perform much better, not worse than WP8.0.
     
  17. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    No, I didn't solve it. Since, AFAIK, it only happens on an OS that is not officially out yet (Windows 10 Phone), I didn't have much hope for it getting fixed on Unity 4.6.

    Give me a couple of days, I'll investigate some more and prepare a scene.
     
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Thanks.
     
  19. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I said I was a newbie with the profiler... I'll see if I can do it right and get back.
     
  20. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I submitted a bug report with a Project attached yesterday, hopefully it worked. I've also zipped and uploaded the whole directory of a Project with the rotating cube to my OneDrive, you can get it from here: http://1drv.ms/1XgjGuo
     
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Did you get an email telling you the case number?
     
  22. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    Yes, case 746402.
     
  23. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    I did some testing and I submitted a bug report.

    Here are the results running on a Lumia 925 running Windows 10 Phone

    8master.jpg
    81release.jpg
    81master.jpg

    There is definitely something wrong with the 8.1 Master build. Case number 747232.

    Edit: Forgot to mention, building with 4.6.9p2
     
    Last edited: Nov 24, 2015
  24. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    I just now received word from Unity support saying they've been able to reproduce this bug!

    We have been able to reproduce this bug and have sent it for resolution with our developers.
    Sounds like we can look forward to a bug fix! Yay, I found a bug! :D
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yup, it's weird. We could only reproduce it on Lumia 1320, and not any other phones we have so far (we don't have 640 or 830 yet). I'm going to order one of those to my office to investigate further.
     
    johandanforth likes this.
  26. johandanforth

    johandanforth

    Joined:
    Aug 16, 2015
    Posts:
    16
    Trust me to find problems on the two models I have at home... :) Anyway, I really appreciate you looking at this, even though WP is a smaller segment. I thought I was going crazy with this thing :)
     
  27. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Did you take a look at my issue as well? I am not sure it's the same issue. (seems to be specific to Windows 10 Phone)
     
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Not yet.
     
  29. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I tried it on Lumia 920 running windows phone 8.1, and Lumia 1520/Lumia 930 each running windows 10.. and I got rock solid 60 fps. Then I retested it on 4.6, and I got the same results.

    I'm quite surprised that you're getting worse results on master build. Do you have a debugger attached when you're measuring? In my experience, it can negatively impact performance.
     
  30. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    No I don't have a debugger attached.

    Master "Phone 8.1" (not universal, maybe it's relevant?) build, is more or less behaving like it's capped at 30 for some reason.

    Master Windows Phone 8 is fine.

    I don't know, maybe it's specific to the device (925?), somehow? The specs are almost identical to the 920.

    I have a 920 as well, but I it's the 8.1 testing device, I'd rather not upgrade it to 10 as well.
     
  31. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Could you attach a profiler to "release" build to see whether anything's fishy? If release build performs better than master, it's possible to use native platform profiler to profile master build.
     
  32. Sievlar

    Sievlar

    Joined:
    Oct 3, 2012
    Posts:
    68
    FWIW - I filed a bug months ago (case 674267, project on case 676009) related to standard shaders not working correctly on Lumia 635 (and other QC8x26 based devices) and really bad FPS. The recommendation at the time was to use legacy shaders, which worked. However since upgrading to 5.2 / 5.3 beta even legacy shaders are giving issues now, once again on my Lumia 635. My older Lumia 520 works fine at the same resolution.
     
  33. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Release build profiler:
    releaseprofile.jpg

    Seems normal to me? I'm guessing the irregularity of the performance is because of the attached profiler.

    We were trying to natively profile the master build, but we didn't manage to. We tried different VS versions (2013 and 2015) and different methods, but we kept getting "Unable to upload diagnostics tools to phone device.". So I'm unsure how we're supposed to profile the device.

    Maybe it needs Windows 10 installed on the PC as well?

    In any case, I'm not sure that profiling will help, since from looking at it, it's so stable at 30fps, that it feels like for some reason it's being capped at 30fps (and only when doing master build). I can't understand why though.
     
  34. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The profiler kinda explains the problem: it has "WaitForTargetFPS" for some reason. This happens if Application.targetFrameRate is set to something. Could you double check that it's set to -1?
     
  35. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    We put application target frame rate to 60 after we saw the master build running at 30, just in case something was defaulting to 30 in the master build (like how iOS behaves).

    So I am sure that's not it.

    I can remove it and try again if you're not convinced, but it'll have to wait till morning.
     
  36. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I'd be interesting to see the profiler without it. It is definitely throwing it off.
     
  37. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    @Tautvydas Zilys

    Here's a release build profiler without application target frame rate
    image.jpeg

    Looks normal to me.

    Installed Windows 10 on desktop. Still can't use native vs tools to profile a master 8.1 phone build on the 925 running Windows 10 phone.

    Master build is still capped at 30fps.
     
  38. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Ok. I suppose release build is running at 60 fps?

    I wouldn't suggest using Visual Studio profiler. It never worked reliably for me in the past.

    For profiling Windows Phone, I usually use Field Medic app. Here's a guide on how to use it:

    http://mmaitre314.github.io/2014/12/01/field-medic-custom-logging.html

    Use the MultimediaPerf.wprp profile to record performance trace. You can either look at it yourself, or zip it up together with all PDBs from your builds (UnityPlayer.pdb is the most important one) and PM it to me.
     
  39. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    @Tautvydas Zilys

    Turns out it's the same issue at the OP of this thread. We've just been testing only on Landscape, so we didn't see it.

    For master builds (and master builds only) it seems in protrait orientation it runs 60fps, while in landscape it runs at 30fps.

    Here is a screenshot from field medic.

    What we did is : Ran field medic on a Lumia 925 running windows 10 phone, opened the test app (it's Template.exe), held the device portrait for roughly 5 seconds (it ran at 60fps), then turned it landscape for another 5 seconds (it ran at 30fps).

    profilermedic.jpg

    I can send you the pdbs if you want.

    EDIT: (release builds seem to be not affected by this, that's why it looks like it performs "better" on release builds)
     
    Last edited: Nov 26, 2015
  40. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you send me the ETL and PDB files?
     
  41. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Sent you a PM
     
  42. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    It looks like once you turn the phone to landscape mode, IDXGISwapChain:: Present calls start taking 26-28 ms. Here's a screenshot of one frame analysis from the trace you sent me:

    http://i.imgur.com/GMMeAZH.png

    it usually means it's waiting for the GPU to finish drawing. It would indicate either that the system GPU is loaded and it's context switching a lot (pretty unlikely for a phone, and I did not see any hints that this is this the case in the trace), or some draw calls are very expensive.

    It would be nice to look at GPUView capture, but I've no idea how to capture one for a phone. I'll look into it. In the meantime, the next thing I'd suggest would be to use VS2015 to capture what GPU is doing. It's not as thorough as GPUView, but should still provide plenty of information. You can do that by pressing Debug -> Graphics -> Start Diagnostics, then wait for the game to load, rotate phone to landspace and press Capture Frame. Once frame is captured, stop debugging, press on the frame to view more info. In the main window, there will be Frame Analysis tab, in which there's one button: "Run Analysis for frame n.". Press that. It will take a few minutes, and produce a nice report telling you exactly how much time the GPU spent processing each draw call during that frame.
     
    Last edited: Nov 26, 2015
  43. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    I don't believe that works. With the 925 Windows 10 device we keep getting errors like:

    "Diagnostics session failed to start
    Unable to start VsStandardCollector.exe process. Unknown error 0xc0000135.
    Graphics Frame Capture has exited."

    So we also updated to the new VS 2015 Update 1 RC, but that doesn't seem to work either. We spent most of yesterday and a good chunk of today trying different OS' different, VS versions, different computers and googling the error messages.

    I know we aren't missing something obvious, because we can start the diagnostics on the 920 8.1 device just fine.

    I think we've literally ran out of things to try.
     
  44. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    One (maybe) interesting result:

    Not enabling "Development Build" in Unity, makes Debug build in VS also get limited at 30 in Landscape.
     
  45. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I'm looking for a way to profile GPU using FieldMedic. Hold on for that, might take a few days on our side.

    Other than that, did you by any chance check if it reproduces on Windows 10 desktop? That would be much, much easier to diagnose.
     
  46. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    @Tautvydas Zilys

    We gave up on that issue, since the performance was terrible, but at least it works. It turns out we had a more pressing issue on this platform:
    crashed.png
    As you can see, crashes and hangs rose significantly after the update. We also got a bunch of negative reviews saying they can't even open the game any more (phones running 8.1, some high end (eg 920T), some mid (eg 640), some low end (eg 521)), while they were previously able to.

    One user told us "This update deleted my data and also the game does not work anymore".

    Sadly it seems we can't roll back to Phone 8.0 (now that we uploaded a 8.1 build, the windows dashboard won't accept a 8.0 build).

    Is there something we should have watched out for? Is the 8.1 build that much worse for some reason?

    It's obvious now we shouldn't have upgraded, but is there *anything* we can do now? Support for 4.x is ending, upgrading our game to 5.x is not an option right now (and won't be, at least until 5.4, depending on several lightmapping issues and even then I need at least a solid month of work to redo all the lighting) and the current state of the Windows Phone build seems to be bad.
     
    Last edited: Dec 12, 2015
  47. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Small update: I tried to reach out to most of the users that were having problems, I heard back from 1 so far but he told me the game is working fine now (we didn't change anything yet, so uhhhh).

    So the possibility of the Windows Store messing up and making the issue look worse than it is is kinda high. So while I think there is an issue (that graph has some meaning, although we can't recreate the crashes/hangs), I also think a good chunk of the people reporting that it doesn't work people meant that the store couldn't download/update the game (which we kinda can recreate, because it seems the store isn't working very well these days).

    Anyway, if I get more concrete info, I'll update here.
     
  48. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Weird. Any chance you can see what it crashes on? You should be able to download dump files from the Windows dev center.

    Either way, I spent last 2 weeks purely on looking into performance issues on various phones, using the projects people supplied in this thread. I'm not done yet - there are still several things I need to work out, but I pretty much found the root cause of bad framerate if it happens on only some phone models. It looks like drivers on some phones don't like the way we limit queued frames, and are thus stalling. There is a workaround: set max queued frames to 2 at startup using this API:

    http://docs.unity3d.com/ScriptReference/QualitySettings-maxQueuedFrames.html
     
    AcidArrow and MrEsquire like this.
  49. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    This is excellent news and very good work and effort on your side.
    Shows lot dedication to help the customers and community members.
    Good luck with the rest of the debugging.

    I hope once done fix be provided in one of the 5.3 patch releases :)
     
  50. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    @Tautvydas Zilys

    Now that I have calmed down (the last few days have been a bit extra stressful for me especially with Windows Phone, all kinds of bizarre problems kept happening, for example on Sunday Trial mode stopped working for.... no particular reason).

    In any case, I think we have recreated the crash/issue and it's not Unity's fault. I'll post more once I'm sure we fixed it.

    We'll also try that maxqueued frames workaround tomorrow morning and I'll let you know if it fixes my slowdown issue as well.

    I also want to thank you for your help and I appreciate the lengths you went to solve the issues in this thread!