Quickstart-ios: Stack overflow in fira_viewDidAppear:

Created on 6 Mar 2017  ·  46Comments  ·  Source: firebase/quickstart-ios

Hi guys!

Something went wrong while I'm trying to attach Firebase framework to my project.

Thanks

screen shot 2017-03-06 at 1 39 09 pm

bug

Most helpful comment

@morganchen12 please move firebase to a dynamic library, the amount of bugs/workarounds just to keep it working properly as a static library make the continued use of Firebase less and less attractive

All 46 comments

This is a stack overflow in one of our private class extensions.

Can you describe what steps you took that led to this issue?

@baolocdo FYI

Hi!

Well actually nothing special. We just installed your pod and at app startup it stuck on viewDidAppear method.

Maybe the root of this cause is that we're swipe/change our rootViewController few times at the very beginning?

Thanks for reporting. Would you mind sharing the SDK version, stack trace and some debug log when you turn on debug mode using the argument -FIRAnalyticsDebugEnabled?

We're using the following frameworks

Firebase (3.14.0)
FirebaseAnalytics (3.7.0)
FirebaseCore (3.5.1)
FirebaseInstanceID (1.0.9)
GoogleToolboxForMac (2.1.1)

And here is the crashlog:

CrashLog.txt

And more details:

CrashLog2.txt

Can you provide symbolicated crash logs?

hi

please see attached. If that not what you're expecting just let me know.

Thanks,
XXXXXX_2017-03-07-114230_MacBook-Pro.crash.zip

Thanks for the info. In the mean time, can you try setting this flag FirebaseScreenReportingEnabled to NO in the Info.plist to turn off auto screen reporting? Please let us know if the problem still persists.

Firebase automatic screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO in the Info.plist

ostapkuzyk@: Would you mind providing a sample app which has this bug? It will greatly help the engineers to debug the issue. Thank you in advance!

hi @baolocdo !

FirebaseScreenReportingEnabled = NO did the trick. And I'm still trying to do some test case which can reproduce the issue.

Thanks

Hi guys!

Seems the option to set FirebaseScreenReportingEnabled = NO not working, it still crashing.
Please see below the stack trace:

