DefVideoAds (plugin for Unity ADS). Video ADS native extension

Ah, that might explain why it works in one game with one rewarded ad and not in a different game with two rewarded ads.

I’ll do some more digging.

Edit: It was a logic error in my code, multiple rewarded ads now work great. Sorry for waving red herrings around publicly. :blowfish:

2 Likes

DefVideoADS 3.4.6
UPDATE: UnityADS SDK updated to v3.4.6

4 Likes

DefVideoADS 3.4.8

Now DefVideoADS is compatible with iOS 14. This version of the extension requires Defold 1.2.174 or higher.

UPDATE: UnityADS SDK updated to v3.4.8

8 Likes

Nice to see this extension keep getting love! Unfortunately I’m unable to use 1.2.174 because of this bug.

Is there a way to use the iOS 14 compatible version of the extension with 1.2.172?

Edit: I upgraded to Defold 1.2.174 and tried using DefVideoAds v3.4.8. As soon as unityads.initialize() is called, there is a hard crash on iOS (13.5.1). Reverting back to v3.4.2 solved the problem.

Have there been any changes to the API between v3.4.2 and v3.4.8?

No, there is no difference in API.

I have tested the newest version on iPhone 5c with iOS 10.3.3 it works fine.
If you provide logs it help me to find the reason for the crash. Unfortunately, I don’t have a device with iOS 13.5.1.

