Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Notes on porting to WP8
Started by hgbrian Oct 25 2014 10:01 AM

10 replies to this topic
wp8
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

hgbrian

[GLOBAL: userInfoPane.html]
hgbrian
  • Contributor

  • 103 posts
  • Corona SDK

I am part of the way to having my game ported to WP8. I am using Parallels on my macbook pro to run Windows 8 and I bought a Lumia 635 ($99 on amazon) to test.

 

Here are some things I had to do to get it to work:

- In Parallels, set num CPUs to 2, memory to 4GB, and enable Nested Virtualization

- Install "Visual Studio Express 2013 for Windows" -- there are lots of different types of Visual Studio

- In calls to io.open, I had to remove system.pathForFile() for some reason (so I am just using io.open(filename))

- I am using device.lua to tell Android from iOS. Corona calls WP8 "Not Supported Yet", which device.lua thinks is Android.

- Because my game is landscape, in MainPage.xaml, I had to change "supportedOrientations" to "Landscape", and set "Orientation" to "LandscapeRight".

- My custom fonts had to have their "Build Action" set to "Content", and I also had to change the font name to include the font family name (there are threads on this)

- I had one sprite with a non-integer width (27.5) and that caused crashes so I had to fix that.

 

Currently I am struggling with a very unresponsive game ("User Interface Thread FPS" ( usually about 3 and Render Thread FPS is about 30), and crashes probably due to memory leaks (when the total memory used by the phone goes above 300MB it crashes). I don't have any real memory leaks in Android/iOS (just ebbs and flows  AFAIK) so I don't know how to fix this yet...

 

It would be nice to share tips on how to get WP8 performance up. OmNomster performs pretty well on my Lumia 635. For now I am just replacing sprites with static images, which is sad....



[TOPIC: post.html]
#2

rbm1155

[GLOBAL: userInfoPane.html]
rbm1155
  • Contributor

  • 108 posts
  • Corona SDK

Wp8 has performance issues displaying text. If possible use a bitmap font library.

[TOPIC: post.html]
#3

hgbrian

[GLOBAL: userInfoPane.html]
hgbrian
  • Contributor

  • 103 posts
  • Corona SDK

Hi rbm1155,

thanks for the advice. I can see very slow text rendering too but removing it doesn't seem to help with the core issue.

 

It looks like the app leaks 1MB or so every second until hitting the limit. Perhaps it's not garbage collecting often enough, because neither system.getInfo("textureMemoryUsed") nor collectgarbage("count") increase and I I'm pretty sure I don't see memory leaks on iOS or Android.

 

I am also seeing weird glitches on my sprites, both on the emulator and device. For example, the transparent part of a sprite sometimes replaced with part of the background and sometimes just black. Has anyone else seen that?



[TOPIC: post.html]
#4

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

Brian,

 

Our sprite APIs definitely work on WP8.  Just to be sure, I re-tested all of our sprite sample projects that are included with the Corona Simulator.  I pressed the Home button and backed back into the app several times as well.  The sprites always reloaded fine, without any graphics glitches.  Note that I also tested on a real WP8 device too.

 

I also tested out the old "bmf.lua" and new "bmf2.lua" bitmap font libraries.  Both rendered correctly.  I suspended/resumed their respective sample projects several times as well.  No graphics glitches.  No memory/texture leaks appeared.

 

Please note that I've conducted the above tests on a real device.  Have you done the same?

I ask because sometimes the WP8 emulator will display graphics glitches on some PCs.  If you run into this, then it's simply a bug with the WP8 emulator with your graphics hardware.

 

Are you seeing any errors/warning in Visual Studio's "Output" panel?

Perhaps this log will provide clues as to what is going wrong.

 

Also, are you sure your app is not using any Lua APIs/features that are unsupported on WP8?

You can find a list of all Lua APIs/features supported on WP8 here...

   http://docs.coronalabs.com/daily/coronacards/wp8/support.html

 

Additional Note:  When you run  your app via Visual Studio's .NET debugger, it'll show debugging information on the side of your app.  The 3rd from the left field indicates the app's current memory/texture utilization.



[TOPIC: post.html]
#5

hgbrian

[GLOBAL: userInfoPane.html]
hgbrian
  • Contributor

  • 103 posts
  • Corona SDK

Hi Joshua,

thanks for the detailed response. It's very helpful. The memory leak issue turned out to be a stupid error on my part.

 

However, I have seen glitches on sprites "live" on my Lumia 635. It is possible that it is somehow related to just running out of memory, since I have not seen it happen upon first booting the game, but rather after playing a few rounds. It may be the same issue reported in this thread? http://forums.coronalabs.com/topic/52032-unscramble-anagram-corona-app-on-the-windows-phone-store/

 

In general, my game still runs out of memory and crashes on the device, but I would guess it would not if the device had more than 512MB of RAM. The game has quite large graphics and it looks like it crashes after total memory usage goes above ~300MB (it starts at ~150MB before starting the game). I have tried more aggressive garbage collection but I haven't gotten it to help yet.

 

For now, I think I will try to submit a simpler app with less going on just to see if I can get that through to the WP8 app store....



[TOPIC: post.html]
#6

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

Just to double check, are you getting an OutOfMemoryException in Visual Studio?

I remember Visual Studio making it very clear when an app has exceeded the max heap size allowed by the app.

 

If it is, then you have 3 options...

 

Option 1:  You of course already know.  Reduce the memory footprint of your app.  This is the ideal solution since the majority of the WP8 device out on the market are low memory devices.  (It's unfortunate, but true.)

 

Option 2:  You can try to request the WP8 device to provide your app more memory via the ID_FUNCCAP_EXTEND_MEM manifest entry documented by Microsoft via the link below.  Note that this raises the max memory limit to 180 MB (not a lot), but might be worth a shot if your app is on the edge.

   http://msdn.microsoft.com/en-us/library/windows/apps/jj681682(v=vs.105).aspx

 

Option 3: You can set up your app to only support 1080 MB of RAM or higher devices via the ID_REQ_MEMORY_300 manifest entry.  The link above talks about this as well.

 

Also, you can test your app in the WP8 emulator with higher memory virtual devices too.  You can do this to confirm that your app runs okay on higher memory devices.  Perhaps this might be a good way to identify if this is the cause of the graphics glitches too.  In Visual Studio, notice that the [>] toolbar button is a drop-down box.  If you choose an emulated device that does *not* have 512 MB next to it, then it'll be a higher memory device.  That is, the 512 MB postfixed emulators are meant for testing with low memory devices.



[TOPIC: post.html]
#7

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

Oh and I'll definitely help you and @spacewolf out in finding whatever is causing those graphics glitches you're both seeing.  Right now, I'm kind of scratching me head in what might be causing it.  But @spacewolf's menu screen looks like it might be simple reproducible case for us.  If there is an issue on our end, we'll definitely take care of it.



[TOPIC: post.html]
#8

guy.stockwell

[GLOBAL: userInfoPane.html]
guy.stockwell
  • Contributor

  • 100 posts
  • Corona SDK

looking for native text field and text box alternative so I can port a few business apps. Any suggestions? I have wider Candy, but nothing for multiline text box input that I can find...



[TOPIC: post.html]
#9

hgbrian

[GLOBAL: userInfoPane.html]
hgbrian
  • Contributor

  • 103 posts
  • Corona SDK

Hi Joshua,

thanks for the extremely useful advice. I'll try what you suggest and if I have success I'll post it to the forum.

 

I actually didn't see Visual Studio report an OutOfMemoryException but I am inexperienced with VS so I need to spend a bit more time with it to see what's up. I was mainly just looking at the graph of memory use. 

 

The one error I have seen in the list of Visual Studio exceptions is a System.Reflection.TargetInvocationException, but I have only seen that once so far.

 

I feel like my game should be under the memory use threshold if it was more aggressive in reclaiming memory. I specifically make the game do a storyboard.removeAll() after every round of every game(!), which works well for me on iOS and Android. I believe I am usually using no more than 100MB at a time on these platforms, with spikes during scene transitions.  

 

Best,

Brian



[TOPIC: post.html]
#10

janfma

[GLOBAL: userInfoPane.html]
janfma
  • Observer

  • 20 posts
  • Enterprise

looking for native text field and text box alternative so I can port a few business apps. Any suggestions? I have wider Candy, but nothing for multiline text box input that I can find...

So you got single line working? How? What id "wider Candy"?



[TOPIC: post.html]
#11

guy.stockwell

[GLOBAL: userInfoPane.html]
guy.stockwell
  • Contributor

  • 100 posts
  • Corona SDK


[topic_controls]
[/topic_controls]