Random crashes of my app on WP8 phone

Another thing -  I’m wondering if adding the GoogleAds.dll by reference is causing memory issues?

I did add Google AdMob’s library reference to your project too and got interstitial ads working.

Just try adding the print() statement I mentioned up above to verify that you are actually building with that version of the Corona library, because your builds might not actually be getting deployed to your device.  That would explain the strange errors that you are getting.  I’m thinking that you are either running into an incremental build issue or an app deployment issue with Visual Studio.  It’s rare, but it’s happen to me in the past as well.  The only way to work-around that issue is to delete the app from your device yourself and clean/rebuild your app.

Yes, I already mentioned 2 posts above:

“According to the debug info that you suggested, I am using build 2015.2589”         <-- I used the print statement you suggested in my main.lua.

I don’t remember if I deleted the app, but I’ll delete it and rebuild from scratch again.

EDIT: Bah, never mind.  I got the exact same memory issue / black background glitch again, by reproducing the steps above after playing 2 games.

I also notice someone else had a similar issue with the black glitches with the same phone (Nokia 635):

http://forums.coronalabs.com/topic/52167-notes-on-porting-to-wp8/#entry271013

Apparently he fixed it by not calling storyboard:removeAll(); but I am using Composer.

 

I am probably going to give up on this and forget WP8.

The black glitches you see in that forum thread was fixed months ago, in build #2484, as can be seen in the link below.  And I know both of these gentlemen were using AdMob as well.

   http://forums.coronalabs.com/topic/52032-unscramble-anagram-corona-app-on-the-windows-phone-store/?p=271957

The only other thing I can think of is that somehow you’re having debugger issues.  Instead of running your app via the Visual Studio debugger, try running your app manually on your device.

Hi Joshua, 

So I tried it again with the phone disconnected from the computer.  I managed to play a couple games, went back to main menu, went to settings, back to main menu etc.   No issues.

However, afterwards when I started a new game, and then went back to the main menu (without rolling dice), I got the following happen to my main menu:

G70dQKQl.jpg

It looks like the title banner graphic and the letter graphics on the buttons got replaced by the background image(!) which got squished into that small space. I had seen this before, a couple of times on other days.

I think the only good news since yesterday is that I am no longer seeing random shutdowns (error 0x800402e) on the phone.  And this is probably because i had done a factory reset of the Nokia earlier that day, so that may have somehow taken care of that.   But who knows, maybe I’m just lucky this time.  However it doesn’t solve these strange graphic issues.

I notice i’m using Text Candy in a few places.  I’m going to replace it with bmGlyph and FontManager and see how it goes.

Update:
So I got rid of all occurrences of Text Candy (in three scenes, one overlay) and replaced them with FontManager calls. However I have a similar issue still, after I play a couple games and then alternate between starting a new game and going back to main menu.

4DganGxl.jpg

Background becomes black and title banner is missing. Aaaghhhhhh.

Hi Joshua,

Was revisiting that thread you quoted above, and I noticed those users exhibited the same problems I am seeing on my own app. I’ll quote:

@doubleslashdesign Oh wow you are totally right. I’ve never seen that happen before… If you do that on the main menu screen the background goes black and the title graphic disappears (this is an actual image not the bitmap font).”

– The above is exactly what I am seeing, as you can see from the image I posted earlier. My title graphic is also an image, not bitmap fonts.

“As you navigate through the menus to the game, the background actually becomes the bitmap font spritesheet!”

– This has actually happened to me as well, about two or three times, as the sprite sheet which contains all the font characters suddenly became part of the background.

I was wondering if you or anyone else at Corona can look back at that issue and see if there’s anything else in their fix that was missed when patching it up. I know you said that no one else has seen my issue (since the October fix), but that shouldn’t imply this is not a real issue and I am left struggling with a defective app. I am sure this will pop up with more users as more people adopt CoronaCards for WP8.

Thanks!

That black text problem was only an issue back when it was in beta.  If you look at the bottom of that forum thread, notice that those 2 developers (@spacewolf and @hgbrian) confirmed that the issue was fixed.  I re-tested it again last week and confirmed that it still works.  No other Corona developer is having this issue since then.  And I can’t reproduce it with the project you sent me.  I gave it a solid shot and even when out of my way to acquire the exact same Nokia device model that you were testing with, but I still can’t reproduce the issue you are seeing.  I even super hammered it by pressing the Home and Back button to put your app into suspend/resume mod several times, but all of the images still re-loaded fine.  I also pressed the power button several time as well, testing suspend/resume via the WP8 lock screen, but it still worked fine.  And I also display a Google interstitial ad several time as well from your app’s homescreen, testing suspend/resume between AdMob and your app… and all images still re-loaded fine.

