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

[Bug]: Conflict with Firebase Auth on the latest version #1504

Open
1 task done
abdelrahmanbonna opened this issue Oct 29, 2024 · 7 comments
Open
1 task done

[Bug]: Conflict with Firebase Auth on the latest version #1504

abdelrahmanbonna opened this issue Oct 29, 2024 · 7 comments

Comments

@abdelrahmanbonna
Copy link

abdelrahmanbonna commented Oct 29, 2024

What happened?

The Flutter app that I am working on is crashing when clicking on the notification that was received from OneSignal here is a crash report:

Translated Report (Full Report Below)

Incident Identifier: F2F818B2-2999-4543-8C26-EC4BC90F40D4
CrashReporter Key:   B6CEBAF7-912C-ABB5-B051-C8B03C941504
Hardware Model:      Mac15,7
Process:             Runner [92935]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/0E2CBEFC-2D95-4F13-9EE7-482DA5092A81/data/Containers/Bundle/Application/C123E177-282C-462E-82FA-27060D651858/Runner.app/Runner
Identifier:          com.sdpgames.landiq
Version:             1.1.3 (5)
Code Type:           X86-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [79438]
Coalition:           com.apple.CoreSimulator.SimDevice.0E2CBEFC-2D95-4F13-9EE7-482DA5092A81 [540655]
Responsible Process: SimulatorTrampoline [41696]

Date/Time:           2024-10-29 02:54:13.5811 +0300
Launch Time:         2024-10-29 02:54:11.1175 +0300
OS Version:          macOS 14.6.1 (23G93)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Termination Reason: SIGNAL 4 Illegal instruction: 4
Terminating Process: exc handler [92935]

Triggered by Thread:  0

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   <translation info unavailable>	       0x107e280e0 ???
1   FirebaseAuth                  	       0x11069868d static Auth.auth() + 637 (Auth.swift:152)
2   FirebaseAuth                  	       0x1106986b1 @objc static Auth.auth() + 33
3   Runner                        	       0x1050dd322 -[FLTFirebaseAuthPlugin application:didReceiveRemoteNotification:fetchCompletionHandler:] + 114 (FLTFirebaseAuthPlugin.m:266)
4   Flutter                       	       0x12b0a6d46 -[FlutterPluginAppLifeCycleDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] + 274
5   CoreFoundation                	       0x11bf8015c __invoking___ + 140
6   CoreFoundation                	       0x11bf7d483 -[NSInvocation invoke] + 302
7   OneSignalCore                 	       0x10ec8a52a +[SwizzlingForwarder callSelector:onObject:withArgs:] + 275
8   OneSignalNotifications        	       0x10f433119 -[OneSignalNotificationsAppDelegate oneSignalReceiveRemoteNotification:UserInfo:fetchCompletionHandler:] + 564
9   OneSignalNotifications        	       0x10f435ca8 +[OneSignalNotificationsUNUserNotificationCenter callLegacyAppDeletegateSelector:isTextReply:actionIdentifier:userText:fromPresentNotification:withCompletionHandler:] + 1376
10  OneSignalNotifications        	       0x10f4352a8 +[OneSignalNotificationsUNUserNotificationCenter forwardReceivedNotificationResponseWithCenter:didReceiveNotificationResponse:OneSignalCenter:withCompletionHandler:] + 506
11  OneSignalNotifications        	       0x10f4354a5 -[OneSignalNotificationsUNUserNotificationCenter onesignalUserNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:] + 402
12  UIKitCore                     	       0x138a9524c -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 6572
13  UIKitCore                     	       0x138a77972 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 5871
14  UIKitCore                     	       0x138a7cea3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1241
15  UIKitCore                     	       0x137d9b661 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
16  UIKitCore                     	       0x138490e45 _UIScenePerformActionsWithLifecycleActionMask + 87
17  UIKitCore                     	       0x137d9c1bf __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
18  UIKitCore                     	       0x137d9bc20 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 249
19  UIKitCore                     	       0x137d9c008 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 813
20  UIKitCore                     	       0x137d9b834 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 341
21  UIKitCore                     	       0x137da8e25 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 174
22  UIKitCore                     	       0x13833d484 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 865
23  UIKitCore                     	       0x1384af4c3 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 261
24  UIKitCore                     	       0x137da8ab4 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 347
25  UIKitCore                     	       0x137b794db __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.613 + 877
26  UIKitCore                     	       0x137b77e90 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 245
27  UIKitCore                     	       0x137b79043 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 252
28  UIKitCore                     	       0x138a7b6e3 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 672
29  UIKitCore                     	       0x138372925 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 353
30  FrontBoardServices            	       0x1351d6db4 -[FBSScene _callOutQueue_didCreateWithTransitionContext:completion:] + 406
31  FrontBoardServices            	       0x13520aa0b __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.254 + 279
32  FrontBoardServices            	       0x1351e6a78 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 213
33  FrontBoardServices            	       0x13520a705 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke + 328
34  libdispatch.dylib             	       0x1182476d8 _dispatch_client_callout + 8
35  libdispatch.dylib             	       0x11824b1e2 _dispatch_block_invoke_direct + 508
36  FrontBoardServices            	       0x13523635f __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
37  FrontBoardServices            	       0x135236239 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 188
38  FrontBoardServices            	       0x135236387 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 19
39  CoreFoundation                	       0x11bed5fb3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
40  CoreFoundation                	       0x11bed5ef5 __CFRunLoopDoSource0 + 157
41  CoreFoundation                	       0x11bed56f2 __CFRunLoopDoSources0 + 215
42  CoreFoundation                	       0x11becfe27 __CFRunLoopRun + 919
43  CoreFoundation                	       0x11becf6ad CFRunLoopRunSpecific + 557
44  GraphicsServices              	       0x1251c408f GSEventRunModal + 137
45  UIKitCore                     	       0x138a79ad1 -[UIApplication _run] + 972
46  UIKitCore                     	       0x138a7e551 UIApplicationMain + 123
47  Runner                        	       0x104fc266f main + 63 (AppDelegate.swift:8)
48  dyld_sim                      	       0x10d7513e0 start_sim + 10
49  dyld                          	       0x20547d345 start + 1909

