NotificationBanner
NotificationBanner copied to clipboard
Crashing all the time
Can you please explain why this library is crashing all the time to me? Here is the code to run the banner:
func showBanner(text: String) {
let banner = NotificationBanner(title: text, style: .info)
banner.autoDismiss = false
banner.applyStyling(titleFont: .custom(type: .regular, size: 14), titleColor: .white, titleTextAlign: .center)
banner.backgroundColor = .init(red: 75, green: 75, blue: 75)
banner.show()
}
Here is the crash:
2020-12-17 12:46:06.465576+0100 APP[836:108657] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x28133a1c0 UIView:0x105b10580.width == - 16 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x28133a1c0 UIView:0x105b10580.width == - 16 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file NotificationBannerSwift/BaseNotificationBanner.swift, line 530
2020-12-17 12:46:08.752985+0100 APP[836:108657] Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file NotificationBannerSwift/BaseNotificationBanner.swift, line 530
Hi @borut-t, if you look carefully at the crash, it says it is crashing on line 530 inside BaseNotificationBanner. That indicates that the bannerPosition is for some reason nil. You will need to provide me with an example of reproducible steps or investigate a little further your self and report back if we want to get to the bottom of this! 😄
Thanks!
I have a typical tabBar + navBar setup and it's crashing on that setup. Nothing special about it. Unfortunately, I don't have time to dig into this issue.
If I may suggest you to replace those IUOs with optionals instead to avoid crashing. I would rather see app not presenting a banner than crashing for those "edge" cases.
Pretty much same issue here... But it's in crash report. While testing, can't reproduce the crash.
I ended up making startFrame and endFrame optional.
class BannerPositionFrame: NSObject {
private(set) var startFrame: CGRect?
private(set) var endFrame: CGRect?
Hope this will fix the crash.
Hi @Daltron,
Some of my users are also facing this crash, the crash takes place according to my Firebase report on. BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 380
and it is a EXC_BREAKPOINT crash.
And the crash started taking place after updating to pod version 3.0.6. I haven't been able to reproduce it on my end.
Looks like a race condition. When i run via xcode, everything works fine. When i run my app without xcode (still compiled with Debug options) it crashes.
let banner = NotificationBanner(title: "XXX", style: .success, colors: BannerColors.shared)
banner.applyStyling(titleFont: Style.text.title.font, titleColor: Style.color.textColor)
banner.show(bannerPosition: .bottom, on: self)
Edit: no crash when i skip the apply styling function
I was able to resolve my issue using this piece of code. https://github.com/Daltron/NotificationBanner/issues/307#issuecomment-690249992
Thanks @aman-at-appinventiv but it does not help in my case.
In file NotificationBanner.swift Line 220:
if titleFont != nil || subtitleFont != nil {
updateBannerHeight()
}
updateBannerHeight() calls onOrientationChanged() in BaseNotificationBanner and there bannerPosition is accessed before it was set causing Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
The same occurs here on 3.0.6. This wasn't an issue in ~~3.0.4.~~ 3.0.2 (Cocoapods)
The relevant stack trace:
Crashed: com.apple.main-thread
0x105871868 BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 380 (BaseNotificationBanner.swift:380)
0x10587aa6c NotificationBannerQueue.addBanner(_:bannerPosition:queuePosition:) + 69 (NotificationBannerQueue.swift:69)
0x105870f6c BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 374 (BaseNotificationBanner.swift:374)
0x105875468 FloatingNotificationBanner.show(queuePosition:bannerPosition:queue:on:edgeInsets:cornerRadius:shadowColor:shadowOpacity:shadowBlurRadius:shadowCornerRadius:shadowOffset:shadowEdgeInsets:) + 332 (BaseNotificationBanner.swift:332)
Same here, if I display a banner on app start (but after setting root view controller), I get this error:
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file NotificationBannerSwift/BaseNotificationBanner.swift, line 380
2021-03-31 15:22:08.872794+0200 Quokkie[6737:6035016] Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file NotificationBannerSwift/BaseNotificationBanner.swift, line 380
And as I saw comments on other threads: I do everything on the main thread.
I'm also experiencing the same issue. Is there a way to fix this?
NotificationBannerQueue.addBanner(_:bannerPosition:queuePosition:) + 78 (NotificationBannerQueue.swift:78)
BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 374 (BaseNotificationBanner.swift:374)
BaseNotificationBanner.show(queuePosition:bannerPosition:queue:on:) + 337 (BaseNotificationBanner.swift:337)
experiencing same issue
1 NotificationBannerSwift 0x000000010526487c BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 51324 (BaseNotificationBanner.swift:373)
2 NotificationBannerSwift 0x000000010526e8bc NotificationBannerQueue.addBanner(_:bannerPosition:queuePosition:) + 92348 (NotificationBannerQueue.swift:71)
3 NotificationBannerSwift 0x00000001052648bc BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 51388 (BaseNotificationBanner.swift:374)
4 NotificationBannerSwift 0x00000001052645bc BaseNotificationBanner.show(queuePosition:bannerPosition:queue:on:) + 50620 (BaseNotificationBanner.swift:337)`
I am also experiencing the same issue:
NotificationBannerQueue.swift - Line 78
NotificationBannerQueue.addBanner(_:bannerPosition:queuePosition:) + 78
BaseNotificationBanner.swift - Line 374
BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 374
BaseNotificationBanner.swift - Line 337
BaseNotificationBanner.show(queuePosition:bannerPosition:queue:on:) + 337
Banner.swift - Line 81
Banner.show(title:subtitle:type:presentType:onTap:) + 81
The same occurs here on 3.0.6. This wasn't an issue in ~3.0.4.~ 3.0.2 (Cocoapods)
The relevant stack trace:
Crashed: com.apple.main-thread 0x105871868 BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 380 (BaseNotificationBanner.swift:380) 0x10587aa6c NotificationBannerQueue.addBanner(_:bannerPosition:queuePosition:) + 69 (NotificationBannerQueue.swift:69) 0x105870f6c BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 374 (BaseNotificationBanner.swift:374) 0x105875468 FloatingNotificationBanner.show(queuePosition:bannerPosition:queue:on:edgeInsets:cornerRadius:shadowColor:shadowOpacity:shadowBlurRadius:shadowCornerRadius:shadowOffset:shadowEdgeInsets:) + 332 (BaseNotificationBanner.swift:332)
I am facing the same issue using v3.0.0. Is this issue not exists in v3.0.2? I will take it as a workaround before there is a patch version if so...
Facing the same issue
Crashed: com.apple.main-thread
0 0x10356137c BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 4323496828 (BaseNotificationBanner.swift:4323496828)
1 0x10356a6d8 NotificationBannerQueue.addBanner(_:bannerPosition:queuePosition:) + 67 (NotificationBannerQueue.swift:67)
2 0x103560b7c BaseNotificationBanner.show(placeOnQueue:queuePosition:bannerPosition:) + 355 (BaseNotificationBanner.swift:355)
3 0x103564b84 FloatingNotificationBanner.show(queuePosition:bannerPosition:queue:on:edgeInsets:cornerRadius:shadowColor:shadowOpacity:shadowBlurRadius:shadowCornerRadius:shadowOffset:shadowEdgeInsets:) + 324 (BaseNotificationBanner.swift:324)
Started using the library with version 3.0.6, went back to 3.0.2 and it keeps happening. Already doing everything on the main thread.
I have the same too, I do everything on the main thread, and these crashes are about 90% of my total app crashes... One important thing to note: Crashlytics indicates that 100% of crashes happen in the background.
Is this library abandoned ? @Daltron
Looks like there is fix for this issue in this pull request for 10 days already, but it's not merged yet.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
As far as I can tell, this is still an issue.
A new version has been released. This issue should be fixed now. Update to the latest version and check if similar crashes occur in latest version.
After a few weeks of using this in production, I can confirm that no more crashes have occurred.
I'm on version 3.1.0 and still getting the crash whenever try to show banner.
I'm on version 3.1.0 and still getting the crash whenever try to show banner.
I had the same issue. In my case, I tried to show banner too early (before view controller fully loaded), see if the same situation applies to you too. @ankitpoplify
Looks like a race condition. When i run via xcode, everything works fine. When i run my app without xcode (still compiled with Debug options) it crashes.
let banner = NotificationBanner(title: "XXX", style: .success, colors: BannerColors.shared) banner.applyStyling(titleFont: Style.text.title.font, titleColor: Style.color.textColor) banner.show(bannerPosition: .bottom, on: self)Edit: no crash when i skip the apply styling function
We can access some properties for decoration, that's exactly what I did