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

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

I would love to! I have tried and failed:

I think it comes down to testing the remaining extensions one by one. This is very time consuming, as you might imagine, and I donā€™t have time to do this today (because Iā€™m making a game, yay!).

I was hoping there was a less time consuming way to move forward. As it stands I have a functional .apk and .ipa with the Firebase extension removed, which works temporarily.

Iā€™m just saying, as it stands right now, we have very little to go on, and I think we need more info to do any further investigation.

This is very time consuming

We know. That is the reason we recommend small repro cases, to minimize the overall cost for everyone involved.

1 Like

Step one is to create an empty project, with the snippet of code from above and with all native extensions you use in your project:

Does it crash under those conditions? Does it happen on both iOS and Android?

1 Like

I understand.

Access to your game project would be fine for me as well, if it possible from your side ofc.I would try to isolate issue myself if I be able to reproduce it.

1 Like

Sorry for trying to take a shortcut! When I have a little more time Iā€™ll make a minimal repro. Thanks for trying to figure this one out!

1 Like

Yes, I agree.

I think I know what the problem (value_1 is null), but I donā€™t know why.

Thatā€™s why it would be nice to know Placements ID, because value_1 is PlacementId (or ErrorMessage). Null check will help with crash, but we will miss some info about error or placement.
Anyway, Iā€™ll prepare fix today later.

1 Like

Good evening DefVideoAds lovers! After a great deal of building and testing, the results are in. This is for Android only.

There is a crash when these extensions are all included:

  • DefVideoAds
  • Firebase
  • IAP
  • Google Play Game Services

A minimal example project: DefVideoAds Conflicts.zip (8.1 KB)

These combinations do not cause a crash:

  • DefVideoAds + IAP + Google Play Game Services
  • DefVideoAds + Firebase + Google Play Game Services
  • DefVideoAds + IAP + Firebase

Hope this will make it easier to figure this out. If it helps Iā€™ll do the same tests for iOS too.

3 Likes

Pls, take a look fixed version

The short version of explanation: developers should use namespaces in extensions.

A bit longer explanation:
in both gpgs extension and DefVideoADS we have the following line:

static dmArray m_callbacksQueue;

Both were written copied/pasted by me =)

There is problem with CallbackData because in both extensions both structures defined in global scope and in some cases DefVideoADS uses CallbackData (structure declaration) from gpgs.

We had similar issue with struct Command in a couple of our extensions a year ago.
I added namespace for DefVideoADS and now everything should be fine.

Sorry for inconvenience and thank you for help with catching this issue. Without repo-case itā€™s not so easy to do.

7 Likes

Fantastic! Great work by everyone involved!

2 Likes

I feel like Iā€™ve run into similar bugs before, when I tried combining native extensions.

As someone who wants to write them someday, is namespacing something that should be added to the docs, and put into the sample native extension repos?

2 Likes

It should probably be added to the template project: https://github.com/defold/template-native-extension

Itā€™s either namespaces or making sure that all variables and functions are prefixed with the extension name: m_GpgpsCallbacksQueue and m_DefVideoAdsCallbacksQueue instead of just m_CallbacksQueue.

2 Likes

Honestly, is sounds like a big bug to me.
I cannot imagine this is a feature of C++, to merge two different symbols.
If anything, it should produce a ā€œduplicate symbolā€ error.

Last time this happened (like @agulev mentioned), I wanted to look into it, but I forgot about it. But Iā€™ll make some tests this weekend.

4 Likes

Also, good job creating the repro @totebo!

3 Likes

I have now tested DefVideoAds v3.4.9 on iOS and Android and can confirm it works with the whole onslaught of extensions listed above, including Firebase. Glorious happiness - and itā€™s Friday! :partying_face:

Youā€™re most welcome!

Thanks!

3 Likes

Oh, sorry, I think I explained it wrong.
Itā€™s not because of the same variable name m_callbacksQueue. Itā€™s because of the same structure declaration CallbackData.
In DefVideoADS it is

struct CallbackData
{
  int msg_type;
  char* key_1;
  char* value_1;
  char* key_2;
  int value_2;
};

But inGPGS:

struct CallbackData
{
    MESSAGE_ID msg;
    char* json;
};

In some conditions DefVideoAds uses CallbackData from GPSG and we got crash because in CallbackData from GPSG we donā€™t have value_1, key_1 and so on.

2 Likes

Ah, got it! I think @JCash is investigating this. We should get something like a ā€œduplicate symbolā€ error or something while linking.

1 Like

Iā€™m just trying the extension example. If I try to use the ā€œSign IOS Appā€ I get the following error:

If instead I bundle the project, the ipa is created and runs just fine.
Any clue?

Sorry, I donā€™t know whatā€™s the problem here.
But you can use developer build of the app the same way you use ā€œSign ios appā€

Seems like is not merging the manifests. Worth mentioning Iā€™m on 1.2.174 beta.