firebase-ios-sdk: FIRAScreenViewReporter incorrectly forces loads of parent view controller's views
Environment
- Xcode version: 9.0/9.1b1
- iOS version: 11.0.1
- Firebase SDK version: 4.0.3
- Firebase Component: Analytics
Description
Firebase hooks into UIKit to know when a UIViewController gets a -viewWillAppear: call, but this calls FIRACurrentViewControllerInStack, which seems to be accessing the parent view controller’s view. In our situation, this happens when the parent view controller is in -loadView, which results in an infinite loop. It may even be the cause for https://github.com/firebase/quickstart-ios/issues/231. I noticed that the debug navigator in Xcode doesn’t show the Firebase calls in the stack, but manually running backtrace in lldb does.
We’ve currently disabled the screen reporting, but would love to see this fixed!
Steps to reproduce:
This is difficult to do, because this may be reliant on UIPageViewController behaviour. The stack trace below should be informative enough. I can confirm, though, that this only occurs when screen reporting is enabled.
Stacktrace
frame #3713: 0x00000001089529cc PSPDFKitUI`-[PSPDFPageCurlViewController viewDidLoad](self=0x000000010a84b200, _cmd="viewDidLoad") at PSPDFPageCurlViewController.m:65
frame #3714: 0x000000018dc6fbfc UIKit`-[UIViewController loadViewIfRequired] + 1040
frame #3715: 0x000000018dc6f7d4 UIKit`-[UIViewController view] + 28
frame #3716: 0x0000000108925fc4 PSPDFKitUI`::-[PSPDFDocumentView setupScrollViewForPageViewControllerBasedLayout](self=0x0000000109f18450, _cmd="setupScrollViewForPageViewControllerBasedLayout") at PSPDFDocumentView.mm:203
frame #3717: 0x00000001089258e4 PSPDFKitUI`::-[PSPDFDocumentView setupScrollView](self=0x0000000109f18450, _cmd="setupScrollView") at PSPDFDocumentView.mm:156
frame #3718: 0x0000000108925350 PSPDFKitUI`::-[PSPDFDocumentView initWithFrame:layout:](self=0x0000000109f18450, _cmd="initWithFrame:layout:", frame=(origin = (x = 0, y = 0), size = (width = 414, height = 736)), layout=0x000000010a1e0ff0) at PSPDFDocumentView.mm:103
frame #3719: 0x00000001089c4c58 PSPDFKitUI`::-[PSPDFDocumentViewController loadView](self=0x000000010a1e0c20, _cmd="loadView") at PSPDFDocumentViewController.mm:108
frame #3720: 0x000000018dc6f8a4 UIKit`-[UIViewController loadViewIfRequired] + 184
frame #3721: 0x000000018dc6f7d4 UIKit`-[UIViewController view] + 28
frame #3722: 0x0000000103079604 Viewer`FIRACurrentViewControllerInStack + 1008
frame #3723: 0x000000010307ab48 Viewer`-[FIRAScreenViewReporter viewControllerDidAppear:] + 516
frame #3724: 0x000000010307c0a4 Viewer`-[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 84
frame #3725: 0x000000018dc8869c UIKit`-[UIViewController _setViewAppearState:isAnimating:] + 852
frame #3726: 0x000000018dc88c08 UIKit`-[UIViewController _endAppearanceTransition:] + 228
frame #3727: 0x000000018e5d8d30 UIKit`-[UIPageViewController _childEndAppearanceTransition:] + 64
frame #3728: 0x000000018e5dd1dc UIKit`-[UIPageViewController _setViewControllers:withCurlOfType:fromLocation:direction:animated:notifyDelegate:completion:] + 1880
frame #3729: 0x000000018e5debc4 UIKit`-[UIPageViewController setViewControllers:direction:animated:completion:] + 172
frame #3730: 0x0000000108953810 PSPDFKitUI`-[PSPDFPageCurlViewController updateControllersForSpreadIndex:animated:](self=0x000000010b08a200, _cmd="updateControllersForSpreadIndex:animated:", spreadIndex=0, animated=NO) at PSPDFPageCurlViewController.m:141
frame #3731: 0x00000001089529cc PSPDFKitUI`-[PSPDFPageCurlViewController viewDidLoad](self=0x000000010b08a200, _cmd="viewDidLoad") at PSPDFPageCurlViewController.m:65
frame #3732: 0x000000018dc6fbfc UIKit`-[UIViewController loadViewIfRequired] + 1040
frame #3733: 0x000000018dc6f7d4 UIKit`-[UIViewController view] + 28
frame #3734: 0x0000000108925fc4 PSPDFKitUI`::-[PSPDFDocumentView setupScrollViewForPageViewControllerBasedLayout](self=0x000000010a1e6f80, _cmd="setupScrollViewForPageViewControllerBasedLayout") at PSPDFDocumentView.mm:203
frame #3735: 0x00000001089258e4 PSPDFKitUI`::-[PSPDFDocumentView setupScrollView](self=0x000000010a1e6f80, _cmd="setupScrollView") at PSPDFDocumentView.mm:156
frame #3736: 0x0000000108925350 PSPDFKitUI`::-[PSPDFDocumentView initWithFrame:layout:](self=0x000000010a1e6f80, _cmd="initWithFrame:layout:", frame=(origin = (x = 0, y = 0), size = (width = 414, height = 736)), layout=0x000000010a1e0ff0) at PSPDFDocumentView.mm:103
frame #3737: 0x00000001089c4c58 PSPDFKitUI`::-[PSPDFDocumentViewController loadView](self=0x000000010a1e0c20, _cmd="loadView") at PSPDFDocumentViewController.mm:108
frame #3738: 0x000000018dc6f8a4 UIKit`-[UIViewController loadViewIfRequired] + 184
frame #3739: 0x000000018dc6f7d4 UIKit`-[UIViewController view] + 28
frame #3740: 0x0000000103079604 Viewer`FIRACurrentViewControllerInStack + 1008
frame #3741: 0x000000010307ab48 Viewer`-[FIRAScreenViewReporter viewControllerDidAppear:] + 516
frame #3742: 0x000000010307c0a4 Viewer`-[UIViewController(FIRAScreenClassName) fira_viewDidAppear:] + 84
frame #3743: 0x000000018dc8869c UIKit`-[UIViewController _setViewAppearState:isAnimating:] + 852
frame #3744: 0x000000018dc88c08 UIKit`-[UIViewController _endAppearanceTransition:] + 228
frame #3745: 0x000000018e5d8d30 UIKit`-[UIPageViewController _childEndAppearanceTransition:] + 64
frame #3746: 0x000000018e5dd1dc UIKit`-[UIPageViewController _setViewControllers:withCurlOfType:fromLocation:direction:animated:notifyDelegate:completion:] + 1880
frame #3747: 0x000000018e5debc4 UIKit`-[UIPageViewController setViewControllers:direction:animated:completion:] + 172
frame #3766: 0x0000000108953810 PSPDFKitUI`-[PSPDFPageCurlViewController updateControllersForSpreadIndex:animated:](self=0x000000010a8e6e00, _cmd="updateControllersForSpreadIndex:animated:", spreadIndex=0, animated=NO) at PSPDFPageCurlViewController.m:141
frame #3767: 0x00000001089529cc PSPDFKitUI`-[PSPDFPageCurlViewController viewDidLoad](self=0x000000010a8e6e00, _cmd="viewDidLoad") at PSPDFPageCurlViewController.m:65
frame #3768: 0x000000018dc6fbfc UIKit`-[UIViewController loadViewIfRequired] + 1040
frame #3769: 0x000000018dc6f7d4 UIKit`-[UIViewController view] + 28
frame #3770: 0x0000000108925fc4 PSPDFKitUI`::-[PSPDFDocumentView setupScrollViewForPageViewControllerBasedLayout](self=0x000000010a1e1370, _cmd="setupScrollViewForPageViewControllerBasedLayout") at PSPDFDocumentView.mm:203
frame #3771: 0x00000001089258e4 PSPDFKitUI`::-[PSPDFDocumentView setupScrollView](self=0x000000010a1e1370, _cmd="setupScrollView") at PSPDFDocumentView.mm:156
frame #3772: 0x0000000108925350 PSPDFKitUI`::-[PSPDFDocumentView initWithFrame:layout:](self=0x000000010a1e1370, _cmd="initWithFrame:layout:", frame=(origin = (x = 0, y = 0), size = (width = 414, height = 736)), layout=0x000000010a1e0ff0) at PSPDFDocumentView.mm:103
* frame #3773: 0x00000001089c4c58 PSPDFKitUI`::-[PSPDFDocumentViewController loadView](self=0x000000010a1e0c20, _cmd="loadView") at PSPDFDocumentViewController.mm:108
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 21 (15 by maintainers)
FYI I forgot to tell the Analytics team to make a release this cycle, so it’ll be in the next minor point release.
Sorry all 😦
This is fixed and will be out in the next Analytics release.
This is a slightly different crash, since
-[UIViewController view]isn’t in the stack trace.Can you file a new issue and (if possible) share the implementation of
-[SWRevealViewController viewDidAppear:]?This way we can avoid spamming the folks that aren’t interested in this new crash.
Thanks!
@morganchen12 We could potentially share this under NDA… it’s a rather large project and not open source. It’s probably easier if you email me binaries and we test them on our side. Feel free to reach out to peter at pspdfkit.com for that.
Good thing is that it’s very easy to reproduce on our side. With some effort, we could probably also build a custom PSPDFKit-sample app using the just released 7.0.1.
We have a PR up internally that addresses this (171700365). I’ll let you know when it’s merged and what release it’s slated for.
Thanks for flagging!