All Text objects disappear when going into Suspend via adMob

Hello/. While using Admbob Interstitial ads, when it resumes after all text objects disappear. They come back if  they are updated with new .text string.

Sometimes i get this message

Cannot render text while Corona is synchronized with the rendering thread.

If I restart sometimes I dont get the message and text is fine. Its random

Okay I found a fix. Its an odd workaround which perhaps will help give a clue to the problem. It seems that in the process of resuming app,  the text objects cant be refreshed as its busy doing something else or not able to yet. 

The workaround is to create a timer event  in  an applicationResume event to refresh the text objects like this:

creditsDisplay.text="";

creditsDisplay.text=credits;

I do this on the resume as this is what the app does after adMob is closed. If I do this without a timer it doesnt work. It needs around 500 milliseconds (Im guessing while adMob is releasing or Corona is being brought back)

Also if I dont set the .text to “” before I set it correctly then that doesnt work either. 

I’ll see about looking into this issue next week.

I suspect that this issue will only happen when navigating forward to page within your own app.  Meaning that pressing the Home button, using system.openURL(), or using a .NET Task to navigate to an app won’t have this issue, because I remember testing that scenario pretty thoroughly.

Theoretically, setting up a 1 millisecond timer during the resume event should be all that you need to force-update your text objects.  You just need to force an update on the 2nd render pass and that should theoretically make it work.  (I’m guessing, but I feel pretty confident about it.)

Thanks Joshua. I did try setting to 10 milliseconds and it didnt work. 

Occasionally 500 isnt long enough either. I have put to 1000 just to make sure and it seems to work all the time now. Better safe than sorry.

Actually adding this less than 1000 slows the refresh down of the Corona display coming back and for a second it looks corrupt, sideways squashed into portrait mode part of Vram or something (not exactly just a sideways version) before reverting back to normal. I think the text refresh/setting that Im forcing being very slow (as the text is) makes it worse so I allow Corona to refresh back first and in the right orientation and the refresh the text. Its a bodge but seems to work

(EDIT:This isnt entirely working either) Ive now had to put it up to 2000 millisonds now I think it depends on the ad request on admob.)

Hmm… I can’t reproduce this issue.  I modified our Hello World app to include AdMob interstitial ad support and went back and forth between the interstitial ad and the Corona MainPage 20 times.  The “Hello World” text always showed up when I returning to the Corona MainPage.

I even tried modifying the text during the “applicationResume” event and the text change always showed up onscreen for me.

Can you think of anything else that’s happening in your app during a suspend/resume?

Because I’m thinking something else is causing this issue.

For example, perhaps you’re using the Lua/.NET bridge to do something during a suspend/resume.

I will run some tests. I have had to make a few bodge jobs to get it all working including timer events for text, native alerts etc, disk activity. This is landscape and my previous attempts worked fine in portrait and single boot up interstial but since launching from corona in landscape after bootup this has happened. I will attempt to figure out what else is happening on resume next week as it’s gone midnight now. Perhaps I have something dodgy lurking around somewhere .

Just FYI, I also ran into this issue when I was using display.newText() with that error: Cannot render text while Corona is synchronized with the rendering thread.I never figured out a fix for it because I switched to using bitmap fonts which don’t have this problem :slight_smile:

Rob, spacewolf,

A fix to this issue will be made available in daily build #2484 in the next couple of days here…

   http://developer.coronalabs.com/downloads/daily-builds

That’s great once again Joshua. Superb. So it’s a fix in corona and not in corona cards. Just as I’m almost finished creating my very own custom bitmap font generator haha

Well, to me, CoronaCards is just a library and XAML control that uses our core Corona code.  It’s just a different means of distributing Corona to native developers.  :slight_smile:

Our daily builds page provides new builds/versions of our WP8 CoronaCards SDK too, which allows us to deliver changes/fixes to everyone quickly and easily.  As long as there aren’t any blockers, a new daily build should hopefully be made available tomorrow.

One more thing to note.  Theoretically, this issue we fixed could have happened to image objects too.  Which sounds like what was happening to @spacewolf.  It’s just less likely to happen if you pre-load all images on startup.  So, you switching to a custom bitmap font is definitely not a wasted effort.

Okay I found a fix. Its an odd workaround which perhaps will help give a clue to the problem. It seems that in the process of resuming app,  the text objects cant be refreshed as its busy doing something else or not able to yet. 

The workaround is to create a timer event  in  an applicationResume event to refresh the text objects like this:

creditsDisplay.text="";

creditsDisplay.text=credits;

I do this on the resume as this is what the app does after adMob is closed. If I do this without a timer it doesnt work. It needs around 500 milliseconds (Im guessing while adMob is releasing or Corona is being brought back)

Also if I dont set the .text to “” before I set it correctly then that doesnt work either. 

I’ll see about looking into this issue next week.

I suspect that this issue will only happen when navigating forward to page within your own app.  Meaning that pressing the Home button, using system.openURL(), or using a .NET Task to navigate to an app won’t have this issue, because I remember testing that scenario pretty thoroughly.

Theoretically, setting up a 1 millisecond timer during the resume event should be all that you need to force-update your text objects.  You just need to force an update on the 2nd render pass and that should theoretically make it work.  (I’m guessing, but I feel pretty confident about it.)

Thanks Joshua. I did try setting to 10 milliseconds and it didnt work. 

Occasionally 500 isnt long enough either. I have put to 1000 just to make sure and it seems to work all the time now. Better safe than sorry.

Actually adding this less than 1000 slows the refresh down of the Corona display coming back and for a second it looks corrupt, sideways squashed into portrait mode part of Vram or something (not exactly just a sideways version) before reverting back to normal. I think the text refresh/setting that Im forcing being very slow (as the text is) makes it worse so I allow Corona to refresh back first and in the right orientation and the refresh the text. Its a bodge but seems to work

(EDIT:This isnt entirely working either) Ive now had to put it up to 2000 millisonds now I think it depends on the ad request on admob.)

Hmm… I can’t reproduce this issue.  I modified our Hello World app to include AdMob interstitial ad support and went back and forth between the interstitial ad and the Corona MainPage 20 times.  The “Hello World” text always showed up when I returning to the Corona MainPage.

I even tried modifying the text during the “applicationResume” event and the text change always showed up onscreen for me.

Can you think of anything else that’s happening in your app during a suspend/resume?

Because I’m thinking something else is causing this issue.

For example, perhaps you’re using the Lua/.NET bridge to do something during a suspend/resume.

I will run some tests. I have had to make a few bodge jobs to get it all working including timer events for text, native alerts etc, disk activity. This is landscape and my previous attempts worked fine in portrait and single boot up interstial but since launching from corona in landscape after bootup this has happened. I will attempt to figure out what else is happening on resume next week as it’s gone midnight now. Perhaps I have something dodgy lurking around somewhere .

Just FYI, I also ran into this issue when I was using display.newText() with that error: Cannot render text while Corona is synchronized with the rendering thread.I never figured out a fix for it because I switched to using bitmap fonts which don’t have this problem :slight_smile:

Rob, spacewolf,

A fix to this issue will be made available in daily build #2484 in the next couple of days here…

   http://developer.coronalabs.com/downloads/daily-builds

That’s great once again Joshua. Superb. So it’s a fix in corona and not in corona cards. Just as I’m almost finished creating my very own custom bitmap font generator haha

Well, to me, CoronaCards is just a library and XAML control that uses our core Corona code.  It’s just a different means of distributing Corona to native developers.  :slight_smile:

Our daily builds page provides new builds/versions of our WP8 CoronaCards SDK too, which allows us to deliver changes/fixes to everyone quickly and easily.  As long as there aren’t any blockers, a new daily build should hopefully be made available tomorrow.

One more thing to note.  Theoretically, this issue we fixed could have happened to image objects too.  Which sounds like what was happening to @spacewolf.  It’s just less likely to happen if you pre-load all images on startup.  So, you switching to a custom bitmap font is definitely not a wasted effort.