firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.64k stars 1.48k forks source link

Crash in FirebaseMessaging #9009

Closed sentrashi closed 2 years ago

sentrashi commented 2 years ago

Step 0: Are you in the right place?

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Crashed: com.apple.main-thread 0 libswiftCore.dylib 0x204ba0 specialized assertionFailure(:_:file:line:flags:) + 360 1 libswiftCore.dylib 0x282bc assertionFailure(:_:file:line:flags:) + 32 2 libswiftFoundation.dylib 0xa3d10 @objc static NSObject.old_unswizzled_keyPathsForValuesAffectingValue(forKey:) + 84 3 libswiftFoundation.dylib 0xa436c static KVOKeyPathBridgeMachinery.keyPathsForValuesAffectingValue(forKey:) + 272 4 libswiftFoundation.dylib 0xa4864 @objc static KVOKeyPathBridgeMachinery.keyPathsForValuesAffectingValue(forKey:) + 88 5 Foundation 0x9d58 -[NSKeyValueUnnestedProperty _givenPropertiesBeingInitialized:getAffectingProperties:] + 196 6 Foundation 0x9a5c -[NSKeyValueUnnestedProperty _initWithContainerClass:key:propertiesBeingInitialized:] + 148 7 Foundation 0xfcb9c NSKeyValuePropertyForIsaAndKeyPathInner.llvm.8205242823520915647 + 288 8 Foundation 0xfd374 NSKeyValuePropertyForIsaAndKeyPath + 140 9 Foundation 0xfbbe0 _NSKeyValueCreateImplicitObservationInfo + 224 10 Foundation 0x1d174 -[NSOperation init] + 372 11 FirebaseMessaging 0x21218 -[FIRMessagingTokenOperation initWithAction:forAuthorizedEntity:scope:options:checkinPreferences:instanceID:] + 55 (FIRMessagingTokenOperation.m:55) 12 FirebaseMessaging 0x1bce4 -[FIRMessagingTokenFetchOperation initWithAuthorizedEntity:scope:options:checkinPreferences:instanceID:] + 52 (FIRMessagingTokenFetchOperation.m:52) 13 FirebaseMessaging 0x1ffe4 -[FIRMessagingTokenManager createFetchOperationWithAuthorizedEntity:scope:options:instanceID:] + 534 (FIRMessagingTokenManager.m:534) 14 FirebaseMessaging 0x1eb08 -[FIRMessagingTokenManager fetchNewTokenWithAuthorizedEntity:scope:instanceID:options:handler:] + 267 (FIRMessagingTokenManager.m:267) 15 FirebaseMessaging 0x1e960 __76-[FIRMessagingTokenManager tokenWithAuthorizedEntity:scope:options:handler:]_block_invoke_2.102 + 248 (FIRMessagingTokenManager.m:248) 16 FirebaseInstallations 0x7c80 49-[FIRInstallations installationIDWithCompletion:]_block_invoke + 210 (FIRInstallations.m:210) 17 FBLPromises 0xdae0 __56-[FBLPromise chainOnQueue:chainedFulfill:chainedReject:]_block_invoke.48 + 273 (FBLPromise.m:273) 18 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release + 24 19 libdispatch.dylib 0x607d4 _dispatch_client_callout + 16 20 libdispatch.dylib 0xde50 _dispatch_main_queue_callback_4CF$VARIANT$mp + 628 21 CoreFoundation 0xaab20 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 22 CoreFoundation 0xa5a58 __CFRunLoopRun + 1924 23 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 24 GraphicsServices 0xa79c GSEventRunModal + 104 25 UIKitCore 0x8bcc38 UIApplicationMain + 212 26 Markirovka 0x153c0 main + 27 (AppDelegate.swift:27) 27 libdyld.dylib 0x18e0 start + 4

Device Model:iPhone X Orientation: Portrait RAM free: 55.64 MB Disk free: 2.43 GB Operating System Version:15.1.0 Orientation: Portrait Jailbroken:No Crash Date:Nov 23, 2021, 10:14:47 PM App version:4.19.0 (119)

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.

Relevant Code:

// TODO(you): code here to reproduce the problem
rizafran commented 2 years ago

Thanks for filing this, @sentrashi. To have a better understanding of what's happening here, could you provide an MCVE or detailed steps in reproducing this issue?