Steps to reproduce?

1. Integrate Firebase Auth and use Apple sign-in
2. Add OneSignal as the documentation
3. fire push notification on a simulator or iPhone with IOS 18
4. open the notification while the app is not in the background

What did you expect to happen?

the notification should open the app as normal.

OneSignal iOS SDK version

Release 5.2.6

iOS version

17, 16, 15, 14

Specific iOS version

IOS 18

Relevant log output

My environment is as follows:
  Mac os: 14.6.1 (23G93)
  Xcode: 15.4 (15F31d)
  Flutter SDK: 3.22.3

And I am using Flutter so my current packages are:
  onesignal_flutter: ^5.2.6
  firebase_auth: ^5.3.1
  firebase_app_check: ^0.3.1+4
  cloud_firestore: ^5.4.4
  cloud_functions: ^5.1.3
  firebase_core: ^3.6.0
  firebase_storage: ^12.3.4
  firebase_crashlytics: ^4.1.3
  firebase_remote_config: ^5.1.3
  firebase_analytics: ^11.3.3
  firebase_performance: ^0.10.0+8

Code of Conduct

  • I agree to follow this project's Code of Conduct
@abdelrahmanbonna
Copy link
Author

@jkasten2 I had the same crash and here is a full report.

@nan-li
Copy link
Contributor

nan-li commented Oct 29, 2024

Hi @abdelrahmanbonna thanks for reporting the stacktrace. I see your reproduction step "fire push notification on a simulator or iPhone with IOS 18".

Does this happen 100% of the time or only sometimes? Additionally, does this affect iOS versions under 18?

@abdelrahmanbonna
Copy link
Author

It happens 100% of the time when the app is not opened at all. Also, I tried it on simulators with IOS 17.5, and I had the same issue there.

@marcmagedbakysa
Copy link

any updates on this @nan-li ?

@nan-li
Copy link
Contributor

nan-li commented Oct 30, 2024

@marcmagedbakysa are you experiencing the exact same consistent crash as well?
If so, can you share your stacktrace, which OneSignal SDK you are using and the version, as well as the firebase auth version as well.

@fanwgwg
Copy link

fanwgwg commented Nov 14, 2024

+1 See the exact same issue

OneSignal 5.2.6 + Firebase 11.4.0

@ThomasEcalle
Copy link

Hi!

I did have the exact same issue between OneSignal & Firebase on my Flutter application.

I know this is the iOS SDK repository, and maybe the issue is different, but I found a solution on my side and if it is the same issue then it has nothing to do with OneSignal, so I wanted to share it with you because I struggled a lot to find the reason and it may help someone.

1. Probably a Firebase issue, not OneSignal

I believe this issue is not really related to OneSignal, but to Firebase and some weird behavior on app cold start.

When you click on a notification, it should open the app, causing a "cold start" and, on my side, Firebase crashed every time, having issues doing these kind of "cold start".

The issue was not really OneSignal, even if it is because of the notification that you see the issue.

2. Firebase issue explanation

Do you use custom schemes in your app?

On my side, I am using Dev, Preprod and Prod schemes.

When you launch the app on an iOS device, even if firebase works well, is there a possibility that you would have, in the first logs written on XCode, something like: could not find a valid GoogleService-Info.plist?

The issue on my side was that I had a directory with my schemes and my GoogleService-info.plist inside like this:

Image

BUT Firebase need this file to be at the root of your project directory to find it!

I don't know about the Firebase configuration on native iOS but, on Flutter, we have some tools to help us (flutterfire)

The issue is that these tools are not very convenient when dealing with schemes and the Build Phase script that the tool generates... simply is not enough when dealing with flavors!

3. How to fix it

The main solution is to create (or update, is you already have one) a Build Phases script to put the good GoogleService-info.plist at the build time.

1. So you have to go to the Build Phases tab:

Image

2. Then you create a script (you can name it as you want) with this code:

environment="default"

# Regex to extract the scheme name from the Build Configuration
# We have named our Build Configurations as Debug-dev, Debug-prod etc.
# Here, dev and prod are the scheme names. This kind of naming is required by Flutter for flavors to work.
# We are using the $CONFIGURATION variable available in the XCode build environment to extract 
# the environment (or flavor)
# For eg.
# If CONFIGURATION="Debug-prod", then environment will get set to "prod".
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi

echo $environment

# Name and path of the resource we're copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/flavors/${environment}/${GOOGLESERVICE_INFO_PLIST}

# Make sure GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}"
if [ ! -f $GOOGLESERVICE_INFO_FILE ]
then
echo "No GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1
fi

# Get a reference to the destination location for the GoogleService-Info.plist
# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"

# Copy over the prod GoogleService-Info.plist for Release builds
cp "${GOOGLESERVICE_INFO_FILE}" "${PLIST_DESTINATION}"

Note that you have to update it with the good paths related to your direcoties naming (my schemes are in a "flavors" directory but maybe yours are differents).

Explanation:

This script simply take the configuration, go to the corresponding folder and "copy and paste" the right file at the build time.

I have seen a lot of similar scripts for the same issue but THIS ONE is the one which worked on my side.

3. This part is probably only for Flutter apps, maybe not native iOS one

On Flutter apps, it seems that the setup documentation is missing an important step which is to "configure" the Firebase app in AppDelegate.

I think this is not important as the app still works, but it seems to be important on "cold starts" like the one causing by notifications.

Her is what changes in a Flutter app (adding 2 lines):

import Flutter
import UIKit
import Firebase. // <- Add this line

@main
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    FirebaseApp.configure() // <- And add this line
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

4. That is all!

Once again, so sorry if this not fix your issue, maybe that is a complete other issue sur to iOS SDK but I do think that it is in fact the same problem in every project with Firebase, OneSignal being jsute the reason we see the problem.

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

5 participants