Crashed: com.apple.main-thread
0 XXXX 0x1004dddb8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885252
1 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
2 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
3 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
4 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
5 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
6 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
7 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
8 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
9 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
10 XXXX 0x1004ddde8 -[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 885300
11 XX 0x1041343a4 _TFC7XX26LaunchScreenViewController13viewDidAppearfSbT_ + 100
12 XX 0x10413467c _TToFC7XX26LaunchScreenViewController13viewDidAppearfSbT_ + 44
13 UIKit 0x191d22834 -[UIViewController _setViewAppearState:isAnimating:] + 848
14 UIKit 0x191d90070 __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44
15 UIKit 0x191d9000c -[UIViewController _executeAfterAppearanceBlock] + 92
16 UIKit 0x191f9c0e4 _runAfterCACommitDeferredBlocks + 556
17 UIKit 0x191f8dd50 _cleanUpAfterCAFlushAndRunDeferredBlocks + 560
18 UIKit 0x191fa709c __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke_2 + 188
19 CoreFoundation 0x18be02a44 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
20 CoreFoundation 0x18be02240 __CFRunLoopDoBlocks + 288
21 CoreFoundation 0x18be00094 __CFRunLoopRun + 788
22 CoreFoundation 0x18bd2e2b8 CFRunLoopRunSpecific + 444
23 GraphicsServices 0x18d7e2198 GSEventRunModal + 180
24 UIKit 0x191d757fc -[UIApplication _run] + 684
25 UIKit 0x191d70534 UIApplicationMain + 208
26 XXXX 0x100174390 main (AppDelegate.swift:31)
27 libdispatch.dylib 0x18ad115b8 (Missing)

Thanks

Hello all,

Gents, are there any plans for updates to be released soon?

Unfortunately I can't reproduce this issue on my test app.

Thanks

We are looking into this. I'm not sure how long it will take since we can't reproduce this scenario and it will be hard to know what is really the issue. Sometimes developers reported that the bugs were caused by some other SDKs or some categories of the NSObjects, UIView, etc.

Same issue for me, i am inhering from default appdelegate, and then initialize firebase. FirebaseScreenReportingEnabled Fixed issue for me.

m1entus@: is it consistent in your app? Is it reproducible in this sample app at all? Also, it would be great to know the SDK versions and XCode versions that you have the problem with. Thanks!

I thought that this is newest version, but i pulled quite old version 3.7.4? And had the same issue. In my app is all the time without Info.plist flag.

Do you know what UIViewController that you have the problem with? How complex is the view (multiple views, keyboard view)? Thanks!

My root view controller have a uiview, which works as a container for child view controller.
rootViewController (UIViewController) -> UIView -> childViewController (UINavigationController) -> topViewController .

And if this help, my rootViewController is in Framework, because i see some calls from you for NSBundle mainBundle, but i suppose there is infinity loop in fira_topViewController, are you checking childViewControllers there ?

Thanks for the info, @m1entus . I'll check with the engineer.

@baolocdo any movement on this issue?

@baolocdo I'm also running into this issue. Here are my version specs

  • Firebase/Core (3.9.0):

    • FirebaseAnalytics (= 3.5.1)

    • FirebaseCore (= 3.4.4)

  • FirebaseAnalytics (3.5.1):

    • FirebaseCore (~> 3.4)

    • FirebaseInstanceID (~> 1.0)

    • GoogleInterchangeUtilities (~> 1.2)

    • GoogleSymbolUtilities (~> 1.1)

    • GoogleToolboxForMac/NSData+zlib (~> 2.1)

  • FirebaseCore (3.4.4):

    • GoogleInterchangeUtilities (~> 1.2)

    • GoogleToolboxForMac/NSData+zlib (~> 2.1)

  • FirebaseInstanceID (1.0.8)

@MikeDeasyBB : Can you try updating to the latest pod (FirebaseAnalytics 3.9.0) and let us know if you still have the same issue?

@baolocdo just tried updating, still have the issue

Current lockfile

  • Firebase/Core (3.17.0):

    • FirebaseAnalytics (= 3.9.0)

    • FirebaseCore (= 3.6.0)

  • FirebaseAnalytics (3.9.0):

    • FirebaseCore (~> 3.6)

    • FirebaseInstanceID (~> 1.0)

    • GoogleToolboxForMac/NSData+zlib (~> 2.1)

  • FirebaseCore (3.6.0):

    • GoogleToolboxForMac/NSData+zlib (~> 2.1)

  • FirebaseInstanceID (1.0.10):

    • FirebaseCore (~> 3.6)

@baolocdo I am able to reproduce this issue on every launch. Please find the sample project which crashes after going to an infinite loop on launch.

I am just using Google Login. Firebase is not used anywhere.

Please let me know if you need further information.

GoogleLoginTest.zip

@VinayakKkini : awesome! That will be really helpful the engineers. Thanks for the sample project.

From the engineer: "The provided sample project has a lot of warnings (e.g. "Class ... is implemented in both"), which indicates that Firebase is being linked in twice (from GoogleLoginTest and CloudAccess). Deleting all entries related to Firebase from 'Other Linker Flags' of GoogleLoginTest, which may include $(inherited), should fix the issue."

@baolocdo Please then make real framework of Firebase and not static library, because we have dependencies from cocoapods and not able to fix it easly ...

@baolocdo The cause for this problem is, firebase is not a dynamic framework but a static library. So when we add this pod to more than one target it gets copied multiple times rather than getting referenced from a single copy. Also, as suggested by the developer, its not easy remove “ entries in 'Other Linker Flags' and $(inherited)” as lot of these flags get set by the cocoa pods and may have dependencies to other frameworks.

The only way you can solve this is by using dynamic frameworks.

You should be able to avoid duplicate Firebase symbols pretty easily if you're just using Firebase as a top-level dependency through CocoaPods. Avoid nesting Firebase in a dynamic library dependency.

What do your dependency graphs look like?

@morganchen12 This is mine:

abstract_target 'ClubAppCommon' do
    pod 'Alamofire', '~> 4.0.1  '
    pod 'SDWebImage', '~> 4.0.0-beta2'
    pod 'FormatterKit', '~> 1.8.1'
    pod 'XCDYouTubeKit', '~> 2.5.3'

    target "ClubAppCoreProduct" do
        pod 'Fabric'
        pod 'Crashlytics'
        pod 'TwitterKit'
        pod 'Firebase'
        pod 'Firebase/Messaging'
    end

    target "ClubAppDemo" do
    end

    target "GornikLeczna" do
    end

    target "MKS Puszcza" do
    end
end

target like GornikLeczna links ClubAppCoreProduct which is framework

Either move Firebase to the top level of your dependency graph or make ClubAppCoreProduct a static library.

I'm going to close this issue, but feel free to keep posting situations in which you'd like to use Firebase as a dependency of a dependency--moving towards dynamic frameworks is something we're constantly evaluating and would like to support, and knowing how many people it'd affect will help us prioritize that.

i also have this issue in my project. my firebse sdk version is 4.0.2, xcode version is 8.3.3. and i use cocoapod to install firebase sdk. here is the screenshot from fabric.

wechatimg136

@WiiliamChik 請確認您 console 裡沒有上面提過的警示。

Class [...] is implemented in both [...] and [...]. One of the two will be used. Which one is undefined.

如果 console 沒有這種警示,卻 app 還会崩溃,請分享您 Podfile 的內容。

@morganchen12 please move firebase to a dynamic library, the amount of bugs/workarounds just to keep it working properly as a static library make the continued use of Firebase less and less attractive

@salqadri FYI

@morganchen12 our main issue with Firebase as a static library is that all of our extensions and main app need to include the code. With 8 extensions this significantly increases our binary size. We minimized our code that touches Firebase so only a few of our classes are duplicated across each extension and the main App. Firebase is not a small target, especially when including the same code 9 times. Moving it to a dynamic framework would allow us to restructure our shared code, and significantly decrease our bundle size which is nearly at 100MB.

Getting the same error while using cocoapods, a dynamic library would be really helpful.

What I noticed is if the pod is added to a framework project/target then the crash happens.

@qalandarov I'm having the same problem. Any way to get around this? The app I'm working on is split into several layers using Frameworks. Firebase is needed for our remote layer.

Setting FirebaseScreenReportingEnabled stopped the app from crashing but now, events are not being sent and still getting all those warnings for classes defined in two places

If you're using CocoaPods, CocoaPods 1.4.0 and higher now specifies a static_framework rule, meaning you can avoid duplicating Firebase symbols in your project by making your dependency tree static.

@morganchen12
I am developing a Swift framework (dynamic). The company distributes it as a binary (no source). Our framework needs to use Firebase and the integrating app may use it as well.
I guess none of the solutions suggested above can work. Right ?

@davibe you'll have to wait for a dynamic Firebase release.

Alternatively, if you're depending on one of the open source components, you can take the source and package it yourself in a way that doesn't cause collisions, but this is a ton of work and has its own downsides.

Having the same issue as everyone above. We need Firebase to be included in both the app and in a Swift Framework utilized by the app. If we can't find a way around this we'll have to wipe Firebase completely from our platform. 😢

In addition to the static_framework option mentioned above, CocoaPods 1.5.0 added Swift static libraries.. Both of these can be helpful for adding Firebase to multiple targets.

Setting FirebaseScreenReportingEnabled to false, basically disables ALL screen tracking, and not only the automatic. So this means, if you try to call setScreenName(_ screenName: String?, screenClass screenClassOverride: String?) it will return in not being sent - so all manual screen opens will fail too.. This is not sustainable - we need to be able to turn off automatic screen tracking ONLY. Any news on this?? :-)

I have integrated Firebase into a highly modular project build with dynamic frameworks.

Here is what you have to do:
1) In your Podfile add Firebase to the dynamic framework.

2) Link dynamic libraries that Firebase depends on to the framework and to your app target so that those dylibs get copied into the target.

e.g In my case I added GoogleToolbox, Protobuf and nanopb to the framework where firebase was and to the AppTarget. I took the exact library versions out of the Podfile.lock when I had only the Firebase linked.

3) Expose Firebase static library via Umbrella file of your dynamic framework so that you can link the firebase on every level you link your dynamic framework to.
e.g in MyFramework.h I added on the bottom this line:

import "FirebaseRemoteConfig/FirebaseRemoteConfig.h"

That allowed me to import Firebase everywhere I linked MyFramework
e.g
import MyFramework
import Firebase

No need to say, that the framework must be compiled before the import will start working.

With this approach, I am able to use Firebase from a dynamic library that is on the 2nd level of our hierarchy. I hope it helps someone.

Was this page helpful?
0 / 5 - 0 ratings