Hi,
I have run into a really strange issue on the Samsung Galaxy S4 when using RenderTarget2D objects for offscreen drawing.
Normally everything runs fine, but since I enabled Google Ads in my game when I instantiate a RenderTarget2D for offscreen drawing it seems to contain already used graphics memory (sometimes graphics I have loaded with LoadContent, sometimes just black). Drawing on the RenderTarget2D will then do other weird stuff such as change graphics that have been loaded with LoadContent or it will not do anything at all and/or crash randomly.
This only happens on the S4 (HTC One X and emulators all fine) and only when Google Ads is running.
I don’t hold out much hope for anyone being able to help with this as it’s a pretty obscure issue but in the vague chance anyone has run into anything similar any input would be appreciated…
cheers
Are you clearing the RenderTarget?
I’m using a custom class for multi resolution drawing that uses RenderTargets and haven’t seen the error you mention. I have a Galaxy S4, also use Google Ads and MonoGame Android, so if you want me to test some code I will as soon as I get home
Hi There,
Thanks for the reply - I do clear them (I would kind of expect garbage to be in there to start with) but there is something other than that going on. It’s almost as if the memory allocated is getting confused with other things or freed when it shouldn’t be or something. It’s really odd!
Are you using banners and interstitials in your game?
Also do you instantiate your RenderTargets right at the start or ‘on the fly’ within the game?
I am doing slightly odd stuff with the Google banners. I want banners within the game, not on the main menus etc. The best way I found of doing this (and also of achieving other functionality I wanted) was to add and remove the AdView on the fly - I’ve a feeling this may have something to do with the problem I’m seeing as the RenderTargets that are causing me problems are instantiated directly after I remove the AdView. I don’t like removing and adding the AdView all the time (this type of thing rings alarm bells) but couldn’t see an obvious way to suppress drawing of a View without removing it from the containing Layout (e.g. the View.Hide() method in iOS). Maybe I just need to look harder!
Anyway - any input appreciated. I can’t work on this today as I don’t have access to the S4 but will be back onto it tomorrow…
cheers
Ah - just found View.SetVisibility() - will try that instead of adding and removing ; )
That seems to have fixed it - I thought adding/removing views was asking for trouble!
Just be careful because I think setting the Visibility to View.GONE will only hide the ad but it will still be clickable (well, tappable). Try combining it with SetEnabled.
Thanks for the tip - it didn’t seem to be clickable whilst hidden but I added SetEnabled(true/false) just to be sure!