Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in InAppMessageBannerViewController.handleBannerConstraints(size:) in 19.0.0 #421

Closed
neriusv opened this issue Jan 31, 2025 · 3 comments

Comments

@neriusv
Copy link

neriusv commented Jan 31, 2025

We're seeing a crash in InAppMessageBannerViewController.handleBannerConstraints(size:):

Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x303e8ca40 "_TtGC7SwiftUI14_UIHostingViewV17AirshipAutomation22InAppMessageBannerView_:0x10aa96400.centerX"> and <NSLayoutXAxisAnchor:0x303e8ca00 "UIWindow:0x108c0e540.centerX"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.

Stack trace:

          Fatal Exception: NSGenericException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x172b8 objc_exception_throw
2  CoreAutoLayout                 0xc454 -[NSLayoutConstraint isActive]
3  <APP>                          0x1120408 InAppMessageBannerViewController.handleBannerConstraints(size:) + 116 (InAppMessageHostingController.swift:116)
4  <APP>                          0x111f904 closure #2 in InAppMessageBannerViewController.viewDidAppear(_:) + 94 (InAppMessageHostingController.swift:94)
5  Combine                        0xaecc Subscribers.Sink.receive(_:)
6  Combine                        0xae60 protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink<A, B>
7  Combine                        0x3d940 PublishedSubject.Conduit.offer(_:)
8  Combine                        0x3d600 partial apply for closure #1 in PublishedSubject.send(_:)
9  Combine                        0x12f50 ConduitList.forEach(_:)
10 Combine                        0x12060 PublishedSubject.send(_:)
11 Combine                        0x11bd4 static Published.subscript.setter
12 <APP>                          0x11170f4 closure #1 in closure #1 in InAppMessageBannerView.banner.getter + 193 (InAppMessageBannerView.swift:193)
13 <APP>                          0x58614 thunk for @escaping @callee_guaranteed @Sendable () -> () (<compiler-generated>)

Started happening after upgrading to Airship 19.0.0.

It's a production crash, not sure how to reproduce, but it might be related to displaying several in-app messages in a row.

@rlepinski
Copy link
Contributor

What SDK version did you come from? Pretty sure this was probably introduced in this commit - c6be6d3

Could you answer a few questions, might help with reproducing:

  • Is your app UIKit or SwiftUI?
  • Do you have metrics you can share on the crash?
    • OS versions
    • Number of crashes
    • Percent of audience crashing

Ill try to to stress test it to reproduce the issue. I am pretty sure we are just trying to update constraints during some sort of transition instead of doing it on viewDidLayoutSubviews.

@rlepinski
Copy link
Contributor

I was not able to reproduce the issue in our sample, but I was able to do it with a minor code change:

    override func viewDidDisappear(_ animated: Bool) {
        // Added this line
        self.bannerConstraints.size = CGSize(width: 100, height: 100)

        super.viewDidDisappear(animated)
        subscription?.cancel()
    }

Canceling the subscription in viewWillDisappear fixes it. Ill try to get a patch out ASAP.

@rlepinski
Copy link
Contributor

Fixed in 19.0.2. Pod and SPM have been updated. XCFrameworks next week hopefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants