Open Tobi-La opened 4 years ago
Having this exact issue with my Testflight beta testers :-(
It seems to have something to do with the latest iOS update 13.3, all testers with this version have the issue.
I tried running it through xcode directly without testflight and got the following debug output before crashing:
***** main.m running app main Path: /var/containers/Bundle/Application/0641A961-34FD-457F-A76E-AF020B679FA0/myGame.app godot_iphone /var/containers/Bundle/Application/0641A961-34FD-457F-A76E-AF020B679FA0/myGame.app/myGame cwd /private/var/containers/Bundle/Application/0641A961-34FD-457F-A76E-AF020B679FA0/myGame.app os created setting data dir to /var/mobile/Containers/Data/Application/0AD9FD7C-7ED4-4B44-A965-134A077079B2/Documents from /var/mobile/Containers/Data/Application/0AD9FD7C-7ED4-4B44-A965-134A077079B2/Documents setup 0 after init super 0x14de09250 2019-12-30 15:41:38.965736+0100 myGame[240:3900] Metal GPU Frame Capture Enabled 2019-12-30 15:41:38.966121+0100 myGame[240:3900] Metal API Validation Enabled 2019-12-30 15:41:39.077161+0100 myGame[240:3900] Setting up an OpenGL ES 3 context. Based on Project Settings "rendering/quality/driver/driver_name" **** screen size 750, 1334 after init gles 0x14de09250 **** adding observer for sound routing changes **** adding observer for keyboard show/hide cadisaplylink: 1start animation! **** screen size 750, 1334 2019-12-30 15:41:39.301026+0100 myGame[240:3900] OpenGL ES 3.0 Renderer: Apple A9 GPU 2019-12-30 15:41:40.173512+0100 myGame[240:3900] ERROR: Condition ' instance != null ' is true. 2019-12-30 15:41:40.173639+0100 myGame[240:3900] At: modules/admob/ios/src/godotAdmob.mm:12:GodotAdmob() - Condition ' instance != null ' is true. transactions updated! status purchased! 2019-12-30 15:41:40.678397+0100 myGame[240:3900] Using iOS IAP 2019-12-30 15:41:40.678460+0100 myGame[240:3900] GodotAdmob Module already initialized 2019-12-30 15:41:40.678623+0100 myGame[240:3900] -[__NSCFNumber loadRewardedVideo:]: unrecognized selector sent to instance 0x8dba8f1a27f15dc4 2019-12-30 15:41:40.689950+0100 myGame[240:3900] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber loadRewardedVideo:]: unrecognized selector sent to instance 0x8dba8f1a27f15dc4' *** First throw call stack: (0x19bd2aa48 0x19ba51fa4 0x19bc2e5a8 0x19bd2eaf4 0x19bd30a7c 0x100753090 0x101523640 0x100854978 0x1a265788c 0x19cc73934 0x19bc7f8ac 0x19bca907c 0x19bca87a8 0x19bca367c 0x19bca2adc 0x1a5c28328 0x19fd9dae0 0x100728bbc) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
I updated xcode to the latest version
It also doesn't occur every time, there is a chance to start the app once when I execute it like 10 times in a row. It seems there is a more frequent sucess rate on older devices, so it may be a timing related issue?
Right, mine seems to work around half the time, and I get exactly that NSInvalidArgumentException
error. I wonder if its an error received from AdMob during initialization that needs to be handled instead of blowing up?
I tried updating to the latest admob framework and it seems that the app is starting fine now. I still have some crashes, but I think they are engine related (they fit to https://github.com/godotengine/godot/issues/34221 and https://github.com/godotengine/godot/pull/33154 which is not part of 3.1 if I see it correctly)
Needs more testing though
Yeah, using the latest admob frameworks I get a good start rate. Those fixes are on a stable release soon. I tried the beta 3.2b3 version but I think they took away support for arm7 on that version, which prevents my device from being used :-(
It's still crashing in some devices on start though, e.g. an iPhone 8
Same crashlog as in the original post.
@Shin-NiL Does the "help wanted" flag mean that you don't know where the issue is or that you don't have the time to fix it yourself? Me and my team are near to the planned release and this issue is preventing progress right now. It didn't occur prior iOS 13.3. I sadly have no experience with the development of this module or godot modules in general yet, but if there is something I can do to help, let me know. Thank you for everything you've done, without all this developing mobile games with godot wouldn't be possible!
This means I don't have the Apple hardware (iphone, mac) and knowledge to fix this. We need help from an iOS developer to fix not only this, but all issues related to this platform.
When I added support for iOS, I borrowed a Mac and did everything without knowing exactly how to program to that. It worked for the project I was releasing and since then I can't do anything about the new issues. I'm really sorry ;(
@Shin-NiL nothing to be sorry for. Do you know anyone who could help? Or would you bother if I link this issue in the official godot community and ask for help? Or do you have some other places where we could ask? I'm currently out of solutions and I really need ads working for the project, as this is our only income from our otherwise free app. :(
@Tobi-La Feel free to ask for help anywhere, I don't know anybody who can help us. I already have asked for help at the godot repository for another issue, but I haven't found anyone.
I invested a few hours and compiled the engine and the export templates myself. I used the precompiled custom templates with integrated admob for godot 3.1 from https://github.com/GhostWalker562/godot-admob-iOS-precompiled , which seems was a big mistake. It seems to run fine now. I'll close the issue when I have a few more testers confirm this. Thanks for your help and your work :)
Nice! I hope everything goes fine from here ;)
I invested a few hours and compiled the engine and the export templates myself. I used the precompiled custom templates with integrated admob for godot 3.1 from https://github.com/GhostWalker562/godot-admob-iOS-precompiled , which seems was a big mistake. It seems to run fine now. I'll close the issue when I have a few more testers confirm this. Thanks for your help and your work :)
Any chance you can share your precompiled export templates? I tried but didn't work. Or maybe sharing which branch you used for the compiling and any additional steps needed (what did you fix in the code that the re-compiling worked)
Also, were you able to fix the crash upon closing the game? (not related to admob but also present on version 3.1.1 stable with iOS 13).
At the end I was able to compile it using the last commit for the stable release 3.1.1 (66baa3b633fe904ea0d90a9688d602d9f3a0b3bd) and following the instructions. The admob error at the begining is now gone.
@jeudy-ua would you be able to share the compiled templates?
@jeudy-ua would you be able to share the compiled templates?
Sure! I will upload them soon. I also want to apply the patch mentioned here to fix a crash that happens when the game is closed and re-compile them with this fix (because the one I compile still crashes on exit and looks bad).
@jeudy-ua would you be able to share the compiled templates?
Sure! I will upload them soon. I also want to apply the patch mentioned here to fix a crash that happens when the game is closed and re-compile them with this fix (because the one I compile still crashes on exit and looks bad).
Thanks man. i'll be looking forward for it. I'm new with the iOS exports with the AdMob, and i'm having some issues trying to figure it out. Your help will be highly appreciate it.
@CompassDevs here is a repo with the compiled template I used and that work. This still doesn't have the fix for the separate issue of the app crash on exit. But will soon.
@CompassDevs here is a repo with the compiled template I used and that work. This still doesn't have the fix for the separate issue of the app crash on exit. But will soon.
Hey, Thanks. I'll give it a try already. Meantime waiting for the crash fixed one.
@CompassDevs here is a repo with the compiled template I used and that work. This still doesn't have the fix for the separate issue of the app crash on exit. But will soon.
Hey, Thanks. I'll give it a try already. Meantime waiting for the crash fixed one.
@jeudy-ua Bro, i did try, but seems not to be working, i admit i'm terrible with the xcode part, i'm afraid i'm doing something wrong, in the certificates or adding the google framework, i'm not sure. Do you know when the final "crash free" template will be completed? and most of all, do you have a good step-by-step i can follow? Thanks in advance!
@CompassDevs yeah the XCode part can be tricky. Here is my published game on iOS where you can see the ads working (intersitial and rewarded): https://apps.apple.com/us/app/moving-blocks-identicons/id1493046555?ls=1
The precompiled version I put crashes when the app is closed but it goes unnoticed for the user so should not be a roadblock (otherwise the app store would not have approved my game this week).
What error are you seeing? is it in the build process on XCode? How far are you getting in the process?
@jeudy-ua Hello, i think i'm missing or doing wrong some step in putting the "stuff" together, meaning the frameworks, and some other necessary. Xcode either fails on doing the build or gives error. I manage to build for development and my app works without admob. The moment i try to build it with admob, no matter development or distribuition it fails...
@jeudy-ua Hello, i think i'm missing or doing wrong some step in putting the "stuff" together, meaning the frameworks, and some other necessary. Xcode either fails on doing the build or gives error. I manage to build for development and my app works without admob. The moment i try to build it with admob, no matter development or distribuition it fails...
@CompassDevs it seems there is a fix for the crash on exit issue (here) so I will try it and create a new precompiled templates with it. After that I will make the step to step tutorial you need for XCode.
@jeudy-ua Hello, i think i'm missing or doing wrong some step in putting the "stuff" together, meaning the frameworks, and some other necessary. Xcode either fails on doing the build or gives error. I manage to build for development and my app works without admob. The moment i try to build it with admob, no matter development or distribuition it fails...
@CompassDevs it seems there is a fix for the crash on exit issue (here) so I will try it and create a new precompiled templates with it. After that I will make the step to step tutorial you need for XCode.
@jeudy-ua Thanks man, you are saving me from a lot of stress!! I'll be waiting patiently
@jeudy-ua Hello there, I gave it one more try, and still didn't work..... I wonder what do i do wrong....
@jeudy-ua Hello there, I gave it one more try, and still didn't work..... I wonder what do i do wrong....
@CompassDevs I uploaded a video showing the steps I followed to build the game. In the descriptions there are more details.
Also, I'm updating the .a file I precompiled to include the fix for the crash on exit (its still uploading so it will be at least a few mins after I posted this reply).
Hope it helps.
@jeudy-ua You have been super patient with me heheh. Your video was very clear, after some further issues, i have managed to complete the package, now waiting for review on app store. I think the error on exit is still there, and most importantly, i could not see the ads appearing, but no error or what so ever.... i'll give a try and see.
For the meantime, THANKS man!!
@jeudy-ua Hey bro, thanks again first of all. Now since my last feedback to you, i have been waiting for a while, but indeed as mentioned already, the ads are not appearing on the iOS devices (for the sake of clarity everything works fine on Android), do you have any idea where the issue could be? I'm pretty sure the id is fine, and no errors of any kind were generated during build....
Hi @CompassDevs, when did you create your admob account and your ad unit? sometimes it takes a few days to show up. Although if they show up on Android then its weird.
Have you tried test ads by sending the "isReal"parameter to false?
@jeudy-ua it was long time ago for Android, and over 3 weeks ago for iOS, i don't think the issue is about waiting anymore, since i also went through it with the Android version at the beginning, and after some time ads start showing. One very strange thing is in the Admob dashboard i see User metrics updating for the iOS account but no Admob network request at all. "Have you tried test ads by sending the "isReal"parameter to false?" No i din't try, at the end the code is the same (android and ios) the only differences are the Admob iOS id and the banner id unit . So, should be all fine.....
Have you tried to use the android ad unit id on the iOS compile? that way you can rule out if the issue is in the compilation process or on the admob side.
@jeudy-ua no, i didn't. i can give it a try.... although makes no much sense....
@jeudy-ua hello there, i have tried, both the suggestions, the test ads (isReal=false) and using android ad unit id. In both cases nothing appears.
Can it be the version of the Google sdk? Maybe the one pre-compiled (*.a file which you made) is different version then the one i use in xcode project (as you show in the video)... can this create this issue? Should an error appear in xcode? It seems it doesn't generate any request at all, therefore no ads.
When i was trying with android i was checking with the adb, and connecting the phone i could see the request and the fill, do you know if there is a way in iOS?
2019-12-30 15:41:39.301026+0100 myGame[240:3900] OpenGL ES 3.0 Renderer: Apple A9 GPU 2019-12-30 15:41:40.173512+0100 myGame[240:3900] ERROR: Condition ' instance != null ' is true. 2019-12-30 15:41:40.173639+0100 myGame[240:3900] At: modules/admob/ios/src/godotAdmob.mm:12:GodotAdmob() - Condition ' instance != null ' is true.
2019-12-30 15:41:40.678460+0100 myGame[240:3900] GodotAdmob Module already initialized
Standard C, C ++, etc. states that we have a clear mistake. "Undefined behavior." For Objective-C, the rules are likely to be the same. The instance variable is not global or initialized. It can have any value, depending on the compiler and the optimization flag!
Since this variable is not global, we can have more than one instance of this class.
instance var is not static and not null. See on arkit_module or camera_module or platform/iphone/in_app_store.* sources
godotAdmob.h error code
class GodotAdmob : public Reference {
#if VERSION_MAJOR == 3
GDCLASS(GodotAdmob, Reference);
#else
OBJ_TYPE(GodotAdmob, Reference);
#endif
bool initialized;
GodotAdmob *instance; // <<< is not static and is not null!!!
//static GodotAdmob *instance = NULL; //we can write like that!
//The standard с++11 guarantees that this variable will be initialized like this!
//But the standard objective-c++ does not guarantee! The standard objective-c++ does not guarantee anything! > _ <
...
};
#include "godotAdmob.h"
#import "app_delegate.h"
#if VERSION_MAJOR == 3
#define CLASS_DB ClassDB
#else
#define CLASS_DB ObjectTypeDB
#endif
GodotAdmob::GodotAdmob() {
ERR_FAIL_COND(instance != NULL); // <<< ERR ON CONSOLE! instnace is not init!!!
instance = this;
initialized = false; //<< unknow?
/*
since the constructor was not called. Initialization variable - not defined. It may be false or true.
*/
}
GodotAdmob::~GodotAdmob() {
instance = NULL;
//we do not free memory! which was isolated using malloc!!!!
}
...
void GodotAdmob::init(bool isReal, int instanceId) {
if (initialized) {
NSLog(@"GodotAdmob Module already initialized"); //<<The log says that the constructor is initialized, although it is not!
return;
}
initialized = true;
banner = [AdmobBanner alloc];
[banner initialize :isReal :instanceId];
interstitial = [AdmobInterstitial alloc]; //<<allocation does not occur!
[interstitial initialize:isReal :instanceId];
rewarded = [AdmobRewarded alloc];
[rewarded initialize:isReal :instanceId];
}
...
////Godot uses his own link count and locator. memnew () function
////It seems to me that in version 3.2 the functions memnew() were passed
void GodotAdmob::loadRewardedVideo(const String &rewardedId) {
//init
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
NSString *idStr = [NSString stringWithCString:rewardedId.utf8().get_data() encoding: NSUTF8StringEncoding];
[rewarded loadRewardedVideo: idStr]; //Turning to a random memory area!
//Since our memory is allocated using a special function. We can spoil the memory of other objects or go beyond it!
}
ERR_FAIL_COND : Current function ends!!!
#define ERR_FAIL_COND(m_cond) \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
return; \
} else \
((void)0)
godotAdmob.h
#ifndef GODOT_ADMOB_H
#define GODOT_ADMOB_H
#include <version_generated.gen.h>
#include "reference.h"
#ifdef __OBJC__
@class AdmobBanner;
typedef AdmobBanner *bannerPtr;
@class AdmobInterstitial;
typedef AdmobInterstitial *interstitialPtr;
@class AdmobRewarded;
typedef AdmobRewarded *rewardedPtr;
#else
typedef void *bannerPtr;
typedef void *interstitialPtr;
typedef void *rewardedPtr;
#endif
class GodotAdmob : public Reference {
#if VERSION_MAJOR == 3
GDCLASS(GodotAdmob, Reference);
#else
OBJ_TYPE(GodotAdmob, Reference);
#endif
bool initialized;
static GodotAdmob *instance; //<<<< STATIC
bannerPtr banner;
interstitialPtr interstitial;
rewardedPtr rewarded;
protected:
static void _bind_methods();
public:
void init(bool isReal, int instanceId);
void loadBanner(const String &bannerId, bool isOnTop);
void showBanner();
void hideBanner();
void resize();
int getBannerWidth();
int getBannerHeight();
void loadInterstitial(const String &interstitialId);
void showInterstitial();
void loadRewardedVideo(const String &rewardedId);
void showRewardedVideo();
GodotAdmob();
~GodotAdmob();
};
#endif
#include "godotAdmob.h"
#import "app_delegate.h"
#if VERSION_MAJOR == 3
#define CLASS_DB ClassDB
#else
#define CLASS_DB ObjectTypeDB
#endif
GodotAdmob *GodotAdmob::instance = NULL; //<< INIT NULL VAR ON COMPILE TIME!
GodotAdmob::GodotAdmob() {
initialized = false;
banner = NULL;
interstitial = NULL;
rewarded = NULL;
//
ERR_FAIL_COND(instance != NULL); //<< SUCCESS!!! FIRST
instance = this;
}
GodotAdmob::~GodotAdmob() {
if (initialized) {
[banner release]; //free banner
[interstitial release]; //free
[rewarded release]; //free
}
if (instance == this) {
instance = NULL;
}
}
void GodotAdmob::init(bool isReal, int instanceId) {
if (instance != this) {
NSLog(@"GodotAdmob Module dublicate singleton");
return;
}
if (initialized) {
NSLog(@"GodotAdmob Module already initialized");
return;
}
initialized = true;
banner = [[AdmobBanner alloc] init];
[banner initialize :isReal :instanceId];
interstitial = [[AdmobInterstitial alloc] init];
[interstitial initialize:isReal :instanceId];
rewarded = [[AdmobRewarded alloc] init];
[rewarded initialize:isReal :instanceId];
}
void GodotAdmob::loadBanner(const String &bannerId, bool isOnTop) {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
NSString *idStr = [NSString stringWithCString:bannerId.utf8().get_data() encoding: NSUTF8StringEncoding];
[banner loadBanner:idStr :isOnTop];
}
void GodotAdmob::showBanner() {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
[banner showBanner];
}
void GodotAdmob::hideBanner() {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
[banner hideBanner];
}
void GodotAdmob::resize() {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
[banner resize];
}
int GodotAdmob::getBannerWidth() {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return 0;
}
return (uintptr_t)[banner getBannerWidth];
}
int GodotAdmob::getBannerHeight() {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return 0;
}
return (uintptr_t)[banner getBannerHeight];
}
void GodotAdmob::loadInterstitial(const String &interstitialId) {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
NSString *idStr = [NSString stringWithCString:interstitialId.utf8().get_data() encoding: NSUTF8StringEncoding];
[interstitial loadInterstitial:idStr];
}
void GodotAdmob::showInterstitial() {
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
[interstitial showInterstitial];
}
void GodotAdmob::loadRewardedVideo(const String &rewardedId) {
//init
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
NSString *idStr = [NSString stringWithCString:rewardedId.utf8().get_data() encoding: NSUTF8StringEncoding];
[rewarded loadRewardedVideo: idStr];
}
void GodotAdmob::showRewardedVideo() {
//show
if (!initialized) {
NSLog(@"GodotAdmob Module not initialized");
return;
}
[rewarded showRewardedVideo];
}
void GodotAdmob::_bind_methods() {
CLASS_DB::bind_method("init",&GodotAdmob::init);
CLASS_DB::bind_method("loadBanner",&GodotAdmob::loadBanner);
CLASS_DB::bind_method("showBanner",&GodotAdmob::showBanner);
CLASS_DB::bind_method("hideBanner",&GodotAdmob::hideBanner);
CLASS_DB::bind_method("loadInterstitial",&GodotAdmob::loadInterstitial);
CLASS_DB::bind_method("showInterstitial",&GodotAdmob::showInterstitial);
CLASS_DB::bind_method("loadRewardedVideo",&GodotAdmob::loadRewardedVideo);
CLASS_DB::bind_method("showRewardedVideo",&GodotAdmob::showRewardedVideo);
CLASS_DB::bind_method("resize",&GodotAdmob::resize);
CLASS_DB::bind_method("getBannerWidth",&GodotAdmob::getBannerWidth);
CLASS_DB::bind_method("getBannerHeight",&GodotAdmob::getBannerHeight);
}
PS: The whole code is an attempt to shoot both legs!)
I suspect that the memory worked like this:
T* memnew(T) {
auto ptr = memory.realloc(sizeof(T));
memset(ptr, 0, sizeof(T)); //fill memory on zero
return new(ptr) T()r;
}
and then changed due to overhead.
T* memnew(T) {
auto ptr = memory.realloc(sizeof(T));
//memset(ptr, 0, sizeof(T)); //memory random byte
return new(ptr) T()r;
}
In general, all Objective-C objects need to implement a constructor (init) Implement a constructor according to all standards ...
interstitial = [[AdmobInterstitial alloc] init];
[interstitial initialize:isReal :instanceId];
...
[interstitial release];
OR
interstitial = [[AdmobInterstitial alloc] initWith:isReal :instanceId];
...
[interstitial release];
BUG still persists in 3.1.2, but when the debug is stopped, i can open the app normally and doesnt froze anymore, but the error is still there on debug
Is the error only in the log or crashes? I will look again at version 3.2.2
The error are in the log, and the app frozen
OS target (Android/iOS): iOS
Godot version: 3.1.1 stable
Issue description: One of my testers has a problem of my app crashing on her iPhone. The crashlog shows the following, which seems it has to do with admob: