Windows Phone 8.1 game with CocosSharp 1.4 or 1.5 is very slow

I experience slowness in my game. Also, the same slowness can be seen in CocosSharp sample called Angry Ninjas https://github.com/mono/cocos-sharp-samples/tree/master/AngryNinjas/src
Run it on WP8.1 device and see how slow the game is.

My game runs smoothly on iOS and Android but is very slow on WP8.1

Please advise.

Posts

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Can you try something that is outlined in the following: http://stackoverflow.com/questions/30243067/monogame-running-very-slow-on-windows-phone

  • AlexSAlexS USUniversity ✭✭✭

    @kjpou1 do you mean running game without debugger? I experience slowness in release-built app published to store, so there is no debugger attached. I am not sure what should I try and would be happy to try anything that could help solve the problem.

  • AlexSAlexS USUniversity ✭✭✭

    @kjpou1 after fixing CCStats for WP81 device (http://forums.xamarin.com/discussion/45337/windows-phone-8-1-displaystats-is-not-working) I can see that FPS is very low (11-12).
    I compared to iOS and see that memory usage, GC count, number of draw calls and time to draw are same.
    However, time to update is much higher and FPS is much lower on WP81 than on iOS.

    Can you suggest some reasons that might cause such a strange behavior?
    I experience that slowness on easy scenes and with or without animations, even when scene is idle.

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Alex

    The windows phone performance problems have always been there from what I have seen. Let's see where things can be optimised. We will need to take them one by one though in stead of a general "it is slow".

    Do you have any specific output that could lead us in the right direction besides a general it is slow?

    One thing that comes to mind is the loading of the assets. That seems to be dog slow compared to other platforms. One thing for that from what I have seen is specifying the exact path to the asset instead of letting MonoGame look for it.

    Instead of loading a lot of sprites try packing them into one texture sheet so that the loading into memory goes faster.

  • AlexSAlexS USUniversity ✭✭✭

    Completely understand your question. I do not have a lot of assets (indeed it's just one). FPS are low even when nothing is done.
    After I fixed CCStats, I was able to identify the problem. Looks like after certain amount of elements in the game it becomes much slower.
    For example, I commented one layer, and FPS jumped to 56. When particle effect runs, they drop again to 12-20.
    I tried to understand which node in this specific layer makes game slow and found out that just uncommenting any node or just at all adding one more node makes fps drop to 20 fps.

    Also, regarding my previous comment, I understood CCStats incorrectly, it's draw cycle slow, not update.
    I would be more than happy to give you a source of the game under NDA but I think you are very busy even without this task.

    What I also did is I deployed on device CocosSharp WP8 tests and Cocos2d-xna WP8 tests. CocosSharp is slow, Cocos2d-xna is much much smoother and faster.

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Sorry to hear that. We definitely need to look at it. Do you see a difference between 1.4 and 1.5

  • AlexSAlexS USUniversity ✭✭✭
  • zahikramerzahikramer ILMember ✭✭✭

    @AlexS
    Did you succeeded to deploy Release version of your game?
    Debug deploy is going good (even with your fix to show CCStats.. thanks)

    But on Release version i get DEP6810 ERROR MdilXapCompile.exe error with resources.dll error.
    even when i succeded to fix this (via copying resouces dll's to release directory)
    and deployment is succeeded, my app CRASHED.

    anyone?

  • AlexSAlexS USUniversity ✭✭✭

    You are welcome!
    Regarding DEP6810 you should check what's the error. Maybe it is something related to your game PCL, not to CC#.
    http://stackoverflow.com/questions/26238570/is-it-possible-to-use-a-portable-library-with-localized-resources-in-a-universal

    My app is being deployed in release just fine.
    Also, make sure you clean and then build project from scratch, some things may be left from previous build

  • AlexSAlexS USUniversity ✭✭✭

    @kjpou1 I finally compared performance between 1.4 and 1.5.
    1.4 is much faster and gives me 60 fps when scene is idle and around 20-30 when I add many particles (in these moments other platforms are sometime sluggish also). So, that is the performance level I would expect and think about optimizing.

    Now I have a dillemma - apply my fixes to CCStats and Orientation to the new branch created from 1.4 or ask you more and more about fixing that problem (which is still unclear for me) in 1.5.

    Please advise.

  • AlexSAlexS USUniversity ✭✭✭

    I was able to profile the game only using VS 2013 (VS 2015 doesn't load method names for some reason)
    https://www.dropbox.com/s/gngju4jqsqsge3k/shot_150714_023019.png?dl=0
    Not sure if this information is valuable, but looks like VertexBuffer.SetDataInternal occupies a lot of time.

  • zahikramerzahikramer ILMember ✭✭✭

    Just FYI.
    I managed to use PCL resources on WinPhone 8.1 WinRT here:
    https://forums.xamarin.com/discussion/comment/138856/#Comment_138856

    It worked for me. for now at least.....

  • AlexSAlexS USUniversity ✭✭✭

    @kjpou1 and @RamiTabbara I know you're busy, guys, but maybe you can give me some ideas where to look at and solve that issue. This is now the only outstanding problem that stops Windows Phone release.

  • zahikramerzahikramer ILMember ✭✭✭
    edited July 2015

    @AlexS
    Try to check performance on WP8.1 Silverlight (and NOT winRT).
    I succeeded there things i didn't succeed on winrt. so maybe.....

  • AlexSAlexS USUniversity ✭✭✭

    @zahikramer, do you have any details how do I do that? I found only template and tutorial for WINRT.

  • zahikramerzahikramer ILMember ✭✭✭
    edited July 2015

    Sure @AlexS , you can see this from few locations
    1. from the examples go to gonebananas2 and see wp8 project. (all you need to do is change from project settings to wp8.1 - it is silverlight on wp8 so it stays silverlight on wp8.1
    2. see the pic from the templates: choose wp8.0 and afterwards change it to 8.1 and it will stay silverlight

  • AlexSAlexS USUniversity ✭✭✭

    @zahikramer thank you

  • zahikramerzahikramer ILMember ✭✭✭

    @AlexS
    It worked?

  • AlexSAlexS USUniversity ✭✭✭

    Not actually, getting a blank screen. Sometimes I see first screen and this error:

    HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: The application made a call that is invalid. Either the parameters of the call or the state of some object was incorrect.
    Enable the D3D debug layer in order to see details via debug messages.

  • zahikramerzahikramer ILMember ✭✭✭

    @AlexS
    Try from the bottom up. first compile the vanilla template and see it's working.
    then (with minimum changes to the pages structure) add the CC files and compile. see how it goes.
    also as you saw yourself , make clean before rebuild.

  • AlexSAlexS USUniversity ✭✭✭

    @zahikramer I was able to achieve that but only after I built a nuget from current CocosSharp master and used it as source for CocosSharp.PCL.Shared.
    In that case everything works fine in WP8.1 project, system fonts, stats and even all the logic is in PCL project.
    However, the game is still very slow.
    I sent my project to CocosSharp team with hope they will solve the mystery.
    I am sure that it's just something unoptimized in MonoGame or CocosSharp for WP. iOS and Android versions work very smooth.

  • zahikramerzahikramer ILMember ✭✭✭
    edited July 2015

    @AlexS
    Glad to hear that.
    It's WP8.1 SL yes?
    You said also SystemFonts? on WP8.1 SL ? on device? (not only emulator?)
    They updated CC?

  • AlexSAlexS USUniversity ✭✭✭

    Yes, I tried WP8.0 (Silverlight), WP8.1 (Silverlight) and WP8.1 (wpa/winrt). All of them show same performance and it is very low. 14-20, sometimes 38 fps.

    SystemFonts work on device with WP8.1 if the game is WP8.1 (wpa/winrt). Xamarin didn't update CocosSharp, but I built a nuget package from the latest master and used local nuget storage.

  • zahikramerzahikramer ILMember ✭✭✭

    Good to heat that.
    I decided to stick with silverlight for now because i saw the best support (if any) is there.
    glad to know things are moving....
    but the performance is still a problem.

  • AlexSAlexS USUniversity ✭✭✭

    @kjpou1 @RamiTabbara Folks, maybe you have any thoughts what it might be causing this slowness?
    Any ideas or ways to get more information are much appreciated!

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Alex

    No not yet to be honest

  • AlexSAlexS USUniversity ✭✭✭

    I see, I'm reading now this thread http://forums.xamarin.com/discussion/46525/how-to-properly-cache-sprites-labels-textures-and-reduce-draw-calls and this one http://forums.xamarin.com/discussion/46525/how-to-properly-cache-sprites-labels-textures-and-reduce-draw-calls with hope this information will give me any clue.

    If I only could pinpoint the source of the problem

  • JahnOttoAndersenJahnOttoAndersen NOMember
    edited August 2015

    Any luck @AlexS ?

  • AlexSAlexS USUniversity ✭✭✭

    Not yet, unfortunately

  • AlexSAlexS USUniversity ✭✭✭

    Update on this topic: with 1.6.2 version application is much much faster. There is only a problem with CCUserDefaults not working correctly on WP8.1, but that is already fixed and (hope) will be merged in and available in the next NuGet release.

    So with 1.6 everything is smooth and cool!

Sign In or Register to comment.