Shutdown and re-initialization of some components / modules causes crashes
larpon opened this issue · 13 comments
Hi, I'm the maintainer of https://github.com/Larpon/QtFirebase (a Qt wrap around the Firebase C++ SDK).
I've noticed crashes in some modules after a call to Terminate - and then trying to reinitialize by calling ModuleInitializer::Initialize - is this expected behaviour?
I'm asking because it's fairly common practice to initialize Qt/QML via dynamic Loader
elements that will cause a complete life-cycle change of a module:
- Initialize app
- Load QML UI on demand when user clicks specific menu entry (call to
ModuleInitializer::Initialize
) - Unload QML UI (call to
Terminate
) - when user navigates back - User goes elsewhere in the app
- Load QML UI on demand when user clicks specific menu entry (call to
ModuleInitializer::Initialize
) - Crash
I just wanted to know if I'm doing something wrong or ? - doing a single cycle initialize + terminate seem to work like a charm.
I'll have to document the behaviour to our users somehow - so I got curious :)
Hi @larpon this definitely sounds like a bug. It's possible we're not cleaning up correctly in a one of Terminate() methods. Any chance you have narrowed down which components cause the problem?
Cheers,
Stewart
I got crashes on Android with Auth
and AdMob
.
Currently I'm a bit confused on whether it's our own code or yours.
Auth
doesn't have anything else than the destructor AFAIK? So I guess the destructor is called when the QML engine is unloading.
Upon AdMob
Terminate call I get this:
11-08 13:47:06.024 24988 25014 D libApp.so: /home/user/Projects/QtFirebase/src/qtfirebaseadmob.cpp:39 (virtual QtFirebaseAdMob::~QtFirebaseAdMob()): QtFirebaseAdMob(0x9b0c27e0) ::~QtFirebaseAdMob shutting down
11-08 13:47:06.024 24988 25014 F firebase: g_java_vm
11-08 13:47:06.254 25165 25165 F google-breakpad: Microdump skipped (uninteresting)
11-08 13:47:06.294 24988 25014 W google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
11-08 13:47:06.294 24988 25014 W google-breakpad: Chrome build fingerprint:
11-08 13:47:06.294 24988 25014 W google-breakpad: 1.0.0-armv7
11-08 13:47:06.294 24988 25014 W google-breakpad: 1
11-08 13:47:06.294 24988 25014 W google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
11-08 13:47:06.294 24988 25014 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 25014 (QtThread)
11-08 13:47:06.354 442 442 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-08 13:47:06.354 442 442 F DEBUG : Build fingerprint: 'samsung/kltexx/klte:6.0.1/MMB29M/G900FXXS1CQD2:user/release-keys'
11-08 13:47:06.354 442 442 F DEBUG : Revision: '14'
11-08 13:47:06.354 442 442 F DEBUG : ABI: 'arm'
11-08 13:47:06.354 442 442 F DEBUG : pid: 24988, tid: 25014, name: QtThread >>> com.blackgrain.android.firebasetest <<<
11-08 13:47:06.354 442 442 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
11-08 13:47:06.414 442 442 F DEBUG : Abort message: 'g_java_vm'
11-08 13:47:06.414 442 442 F DEBUG : r0 00000000 r1 000061b6 r2 00000006 r3 9cc47978
11-08 13:47:06.414 442 442 F DEBUG : r4 9cc47980 r5 9cc47930 r6 00000002 r7 0000010c
11-08 13:47:06.414 442 442 F DEBUG : r8 9d35b0b3 r9 00000000 sl 00000007 fp 9cc471ac
11-08 13:47:06.414 442 442 F DEBUG : ip 00000006 sp 9cc47098 lr b6d44c11 pc b6d47000 cpsr 400f0010
11-08 13:47:06.424 442 442 F DEBUG :
11-08 13:47:06.424 442 442 F DEBUG : backtrace:
11-08 13:47:06.424 442 442 F DEBUG : #00 pc 00042000 /system/lib/libc.so (tgkill+12)
11-08 13:47:06.424 442 442 F DEBUG : #01 pc 0003fc0d /system/lib/libc.so (pthread_kill+32)
11-08 13:47:06.424 442 442 F DEBUG : #02 pc 0001c393 /system/lib/libc.so (raise+10)
11-08 13:47:06.424 442 442 F DEBUG : #03 pc 00019611 /system/lib/libc.so (__libc_android_abort+34)
11-08 13:47:06.424 442 442 F DEBUG : #04 pc 00017564 /system/lib/libc.so (abort+4)
11-08 13:47:06.424 442 442 F DEBUG : #05 pc 000d6557 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so
11-08 13:47:06.424 442 442 F DEBUG : #06 pc 000d660b /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so
11-08 13:47:06.424 442 442 F DEBUG : #07 pc 000d658f /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN8firebase9LogAssertEPKcz+14)
11-08 13:47:06.424 442 442 F DEBUG : #08 pc 000bf873 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN8firebase5admob6GetJNIEv+30)
11-08 13:47:06.424 442 442 F DEBUG : #09 pc 000c0089 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN8firebase5admob8internal25BannerViewInternalAndroid13InvokeNullaryENS1_12BannerViewFnENS0_18banner_view_helper6MethodE+24)
11-08 13:47:06.424 442 442 F DEBUG : #10 pc 000c0113 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN8firebase5admob8internal25BannerViewInternalAndroid7DestroyEv+18)
11-08 13:47:06.424 442 442 F DEBUG : #11 pc 000c1435 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN8firebase5admob10BannerView7DestroyEv+28)
11-08 13:47:06.424 442 442 F DEBUG : #12 pc 0008d0fc /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN21QtFirebaseAdMobBannerD2Ev+96)
11-08 13:47:06.424 442 442 F DEBUG : #13 pc 000787c8 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN11QQmlPrivate11QQmlElementI21QtFirebaseAdMobBannerED1Ev+64)
11-08 13:47:06.424 442 442 F DEBUG : #14 pc 00078810 /data/app/com.blackgrain.android.firebasetest-1/lib/arm/libApp.so (_ZN11QQmlPrivate11QQmlElementI21QtFirebaseAdMobBannerED0Ev+20)
11-08 13:47:07.374 962 1482 D lights : button : 0 +
11-08 13:47:07.414 962 1482 D lights : button : 0 -
11-08 13:47:08.204 442 442 F DEBUG :
11-08 13:47:08.204 442 442 F DEBUG : Tombstone written to: /data/tombstones/tombstone_02
11-08 13:47:08.204 442 442 E DEBUG : AM write failed: Broken pipe
11-08 13:47:08.204 442 442 E : ro.product_ship = true
11-08 13:47:08.204 442 442 E : ro.debug_level = 0x4f4c
11-08 13:47:08.204 442 442 E : sys.mobilecare.preload = false
11-08 13:47:08.214 2275 2275 E audit : type=1701 msg=audit(1510145228.214:25120): auid=4294967295 uid=10198 gid=10198 ses=4294967295 subj=u:r:untrusted_app:s0:c512,c768 pid=25014 comm="QtThread" reason="memory violation" sig=6
11-08 13:47:08.224 962 1100 I BootReceiver: Copying /data/tombstones/tombstone_02 to DropBox (SYSTEM_TOMBSTONE)
11-08 13:47:08.234 962 25166 W ActivityManager: Force finishing activity com.blackgrain.android.firebasetest/.Main
It's worth noting that we initialize AdMob with the admob::Initialize
call - but the crash is upon calling Terminate()
Just managed to catch a glimpse of the crash in Auth and it seem to be on our side.
@larpon did you figure out what was going on in QtFirebase?
@stewartmiles yes, I have got everything working - except AdMob that still crashes on calling Terminate()
(here)
I think the call to Terminate
make it crash because instances of banners and/or interstitials/rewarded are still alive at that point in the QML engine (it's garbage collected and the order of shutdown is not predictable)
@larpon which platform crashes? Is this both Android and iOS?
Are you cleaning up all AdMob objects (banner view, rewarded video & interstitials) before calling terminate?
Android - I'll try and make so any AdMob objects are shutdown before calling Terminate
getting same issue, crash on calling firebase::AdMob::terminate
@bswstudiosgit could you share your logs including the crash?
@stewartmiles Crashed: com.apple.main-thread
0 LudoBlacklight-mobile 0x101776aa0 firebase::admob::internal::BannerViewInternal::NotifyListenerOfPresentationStateChange(firebase::admob::BannerView::PresentationState) + 16960
1 LudoBlacklight-mobile 0x1017774fc invocation function for block in firebase::admob::internal::BannerViewInternalIOS::Destroy() + 19612
2 LudoBlacklight-mobile 0x1017655dc firebase::util::DispatchAsyncSafeMainQueue(void () block_pointer) + 54768
3 LudoBlacklight-mobile 0x101777468 firebase::admob::internal::BannerViewInternalIOS::Destroy() + 19464
4 LudoBlacklight-mobile 0x101776d2c firebase::admob::internal::BannerViewInternalIOS::~BannerViewInternalIOS() + 17612
5 LudoBlacklight-mobile 0x101776a94 firebase::admob::internal::BannerViewInternal::NotifyListenerOfPresentationStateChange(firebase::admob::BannerView::PresentationState) + 16948
6 LudoBlacklight-mobile 0x101776de8 firebase::admob::internal::BannerViewInternalIOS::~BannerViewInternalIOS()
@stewartmiles i am getting crash when inside destructor i am deleting banner_view->destroy.
banner_view->Destroy();
firebase::admob::Terminate();
@bswstudiosgit Destroy() is asynchronous, are you waiting for Destroy() to complete?
Also, you need to delete the banner_view after Destroy(). See the sample code here:
Closing this issue since it has been a month
bswstudiosgit@ Please let us know if you are still experiencing the same crash.