So, at this point, I don’t know how I can help you further.  It’s *not* looking like a bug on our end.  And no one else is running into this issue.  (The forum threads you are reference are back in the beta days and are no longer an issue.)

Perhaps the issue is more with your development environment then?  Since I can build and run your app without any issues on my Win8 Pro machine, that’s the only other thing I can think of.

You might also want to try to installing some other Corona developers WP8 apps on your phone to see how well they work on your device.  For example, @spacewolf’s app did have this issue in the beginning, but we fixed it back in October 2014.  The name of his app is “Unscramble Anagram”.

   http://www.windowsphone.com/en-us/store/app/unscramble-anagram/e53489ab-c108-4480-b2b1-42d5c774db22

HI Joshua,

Oh I totally appreciate how much you helped, and thankful that you did try to attempt to reproduce the issue, especially considering your schedule.  I’m just thinking, from a code point of view, if there was something else that may have been missed that could affect a small percentage of users like myself.  I mean it’s not just my device but the emulator as well that is affected.

My dev environment involves my licensed version of VMWare 7 running Windows 8.1 Pro 64-bit on a MacBook Pro (OS X Yosemite as the host system).  I had to enable Hypervisor optimization from VMWare to get the emulator to work, but I think that made the Windows OS run a bit laggy as well.  I’m wondering if my setup affects the builds as well.

In the meantime, I made a workaround which seems to be working so far.  What I did is, whenever the main menu scene is loaded, I wait half a second before the graphical content (background, title, menu buttons etc.) are displayed on the screen.  I tested this for about half an hour and it seemed to be fine.   So, if I enter the game and then press the Back button (or press the red home button) to return to the main menu, it will delay just a bit before showing the menu content.

I will definitely try and provide feedback if necessary for the other WP8 app when I have some time available.

Thanks again

Hmm… I can think of one other possible issue.

When you download our WP8 CoronaCards daily build zip file, Windows may not fully unzip all of its content unless you tell Windows to “Unblock” it.  You would do this by:

  1. Right click on the zip file.

  2. Select “Properties” from the popup menu.

  3. Select the “General” tab in the Properties window.

  4. Click on the “Unblock” button in the bottom right corner.

  5. Click on the “OK” button.

Afterwards, you can unzip the file just fine.  This is something that Windows does with all downloaded zip files from the Internet, which is Microsoft’s effort into trying to protect PC users from viruses and the like.

Now, I don’t recall this being an issue with our *.vsix Visual Studio extension, but I do remember Windows refusing to display our *.chm help file’s contents unless you “unblock” the zip file first.

I have just tried your advice.  I unblocked the latest daily build (2599) before unzipping it.  Then I went into Visual Studio Express 2013, uninstalled the two Corona-based extensions and then double-clicked on the new public build VSIX file to install it.   Then I opened my new app project and and assigned the new Corona build 2599 to its extensions.

Then I built the app, but this time I removed the 0.5-second delay before the main menu is shown.   However, after playing two games and returning to the main menu, the black background glitch came back.  So I had to put my delay back.

The menu glitch no longer happened after the delay was added.  However, in two different instances (after playing two games, returning back to main menu, going to the New Game menu, then back to the main menu, then back to the New Game menu), the app would raise an ‘out of memory’ exception in Visual Studio before the full-screen ad was shown.  It would then shut down the app.   If I disconnect the phone from the computer, and then run the app again with the same procedure, it would simply shut down the app.

Just tried Unscramble Anagram.  Couldn’t get the glitch to appear on that game, although I only tried it for 10 minutes.  (Nice game!)

Just an update - my game was released a week ago, and since then it has had 47 downloads. There have been, however, 3 crash reports, so it does seem that the problems are still present, unless it’s a totally different type of crash I am not aware of.

Anyways if anyone wants to try/test it, here it is linked below. This is one of my early apps so it’s a “guinea pig” project to test WP8. It’s not refined like my later work where I have an actual artist :wink:

http://www.windowsphone.com/en-us/store/app/snakes-and-ladders-ultimate/e6cfe5ed-8b95-4606-82e8-ff21c575260e

It sounds like you are running into OutOfMemory exceptions.

A 512 MB WP8 device is the lowest memory device you can get (worst case scenario) and is definitely good to test with, because low-end WP8 devices are the most popular devices.  On these phones, your app does not get to use all 512 MB of memory.  Your app is typically limited to 180 MB of RAM.

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

