firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.63k stars 3.95k forks source link

🐛 [dynamic-link] App Crash on startup for iOS >= 16.6 #11385

Closed marceloalvestrela closed 11 months ago

marceloalvestrela commented 1 year ago

Bug report

Describe the bug My app is crashing on startup with Dynamiclink lib. I've checked this crashes occurs from iOS >= 16.6. In versions before 16.6 it's works well.

Crash log

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x4320 objc_release_x0 + 16
1  libobjc.A.dylib                0x4320 objc_release + 16
2  FirebaseDynamicLinks           0xb678 __55-[FIRDLJavaScriptExecutor webView:didFinishNavigation:]_block_invoke_2 + 104
3  WebKit                         0x655654 <redacted> + 332
4  WebKit                         0x65519c <redacted> + 88
5  WebKit                         0x58b8c8 <redacted> + 64
6  WebKit                         0xa9ef5c <redacted> + 712
7  WebKit                         0xa9f2c8 <redacted> + 292
8  JavaScriptCore                 0x4f6a4 WTF::RunLoop::performWork() + 204
9  JavaScriptCore                 0x50574 WTF::RunLoop::performWork(void*) + 36
10 CoreFoundation                 0xd1800 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
11 CoreFoundation                 0xdc930 __CFRunLoopDoSource0 + 176
12 CoreFoundation                 0x6a68c __CFRunLoopDoSources0 + 244
13 CoreFoundation                 0x7ca24 __CFRunLoopRun + 828
14 CoreFoundation                 0x816c0 CFRunLoopRunSpecific + 600
15 GraphicsServices               0x1224 GSEventRunModal + 164
16 UIKitCore                      0x38ed2c -[UIApplication _run] + 888
17 UIKitCore                      0x38e990 UIApplicationMain + 340
18 Runner                         0x720c main + 5 (AppDelegate.swift:5)
19 ???                            0x1c0bb04f8 (Missing)

Steps to reproduce

