Since v84d Android AdmobInterstitial Fails

Monkey Forums/Monkey Bug Reports/Since v84d Android AdmobInterstitial Fails

therevills(Posted 2016) [#1]
Hi Mark,

Since this change in v84d, the AdmobInterstitial module fails:

Tweaked android_new target so OnUpdate always happens on render thread.


What did this fix?

Going back to v84b version of androidgame.java fixes the AdmobInterstitial module (I havent got v84c).

SilientShark reported this a few months ago, here is his debug log:

http://www.monkey-x.com/Community/posts.php?topic=8002

Could you please have a look at a solution for this as I would like to use the latest Monkey/Mojo code.

Cheers,
Steve


marksibly(Posted 2016) [#2]
OnUpdate got moved to the render thread because mojo2 allows you to draw 'offscreen' at any time.

As far as I know, there is no reliable way to share GL contexts between threads on android, so there is no easy solution to this. Either the module will have to be updated so that isLoaded etc are called on the main thread (if it's got an onLoaded method, this could just set a global var...) or mojo2 loses the ability to render off screen outside of OnRender.


therevills(Posted 2016) [#3]
Hi Mark,

Been away for a couple of days. Here is the module code, its pretty small:

Java:


Monkey:


if it's got an onLoaded method, this could just set a global var...

How would we do this? With the above code? It would be great to be able to use the module with Mojo2.

Cheers,
Steve


marksibly(Posted 2016) [#4]
This may or may not work!




therevills(Posted 2016) [#5]
Thanks Mark, nearly works... after the Ad is displayed the game input freezes and produces this log:



And then dies after a few seconds...


Paul - Taiphoz(Posted 2016) [#6]
Daft question but why is a change for mojo2 affecting monkey1 are you planning on having mojo2 work on monkey1 and 2 ? or am I not reading this thread correctly.


tiresius(Posted 2016) [#7]
Mojo2 is part of Monkey1.
Monkey2 will have something similar to Mojo2.
Hopefully it's not called Mojo3.


therevills(Posted 2016) [#8]
I tried a different approach yesterday:



Which displays the ad using the latest Monkey/Mojo... but I still get the ANR when returning to the game afterwards :(

E/ActivityManager(  462): ANR in com.therevillsgames.csusatripeaks (com.therevillsgames.csusatripeaks/.MonkeyGame)

E/ActivityManager(  462): Reason: Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 3.  Wait queue head age: 7834.1ms.)



therevills(Posted 2016) [#9]
I did a adb pull to get the full log and the place where the ANR happens is in MouseEvent (line 674):

ALVIK THREADS (45):
"main" prio=5 tid=1 Blocked
  | group="main" sCount=1 dsCount=0 obj=0x73665eb8 self=0x400ce600
  | sysTid=5338 nice=-6 cgrp=default sched=0/0 handle=0x400a4bec
  | state=S schedstat=( 2986155000 801129000 11511 ) utm=205 stm=93 core=3 HZ=100
  | stack=0xbe68f000-0xbe691000 stackSize=8MB
  | held mutexes=
  at com.therevillsgames.csusatripeaks.BBGame.MotionEvent(MonkeyGame.java:674)
  - waiting to lock <0x30ab1fe1> (a com.therevillsgames.csusatripeaks.c_GameDelegate) held by thread 13
  at com.therevillsgames.csusatripeaks.BBAndroidGame.onSensorChanged(MonkeyGame.java:1402)
  at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:405)
  at android.os.MessageQueue.nativePollOnce(Native method)
  at android.os.MessageQueue.next(MessageQueue.java:143)
  at android.os.Looper.loop(Looper.java:122)
  at android.app.ActivityThread.main(ActivityThread.java:5254)
  at java.lang.reflect.Method.invoke!(Native method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)


Here is the full ADB log:

http://pastebin.com/uMiqLBLz

Line 647 is the "Try" block:
	void MouseEvent( int event,int data,float x,float y ){

		if( !_started ) return;
		
		try{
			synchronized( _delegate ){
				_delegate.MouseEvent( event,data,x,y );
			}
		}catch( RuntimeException ex ){
			Die( ex );
		}
	}



therevills(Posted 2016) [#10]
G'ah! Just been testing for the past couple of hours trying different things... and the ANR happens on "proper" ads only! When using a test device and/or the test ad unit ID it works fine!


marksibly(Posted 2016) [#11]
Is the app getting suspended/resumed properly? Try sticking some Prints in OnSuspend/OnResume.


therevills(Posted 2016) [#12]
Is the app getting suspended/resumed properly? Try sticking some Prints in OnSuspend/OnResume.

Yes, the game reappears after the ad and after a few seconds I touch the screen the ANR happens (sometimes after a few touches). Added tracing "OnResume" and "OnSuspend" logs:



Edit: Uploading a video of the issue to youtube....


therevills(Posted 2016) [#13]
Video of the crash (cheat mode activated):



(Sorry for the quality...)


Soap(Posted 2016) [#14]
Ever figure this out?


therevills(Posted 2016) [#15]
Not really... to get around it I used an old version (v84b) of androidgame.java... which is okay if you dont use Mojo2.


Xaron(Posted 2016) [#16]
But with that old version you won't get any ads anymore due to the request of the newest admob SDK by mid of september?


Soap(Posted 2016) [#17]
I'll try to find a solution over this next week.


therevills(Posted 2016) [#18]
But with that old version you won't get any ads anymore due to the request of the newest admob SDK by mid of september?


I dont think so, the only difference between the latest 87b (fixed admob) and 85a (old admob) version of androidgame.java is fixes for some keyboards:
public InputConnection onCreateInputConnection( EditorInfo outAttrs ){

private class BackspaceInputConnection extends BaseInputConnection {


Nothing to do with with AdMob... oh and the deadline has been changed to October now (17th).

I'm really busy in a BlitzMax project at the moment which hopefully (it better be!) will be finished this month, then I need to go thru all my Monkey Android games and update them to the latest version of Monkey for the Admob fixes...


Xaron(Posted 2016) [#19]
Yeah maybe Mark could take a second look? :) I know it's probably not that exciting than on working on monkey 2:)


Soap(Posted 2016) [#20]
I just tested 87b with admob and it does work fine just FYI.

"There are actually 2 versions of admob in monkey - the old android target uses the standalone SDK, while the new android target uses 'google play services'."

http://www.monkey-x.com/Community/posts.php?topic=12351&post=123109

I am doing a new test for interstitial ads today.