You can verify that this is the issue by running your app via the WP8 emulator with a virtual device that supports more than 512 MB of RAM.  What you need to do is compile your app for x86 as shown here…

   http://docs.coronalabs.com/coronacards/wp8/build.html

And on the toolbar, notice that the [> Emulator] button is a drop-down box.  The emulator devices that do *not* have “512 MB” to the right of the device name support more than 512 MB of RAM.

The idea is to confirm that you are actually running into an out-of-memory issue (it sounds like you are) or at least to confirm if there is a 2nd issue happening as well so that you can debug 1 issue at a time.

Now, if you are running out of memory, then there is really only 2 solutions to this problem…

  • Solution #1

The best solution of course is to reduce the amount of memory you app eats up at runtime.  This may mean loading smaller images.  Or loading less images and audio at a time.  If you are loading huge audio files, then perhaps you should consider streaming them instead.

  • Solution #2

The other way to handle it is to not support low-memory devices.  This involves adding a ID_REQ_MEMORY_300 entry to your app’s manifest file as described in Microsoft’s documentation in the link I posted up above.  Note that I don’t recommend this because low-memory/low-end WP8 devices are very popular.  Like over half of the WP8 market.

Thanks for the tips.  Yeah I do not want to limit my audience by preventing 512MB devices.   I’ll try running the emulator in 512MB device mode to ensure I can reproduce the problem there before I move onto a > 512MB emulator.

I don’t think my app is eating up a lot of memory.  I’m looking at the numbers on the right side of the emulator, and it looks like I’m usually at around 4500 (kB?) of texture memory being used up, both on the phone and the emulator. (EDIT: Okay that may be a lot!)

BTW, I just ran it on the emulator, and after about 4-5 minutes of play the game screen froze up and some of it changed to a black background.   Will now try on a higher-RAM device.   I think this message appeared at the same time, not sure:

“The thread 0xce8 has exited with code 0 (0x0).”

I’m pretty sure your app is using more than 4,500 KB of memory.

For example, your image files (*.PNGs, *.JPEGs, etc.) have to be decoded to 32-bit uncompressed bitmaps when submitted to the GPU as textures.  So, it doesn’t matter how smaller your PNG or JPEG files are.  They’ll all get decompressed into memory at runtime.  This is how it works on all platforms too (Android, iOS, Mac, Windows).  So, a 512x512 image is made up of 262,144 pixels, multiplied by 4 byte (for 32-bit color) per pixel, for a grand total of 1,048,576 bytes used in memory… or just over 1 MB.

You might also want to check Visual Studio’s “Output” panel for any Lua runtime errors that might be occurring.  Although, I suspect you might already being doing so.

Also, the following message…

>>  “The thread 0xce8 has exited with code 0 (0x0).”

…is nothing to worry about.  It’s not an error or warning.  This is Visual Studio just telling you that a thread has finished executing.  You’ll see the same thing happening in Microsoft’s own sample projects too.

Yes, I’m using the output panel (CTRL + ALT + letter O).

I cut a bunch of stuff out of my game last night, so it’s totally gimped, but I’m still running into these random shutdowns. You may be right that my game has too many things going on… I mean I have the background image, the game board image, the numbers on the board (a hundred of them), a transparency on top that shows the bad guys on the board, and then the player pieces and dice.   I even tried removing the 100 numbers and I still had issues.  I never had this problem on a 512MB Android phone.

Next, I ran some debug Corona code to show me the System Memory (collectgarbage(“count”)) and Texture Memory (system.getInfo(“textureMemoryUsed”) at every 1-second interval.   NOTE: I also realize I have an interstitial ad that is displayed at the start, and is preloaded again after the ad is shown (otherwise it won’t show the interstitial again).

When I start the app, it goes to the main menu (ad is preloaded):

System Memory used: 988 kB

Texture Memory used: 8 kB

Start the game (interstitial now shown):

System Memory used: 1650 kB   <— Big increase – board is being shown underneath

Texture Memory used: 9 kB

Close the ad:

System Memory used: 1650 kB   <------ Still remains…

Texture Memory used: 8.7 kB

Start playing (pieces moving, dice rolling):

System Memory used: 1800kB   —> Remains around this amount while playing, even when you go back to game menu and restart

Texture Memory used: 10.8 kB

After about 5 minutes of play, the game shuts down with code -2147220978 (0x8004020e) again:

System and Texture memory used: Same as the amount above.

So, this is all the info I have so far.  The game uses up 1.8MB of RAM.   Is this acceptable?

Just another note - I do have a couple of display.newText objects on the screen that get updated,  just the player’s name and their position (the square’s number) on the board.   There are a few more but they are static.   I don’t know if this would have an effect?