google-oss-bot commented 2 years ago

Hey @sentrashi. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

sentrashi commented 2 years ago

Sorry, can't provide steps or MCVE - Its very rare crash.

thanhdevapp commented 2 years ago

IPhone X Sign with Email and Password return nil user, each other IPhone version work good

rizafran commented 2 years ago

Hi @sentrashi, we can't investigate the issue further without enough information. Could you provide the detailed steps in reproducing the issue? Thanks.

sentrashi commented 2 years ago

Hi! I also have few crashes in AppsFlyer, and they think they're related to Firebase. Here is the message from them

Hi,

After checking with our R&D team, it seems this issue is not on our side, it might be an issue with one of the third-party libraries you mentioned, as the error starts from [NSOperation init]​ when we simply use [super init] and it leads to NSObject.__old_unswizzled_keyPathsForValuesAffectingValue​. We have found a similar issue to yours in the issues of firebase-ios-SDK, which is related to FirebaseMessaging that you use, the initial stack trace looks identical to yours.

It looks like the issue might stem from Firebase and I can only suggest you contact their support or open an issue with them on their GitHub page if this issue keeps happening.

If you have any additional questions - I'll be happy to answer them. Best Regards, Dima | Mobile/SDK Support Engineer

Here is their crash:

Recently got following crash Library

Crash

Crashed: com.appsflyer.serial EXC_BREAKPOINT 0x00000001e63deba0 0 libswiftCore.dylib specialized assertionFailure(:_:file:line:flags:) + 360 1 libswiftCore.dylib assertionFailure(:_:file:line:flags:) + 32 2 libswiftFoundation.dylib @objc static NSObject.old_unswizzled_keyPathsForValuesAffectingValue(forKey:) + 84 3 libswiftFoundation.dylib static KVOKeyPathBridgeMachinery.keyPathsForValuesAffectingValue(forKey:) + 272 4 libswiftFoundation.dylib @objc static __KVOKeyPathBridgeMachinery.keyPathsForValuesAffectingValue(forKey:) + 88 5 Foundation -[NSKeyValueUnnestedProperty _givenPropertiesBeingInitialized:getAffectingProperties:] + 196 6 Foundation -[NSKeyValueUnnestedProperty _initWithContainerClass:key:propertiesBeingInitialized:] + 148 7 Foundation NSKeyValuePropertyForIsaAndKeyPathInner.llvm.8205242823520915647 + 288 8 Foundation NSKeyValuePropertyForIsaAndKeyPath + 140 9 Foundation _NSKeyValueCreateImplicitObservationInfo + 224 10 Foundation -[NSOperation init] + 372 11 Markirovka -[AFSDKOperation initWithOperationId:userObject:executionBlock:] + 108 12 Markirovka +[AFSDKOperation Id:userObject:executionBlock:] + 100 13 Markirovka 37-[AppsFlyerLib willResolveSKRules:]_block_invoke + 1132 14 libdispatch.dylib _dispatch_client_callout + 16 15 libdispatch.dylib _dispatch_once_callout + 28 16 Markirovka -[AppsFlyerLib willResolveSKRules:] + 400 17 Markirovka 30-[AppsFlyerLib setAppleAppID:]_block_invoke + 40 18 libdispatch.dylib _dispatch_call_block_and_release + 24 19 libdispatch.dylib _dispatch_client_callout + 16 20 libdispatch.dylib _dispatch_lane_serial_drain$VARIANT$mp + 592 21 libdispatch.dylib _dispatch_lane_invoke$VARIANT$mp + 428 22 libdispatch.dylib _dispatch_workloop_worker_thread + 596 23 libsystem_pthread.dylib _pthread_wqthread + 304 24 libsystem_pthread.dylib start_wqthread + 4

Crash descritpion crash_info_entry_0 Fatal error: Should never be reached: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang_overlay_Foundation_Device/swiftlang-1001.2.63.13/swift/stdlib/public/SDK/Foundation/NSObject.swift, line 46

Event summary iOS 12.5.5 iPhone 5s Nov 23, 2021, 2:11:18 PM

And here is all KVO info from app

What was called

Pods->GooleUtilities [[GULAppDelegateSwizzler sharedApplication] addObserver:self forKeyPath:kGULAppDelegateKeyPath options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil]; _isObserving = YES;

firebasemessaging [userNotificationCenter addObserver:self forKeyPath:NSStringFromSelector(@selector(delegate)) options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:UserNotificationObserverContext];

svgkit [selfaddObserver:selfforKeyPath:@"DOMTree.viewport"options:NSKeyValueObservingOptionOldcontext:nil];

our code

00x00007fff207a70e7 in -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] ()

10x00007fff243ffdd9 in -[_UIHyperInteractor _setInternalRegion:] ()

20x00007fff243ffcfe in -[_UIHyperInteractor _setRegion:] ()

30x00007fff247f4e0e in -[_UIPageControlInteractor initWithMaximumDistance:] ()

40x00007fff25312eb6 in -[_UIInteractivePageControlVisualProvider prepare] ()

50x00007fff248a65df in -[UIPageControl initWithCoder:] ()

60x000000010180a23b in CustomPageControl.init(coder:) ()

70x000000010180a2f8 in @objc CustomPageControl.init(coder:) ()

80x00007fff24bb35f2 in -[UIClassSwapper initWithCoder:] ()

90x00007fff2427fd3f in UINibDecoderDecodeObjectForValue ()

100x00007fff24280005 in UINibDecoderDecodeObjectForValue ()

110x00007fff2427fa73 in -[UINibDecoder decodeObjectForKey:] ()

120x00007fff25589525 in -[UIView initWithCoder:] ()

130x00007fff251e67ae in -[UITableViewCellContentView initWithCoder:] ()

140x00007fff2427fd3f in UINibDecoderDecodeObjectForValue ()

150x00007fff24280005 in UINibDecoderDecodeObjectForValue ()

160x00007fff2427fa73 in -[UINibDecoder decodeObjectForKey:] ()

170x00007fff25589525 in -[UIView initWithCoder:] ()

180x00007fff251d0228 in -[UITableViewCell initWithCoder:] ()

190x00000001012d25da in DrugsAvtivityTableViewCell.init(coder:) ()

200x00000001012d2678 in @objc DrugsAvtivityTableViewCell.init(coder:) ()

210x00007fff24bb35f2 in -[UIClassSwapper initWithCoder:] ()

220x00007fff2427fd3f in UINibDecoderDecodeObjectForValue ()

230x00007fff2427fa73 in -[UINibDecoder decodeObjectForKey:] ()

240x00007fff24bb7ae0 in -[UIRuntimeConnection initWithCoder:] ()

250x00007fff2427fd3f in UINibDecoderDecodeObjectForValue ()

260x00007fff24280005 in UINibDecoderDecodeObjectForValue ()

270x00007fff2427fa73 in -[UINibDecoder decodeObjectForKey:] ()

280x00007fff24bb27a0 in -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] ()

290x00007fff24bb5321 in -[UINib instantiateWithOwner:options:] ()

300x00007fff25249d4a in -[UITableView _dequeueReusableViewOfType:withIdentifier:] ()

310x00007fff2524a122 in -[UITableView dequeueReusableCellWithIdentifier:] ()

320x0000000101d4d4ae in UITableView.dequeue<τ_00>(:) at /Users/e.neterov/git/mobile_iOS/Markirovka/Markirovka/Extensions/UITableViewCell.swift:28

330x000000010175927d in MainScreenViewManager.tableView(_:cellForRowAt:) at /Users/e.neterov/git/mobile_iOS/Markirovka/Markirovka/UI/Scenarios/Main/Modules/MainScreen/Modules/Initial/ViewManagers/MainScreenViewManager.swift:156

and code for it extensionUITableView { func register( cell: Cell.Type, forCellReuseIdentifier reuseIdentifier: String = Cell.identifier ) where Cell: UITableViewCell { register(cell, forCellReuseIdentifier: reuseIdentifier) }

func dequeue<Cell>(_ reusableCell: Cell.Type) -> Cell? where Cell: UITableViewCell {
    returndequeueReusableCell(withIdentifier: reusableCell.identifier) as? Cell
}

What wasn’t called, but present in pods

GTMSessionFetcher

amplitude (void) addObservers { NSNotificationCenter *center = [NSNotificationCenterdefaultCenter]; [center addObserver:self selector:@selector(enterForeground) name:UIApplicationWillEnterForegroundNotification object:nil]; [center addObserver:self selector:@selector(enterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; }

firebase messaging [center addObserver:self selector:@selector(defaultFCMTokenWasRefreshed:) name:kFIRMessagingRegistrationTokenRefreshNotification object:nil];

google toolboxForMac [userDefaults_addObserver:self forKeyPath:kVerboseLoggingKey options:NSKeyValueObservingOptionInitial context:nil];

googleUtilities->GULSceneDelegateSwizzzler [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSceneWillConnectToNotification:) name:UISceneWillConnectNotification object:nil]; }

GMTSessionfetcher

if GTMSESSION_RECONNECT_BACKGROUND_SESSIONS_ON_LAUNCH && TARGET_OS_IPHONE

NSNotificationCenter *nc = [NSNotificationCenterdefaultCenter]; [nc addObserver:self selector:@selector(reconnectFetchersForBackgroundSessionsOnAppLaunch:) name:UIApplicationDidFinishLaunchingNotification object:nil];

elif GTMSESSION_RECONNECT_BACKGROUND_SESSIONS_ON_LAUNCH && TARGET_OS_OSX

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(reconnectFetchersForBackgroundSessionsOnAppLaunch:) name:NSApplicationDidFinishLaunchingNotification object:nil];

else

mindbox internalfuncsetupObservers() { didEnterBackgroundApplication = NotificationCenter.default.addObserver( forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { [weakself] (_) in

        self?.invalidate()
    }

    didBecomeActiveApplication = NotificationCenter.default.addObserver(
        forName: UIApplication.didBecomeActiveNotification,
        object: nil,
        queue: nil) { [weakself] (_) in

        if self?.timer == nil {

            self?.setupTimer()
        }
    }

}

Realm, RealmSwift a lot of them

SDWebImage [config addObserver:selfforKeyPath:NSStringFromSelector(@selector(maxMemoryCost)) options:0context:SDMemoryCacheContext]; [config addObserver:selfforKeyPath:NSStringFromSelector(@selector(maxMemoryCount)) options:0context:SDMemoryCacheContext];

SBGKit [_imageaddObserver:selfforKeyPath:@"size"options:NSKeyValueObservingOptionNewcontext:(bridgevoid _Nullable)(internalContextPointerBecauseApplesDemandsIt)]; [selfaddObserver:selfforKeyPath:@"image"options:NSKeyValueObservingOptionNewcontext:(__bridgevoid _Nullable)(internalContextPointerBecauseApplesDemandsIt)]; [selfaddObserver:selfforKeyPath:@"tileRatio"options:NSKeyValueObservingOptionNewcontext:(bridgevoid _Nullable)(internalContextPointerBecauseApplesDemandsIt)]; [selfaddObserver:selfforKeyPath:@"showBorder"options:NSKeyValueObservingOptionNewcontext:(__bridgevoid _Nullable)(internalContextPointerBecauseApplesDemandsIt)]; [selfaddObserver:selfforKeyPath:@"layer"options:NSKeyValueObservingOptionNewcontext:(__bridgevoid _Nullable)(internalContextPointerBecauseApplesDemandsIt)]; [self.layeraddObserver:selfforKeyPath:@"transform"options:NSKeyValueObservingOptionNewcontext:(__bridgevoid _Nullable)(internalContextPointerBecauseApplesDemandsIt)]; [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(didReceiveMemoryWarningOrBackgroundNotification:) name:UIApplicationDidReceiveMemoryWarningNotificationobject:nil]; [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(didReceiveMemoryWarningOrBackgroundNotification:) name:UIApplicationDidEnterBackgroundNotificationobject:nil]; [selfaddObserver:selfforKeyPath:@"DOMTree.viewport"options:NSKeyValueObservingOptionOldcontext:nil];

our code scrollView?.addObserver(self, forKeyPath: "contentOffset", options: [.new, .old], context: nil) windowAppearanceObserver = NotificationCenter.default.addObserver( forName: UIWindow.didBecomeKeyNotification, object: nil, queue: .main) { [weak ...

rizafran commented 2 years ago

Thanks for the info, @sentrashi. We'll try and investigate this, but for the meantime, can you try using our latest SDK version (8.10.0) to check if that resolves the issue?

google-oss-bot commented 2 years ago

Hey @sentrashi. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@sentrashi if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.