Yes, use beta extender server (https://build-stage.defold.com) even if you use 1.2.172 (the extender has one critical fix for v3.4.8)

1 Like

I’m back! :smiley:

When building DefVideoAds v3.4.8 with the latest Defold v1.2.164 build using http://build-stage.defold.com/ I get this crash on Android:

2020-09-29 17:43:42.679 30529-30577/com.winkelgames.juump E/defold: ERROR:CRASH: CALL STACK:

# 0 pc       0x1dc8 /system/bin/app_process64 <unknown>+0




--------- beginning of crash
2020-09-29 17:43:42.679 30529-30577/com.winkelgames.juump A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7d00000000 in tid 30577 (Thread-81), pid 30529 (nkelgames.juump)
2020-09-29 17:43:42.844 1311-1404/? E/AppIdleHistory: Error writing app idle file for user 0
2020-09-29 17:43:42.899 30811-30811/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-09-29 17:43:42.899 30811-30811/? A/DEBUG: Build fingerprint: 'OnePlus/OnePlus6T/OnePlus6T:10/QKQ1.190716.003/2007171848:user/release-keys'
2020-09-29 17:43:42.899 30811-30811/? A/DEBUG: Revision: '0'
2020-09-29 17:43:42.899 30811-30811/? A/DEBUG: ABI: 'arm64'
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG: Timestamp: 2020-09-29 17:43:42+0100
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG: pid: 30529, tid: 30577, name: Thread-81  >>> com.winkelgames.juump <<<
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG: uid: 10722
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7d00000000
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x0  0000007d00000000  x1  0000007d00000000  x2  00000000001fb856  x3  00000000001fb7a6
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x4  0000000000000000  x5  0000000080000000  x6  2e6c6e61ff634873  x7  7f7f7f7f7f7f7f7f
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x8  0101010101010101  x9  0000000000000001  x10 0000000000000000  x11 0000007dcae471f7
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x12 0000000000000000  x13 0000007dcae46bcd  x14 0000007dcae47241  x15 fffffffffffffff7
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x16 0000007dcaf278d8  x17 0000007ebb3d5a60  x18 0000007dc7450000  x19 0000007e1cb96380
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x20 0000007e1cb96380  x21 0000007e1cba8fe0  x22 0000007dcaf89630  x23 0000007dcae71396
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x24 0000007dcae7224f  x25 0000000000000008  x26 0000000000000001  x27 0000007e286f3020
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     x28 0000007fdf34ccf0  x29 0000007dca93fd10
2020-09-29 17:43:42.900 30811-30811/? A/DEBUG:     sp  0000007dca93f950  lr  0000007dcacf8820  pc  0000007ebb3d5a70
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG: backtrace:
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #00 pc 000000000007fa70  /apex/com.android.runtime/lib64/bionic/libc.so (strlen+16) (BuildId: a6a4a6a4e20240bbe3173fe560b161af)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #01 pc 00000000001b481c  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (lua_pushstring+72)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #02 pc 000000000007b368  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (luaL_push_pair_str_str(lua_State*, char*, char*)+48)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #03 pc 000000000007b134  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (DefUnityCallback_invoke_callback(int, char*, char*, char*, int, DefUnityAdsListener*)+456)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #04 pc 000000000007aef8  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (DefUnityCallback_callback_updates()+188)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #05 pc 0000000000079504  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (UpdateUnityAds(dmExtension::Params*)+20)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #06 pc 0000000000196cf4  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (dmScript::InternalUpdateExtensions(dmScript::Context*)+244)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #07 pc 00000000001921c4  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (dmScript::Update(dmScript::Context*)+40)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #08 pc 00000000000acd04  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (dmEngine::Step(dmEngine::Engine*)+544)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #09 pc 00000000000adb1c  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (dmEngineUpdate(dmEngine::Engine*)+20)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #10 pc 00000000000aa154  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (dmEngine::RunLoop(dmEngine::RunLoopParams const*)+92)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #11 pc 00000000000aa058  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (EngineMainThread(void*)+124)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #12 pc 000000000021ac00  /data/app/com.winkelgames.juump-KdMOolGY--EI926wnRBYcw==/lib/arm64/libJUUMP.so (dmThread::ThreadStartProxy(void*)+32)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #13 pc 00000000000e6890  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: a6a4a6a4e20240bbe3173fe560b161af)
2020-09-29 17:43:42.903 30811-30811/? A/DEBUG:       #14 pc 0000000000084b6c  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: a6a4a6a4e20240bbe3173fe560b161af)
2020-09-29 17:43:43.405 1311-30814/? W/ActivityTaskManager:   Force finishing activity com.winkelgames.juump/com.dynamo.android.DefoldActivity
2020-09-29 17:43:43.410 1260-1260/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_00
2020-09-29 17:43:43.447 1311-1405/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-09-29 17:43:43.447 1311-1405/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-09-29 17:43:43.456 572-572/? E/SELinux: avc:  denied  { find } for interface=vendor.qti.hardware.servicetracker::IServicetracker sid=u:r:system_server:s0 pid=1311 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0
2020-09-29 17:43:43.458 1311-1405/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-09-29 17:43:43.458 1311-1405/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-09-29 17:43:43.529 572-572/? E/SELinux: avc:  denied  { find } for interface=vendor.qti.hardware.servicetracker::IServicetracker sid=u:r:system_server:s0 pid=1311 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0
2020-09-29 17:43:43.544 1311-1408/? W/libprocessgroup: Failed to open process cgroup uid 99879 pid 30730: Permission denied
2020-09-29 17:43:43.544 1311-1408/? E/libprocessgroup: Error encountered killing process cgroup uid 99879 pid 30730: Permission denied
2020-09-29 17:43:43.544 572-572/? E/SELinux: avc:  denied  { find } for interface=vendor.qti.hardware.servicetracker::IServicetracker sid=u:r:system_server:s0 pid=1311 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0
2020-09-29 17:43:43.545 1311-3860/? W/ActivityManager: Scheduling restart of crashed service com.winkelgames.juump/org.chromium.content.app.SandboxedProcessService1:0 in 1000ms
2020-09-29 17:43:43.653 1311-1846/? W/InputDispatcher: channel '71fc6f7 com.winkelgames.juump/com.dynamo.android.DefoldActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
2020-09-29 17:43:43.654 1311-1846/? E/InputDispatcher: channel '71fc6f7 com.winkelgames.juump/com.dynamo.android.DefoldActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2020-09-29 17:43:43.659 1311-3856/? W/InputDispatcher: Attempted to unregister already unregistered input channel '71fc6f7 com.winkelgames.juump/com.dynamo.android.DefoldActivity (server)'
2020-09-29 17:43:43.666 572-572/? E/SELinux: avc:  denied  { find } for interface=vendor.qti.hardware.servicetracker::IServicetracker sid=u:r:system_server:s0 pid=1311 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0
2020-09-29 17:43:43.674 572-572/? E/SELinux: avc:  denied  { find } for interface=vendor.qti.hardware.servicetracker::IServicetracker sid=u:r:system_server:s0 pid=1311 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0
2020-09-29 17:43:43.696 911-911/? E/BufferQueueConsumer: disconnect by : /system/bin/surfaceflinger my_pid = 911
2020-09-29 17:43:43.724 1311-1392/? W/ActivityManager: setHasOverlayUi called on unknown pid: 30529
2020-09-29 17:43:43.726 22072-22112/? W/WeatherProvider: the weather application is not installed, may not receive the updates
2020-09-29 17:43:43.727 22072-23049/? W/WeatherProvider: the weather application is not installed, stop querying...
2020-09-29 17:43:43.906 1311-1392/? W/ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{b9150f5 u0 com.winkelgames.juump/com.dynamo.android.DefoldActivity t-1 f}

The ad implementation in the game hasn’t changed. Any idea what might cause this? I’m not certain it’s to do with DefVideoAds, but the “DefUnityCallback” appears to suggest it is?

Could you check please if default example project works for you (download project from rep. of DefVideoADS and build).
(I’m re-checking using the latest 1.2.174)

UPD: Also, try this, pls:

  1. Remove “build” folder from your project folder
  2. Build and test game again

UPD2:
I watched 14 x 4 = 56 videos + opened 2 x 4 = 8 banners, it works for me.

Sooooo, that means I can’t reproduce this issue without exact steps, and minimal repo case. Also it would be nice to know more info about devices you tested on (OS, Model).

3 Likes

It might be that it doesn’t play nice with one of the (many, many) other extensions in the project? Will try a clean build this morning.

Update 1: A minimal Lua implementation (no game, only DefVideoAds) using a bundled .apk with all the extensions the game use also crashes.

Update 2: A minimal Lua implementation using a bundled .apk only with DefVideoAds extensions doesn’t crash.

Where should I start? :sweat_smile:

Could you provide your project with all the extensions you use, please? I’ll take a look today evening.

UPD:
The simplest way is to cut off all the extensions you use and check. Then if you don’t have crash, return just a half of cut extensions and so on.

1 Like

Thanks for your help @AGulev! I’m going in. I’ll ignore the pure Lua extensions for now, to make the task less daunting. Wish me luck! :slight_smile:

Update 1: I was lucky in my first batch. One (or more!) of these is the culprit: Facebook, GameAnalytics, Firebase or Google Play.

Update 2: It seems to have something to do with Firebase; keeping all extensions except Firebase causes no crash. However, an .apk with only Firebase and DefVideoAds also doesn’t crash. This stumped me a bit. Any suggestions?

When it does crash, it consistently happens as the DefVideoAds callback is fired, so a few seconds after the unityads.initialize() call.

Update 3: A new iOS+Android build of the full game, with the Firebase extension removed, works and doesn’t crash. How can we allow both DefVideoAds and Firebase to coexist?

1 Like

I’ll take a look today evening and try to figure out.

UPD: If you add firebase into DefVideoADS example project, can you reproduce this crash? Could you try to create minimal repo-case for me based on DefVideoADS example, please? @totebo

1 Like

Very unlikely, because an entirely empty project with only DefVideoAds and Firebase doesn’t crash. I guess this means there is (at least) another extension that causes an issue, but finding which one would be very time consuming.

Since I can consistently replicate the crash, is there a way I could produce a more detailed error that could help narrow it down? I could send a debug .apk if that helps?

I think it depends on what you call before show ADS and in ADS callback. Try to do the same In empty example.
One more option is to share your project with me (in PM of course)

Are you sure it’s a broken Lua stack? According to the crash shared by Totebo it seems like it is this line crashing:

The key_1 and value_1 values are not checked. Are we sure they are ok? Perhaps you could dmLogInfo() print them one by one before they are used and put that on a branch for Totebo to try?

Also, @totebo: How are you invoking any of the DefUnityAds functions? Are they called from within some callback or directly from the Defold lifecycle functions?

I use a lua module:

local M = {}

local function unity_ads_callback( self, msg_type, message )

	pprint( "unity_ads_callback()", self, msg_type, message )

end

function M.initialize()

	pprint( "ads.initialize()" )
	
	local test_mode = false
	local game_id
	local sys_info = sys.get_sys_info()
	if sys_info.system_name == "Android" then
		game_id = "4350934"
	elseif sys_info.system_name == "iPhone OS" then
		game_id = "2309234"
	end

	if unityads then
		
		local unityads_is_supported = unityads.isSupported()

		print( "unityads.isSupported()", unityads_is_supported )
		
		if unityads_is_supported then
			if unityads.isInitialized() then
				print("unityads.setCallback()", unity_ads_callback )
				unityads.setCallback(unity_ads_callback)
			else
				print("unityads.initialize()", game_id, unity_ads_callback, test_mode )
				unityads.initialize( game_id, unity_ads_callback, test_mode )
			end
		else
			--print("Unity Ads are not supported on this device")
		end

	end

end

return M

Called like this:

local ads = require "main.ads"

function init(self)
	ads.initialize()
end

See the empty example above (that’s all the code in the project).

Ok, so there really shouldn’t be any problem with other extensions when setting up the callback. The DefUnityAds extension callback uses polling and will run together with other extensions which have an update method defined. But I don’t really see how they would interfere, especially since you’re restoring the Lua state from the callback. Printing values inside that callback function in the extension may help shed some light on the problem.

Please share code how you call “show” and what is your PlacementID(s)

The crash always happens after I call unityads.initialize(), so I have never made it far enough to show any ads.

Anything printed in the callback doesn’t show, for some reason. The crash seems to override it. Or maybe the printing itself causes the crash? Worth testing.

Update: I read now you meant inside the extension, doh. In any case, it still crashes, with this error message in Defold:

Even though it says it “successfully wrote Crashdump”, there is no crash log in the location specified.

I strongly suggest creating a minimal repro project that you share for others to test/debug. It will shorten the turnaround times and guessing a lot.

1 Like