Steps to reproduce the behavior:

  1. Add and config Dynamic link lib into a project
  2. Build a release iOS app
  3. Run on physical device

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [✓] Flutter (Channel stable, 3.10.6, on macOS 13.5 22G74 darwin-arm64, locale en-BR) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.0) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] IntelliJ IDEA Ultimate Edition (version 2023.1) [✓] Connected device (4 available) [✓] Network resources ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 3.0.6 Flutter SDK 3.10.6 marketplace_app 0.0.0 dev dependencies: - melos 3.1.0 [ansi_styles args cli_launcher cli_util collection conventional_commit file glob graphs http meta mustache_template path platform pool prompts pub_semver pub_updater pubspec string_scanner yaml yaml_edit] transitive dependencies: - ansi_styles 0.3.2+1 - args 2.4.0 - async 2.11.0 [collection meta] - charcode 1.3.1 - cli_launcher 0.3.1 [path yaml] - cli_util 0.3.5 [meta path] - collection 1.17.1 - conventional_commit 0.6.0+1 - file 6.1.4 [meta path] - glob 2.1.1 [async collection file path string_scanner] - graphs 2.2.0 [collection] - http 0.13.5 [async http_parser meta path] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - io 1.0.4 [meta path string_scanner] - json_annotation 4.8.0 [meta] - matcher 0.12.14 [meta stack_trace] - meta 1.9.0 - mustache_template 2.0.0 - path 1.8.3 - platform 3.1.0 - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - prompts 2.0.0 [charcode io] - pub_semver 2.1.3 [collection meta] - pub_updater 0.2.4 [http json_annotation process] - pubspec 2.3.0 [path pub_semver yaml uri] - quiver 3.2.1 [matcher] - source_span 1.9.1 [collection path term_glyph] - stack_trace 1.11.0 [path] - string_scanner 1.2.0 [source_span] - term_glyph 1.2.1 - typed_data 1.3.1 [collection] - uri 1.0.0 [matcher quiver] - yaml 3.1.1 [collection source_span string_scanner] - yaml_edit 2.1.0 [collection meta source_span yaml] ```

darshankawar commented 1 year ago

@marceloalvestrela Can you confirm if you are not calling the dynamic link sdk before the firebase SDK init ? ie, check if you are making use of await properly.

marceloalvestrela commented 1 year ago

Yes, I'm calling first Firebase init. I've tested First Firebase then Dynamic. As I sad before, on iOS version before 16.6 it is working well.

darshankawar commented 1 year ago

Thanks for the update @marceloalvestrela If you run through Xcode and when it crashes, do you get any log in it in the form of underlying error or which says the operation couldn't be completed ?

Also, although I don't have iOS 16+ setup to verify this, but can you run the plugin example on same iOS version and see if using it, do you still get the same crash or not ?

google-oss-bot commented 1 year ago

Hey @marceloalvestrela. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 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!

marceloalvestrela commented 1 year ago

Thanks for the update @marceloalvestrela If you run through Xcode and when it crashes, do you get any log in it in the form of underlying error or which says the operation couldn't be completed ?

Also, although I don't have iOS 16+ setup to verify this, but can you run the plugin example on same iOS version and see if using it, do you still get the same crash or not ?

Hi @darshankawar , I cant reproduce this issue running from XCode , only if I test from a Product Build release from TestFlight. But to run the plugin example, I will need to configure its for production release, because only in this scenario I reproduce this problem.

darshankawar commented 1 year ago

We tried by running the plugin example on iOS 16.6 in release mode with which we didn't observe the reported crash. I guess per OP, the app needs to be released atleast to TestFlight and then install it on iOS 16.6 version. Based on the report, keeping it open for team's attention.

/cc @russellwheatley

davefaliskie commented 1 year ago

I'm experiencing a similar issue, The app doesn't fully crash but I do get an error logged in Sentry App Hanging: App hanging for at least 2000 ms. and then in the details it looks very similar to the original post with FirebaseDynamicLinks triggering this long wait.

For me this is happening only on iOS when I download the app via the app store through a dynamic link. But also for me this isn't an actual crash the app does seem to function as expected. Maybe this is unrelated but posting it incase it helps find a fix.

UPDATE: I was able to get a better error logged by adding some debug symbols. it seems this issue (at least the one I'm seeing) is related to FIRDLDefaultRetrievalProcessV2 retrievePasteboardContents Updated logs below.

here's all I can get from Sentry

Details libsystem_kernel 0x1f5822c20 semaphore_wait_trap libdispatch 0x1bdd34444 _dispatch_sema4_wait libdispatch 0x1bdd34af8 _dispatch_semaphore_wait_slow UIKitCore 0x1b959a514 _coerceItemToClass UIKitCore 0x1b959a624 -[_UIConcretePasteboard string] FirebaseDynamicLinks0x104c5ae30 -[FIRDLDefaultRetrievalProcessV2 retrievePasteboardContents] (FIRDLDefaultRetrievalProcessV2.m:212) FirebaseDynamicLinks0x104c5acb0 -[FIRDLDefaultRetrievalProcessV2 uniqueMatchLinkToCheck] (FIRDLDefaultRetrievalProcessV2.m:177) FirebaseDynamicLinks0x104c5a8e4 -[FIRDLDefaultRetrievalProcessV2 retrievePendingDynamicLinkInternal] (FIRDLDefaultRetrievalProcessV2.m:112) FirebaseDynamicLinks0x104c5b2f8 -[FIRDLJavaScriptExecutor handleExecutionResult:] (FIRDLJavaScriptExecutor.m:101) FirebaseDynamicLinks0x104c5b668 __55-[FIRDLJavaScriptExecutor webView:didFinishNavigation:]_block_invoke_2 (FIRDLJavaScriptExecutor.m:136) WebKit 0x1c9a1e6ec WebKit::WebPageProxy::runJavaScriptInFrameInScriptWorld::lambda::operator() WebKit 0x1c9a1e314 WTF::Detail::CallableWrapper::call WebKit 0x1c9954818 WTF::Detail::CallableWrapper::call WebKit 0x1c9e30004 IPC::Connection::dispatchMessage WebKit 0x1c9e30368 IPC::Connection::dispatchIncomingMessages JavaScriptCore 0x1c9fffce0 WTF::RunLoop::performWork JavaScriptCore 0x1ca000bac WTF::RunLoop::performWork CoreFoundation 0x1b6936124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ CoreFoundation 0x1b69427b0 __CFRunLoopDoSource0 CoreFoundation 0x1b68c75e4 __CFRunLoopDoSources0 CoreFoundation 0x1b68dd0d0 __CFRunLoopRun CoreFoundation 0x1b68e23e8 CFRunLoopRunSpecific GraphicsServices 0x1f1df8358 GSEventRunModal UIKitCore 0x1b8c6ef54 -[UIApplication _run] UIKitCore 0x1b8c6ebb8 UIApplicationMain Runner 0x10486f10c

prateek601 commented 1 year ago

I am also getting the same issue as mentioned above. When the app is open through test flight, the app is crashing on the initial screen only. When run through the xcode in debug mode , it is working fine. App ran on devices with ios v16.6 working fine on some devices but crashing on others when opened through test flight

Screenshot 2023-08-23 at 8 20 31 PM
prateek601 commented 1 year ago

I am also getting the same issue as mentioned above. When the app is open through test flight, the app is crashing on the initial screen only. When run through the xcode in debug mode , it is working fine. App ran on devices with ios v16.6 working fine on some devices but crashing on others when opened through test flight

Screenshot 2023-08-23 at 8 20 31 PM

In my case app was crashing due to the New Relics package that I was using The issue was resolved after setting webViewInstrumentation parameter to false

Relevant material that helped me - https://forum.newrelic.com/s/hubtopic/aAX8W0000008e8DWAQ/my-flutter-app-went-crash-after-integrating-new-relic

https://forum.newrelic.com/s/hubtopic/aAX8W0000008bSlWAI/crash-in-ios-app-caused-by-new-relic-webview-navigation-delegate

ersefuril commented 1 year ago

I'm experiencing a similar issue, The app doesn't fully crash but I do get an error logged in Sentry App Hanging: App hanging for at least 2000 ms. and then in the details it looks very similar to the original post with FirebaseDynamicLinks triggering this long wait.

For me this is happening only on iOS when I download the app via the app store through a dynamic link. But also for me this isn't an actual crash the app does seem to function as expected. Maybe this is unrelated but posting it incase it helps find a fix.

UPDATE: I was able to get a better error logged by adding some debug symbols. it seems this issue (at least the one I'm seeing) is related to FIRDLDefaultRetrievalProcessV2 retrievePasteboardContents Updated logs below.

here's all I can get from Sentry

Details

@davefaliskie I'm experiencing the exact same issue. Did you found any workaround ?

davefaliskie commented 11 months ago

@ersefuril No, unfortunately I have not found a workaround. If/ when I do I'll share here

mortenthansen commented 11 months ago

@ersefuril @davefaliskie what your are seeing looks a lot like my issue in #11509 where I have full Sentry stack trace as well

russellwheatley commented 11 months ago

If you read the stack trace, this is occurring at the level of the Firebase iOS SDK, it is upstream of FlutterFire. As Dynamic Links service is being shutdown, I don't think this issue will be addressed: https://github.com/firebase/firebase-ios-sdk/issues/11753#issuecomment-1699712835

There is nothing we can do to address this here.

alpebubekir commented 11 months ago

I am not using dynamic links but I am using firebase and I am getting startup crash on ios 16.6.1 devices. I cant get any logs because I dont have a ios 16.6.1 device and xcode doesnt give ios 16.6.1 as a runtime. Any idea how can I fix that? (App is on production and I was using firebase before too. I updated the app (and some packages) and it doesnt work on ios16.6.1)

I am using this firebase packages: firebase_auth_platform_interface: ^6.11.3 firebase_core: ^2.2.0 firebase_auth: ^4.7.2 firebase_database: ^10.2.4 firebase_storage: ^11.0.5 firebase_messaging: ^14.1.0 firebase_analytics: ^10.0.5 firebase_in_app_messaging: ^0.7.3