Skip to content

🐛 [firebase_dynamic_links] iOS app crashes when users click on the dynamic link #4882

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

Closed
moo7md opened this issue Jan 31, 2021 · 1 comment
Labels
Needs Attention This issue needs maintainer attention. type: bug Something isn't working

Comments

@moo7md
Copy link

moo7md commented Jan 31, 2021

Hello Everyone,

My app allows users to share links to certain pages in my app to other users using Firebase's Dynamic Link. This feature works fine in my Android version, but iOS users reported app crashes when they click on the dynamic links. In addition, even if the app was in the background (Not dead) the app crashes when users click on the dynamic link.

This is how I initialize my dynamic link plugin:

void init(BuildContext context) async {
    FirebaseDynamicLinks.instance.onLink(
        onSuccess: (PendingDynamicLinkData dynamicLink) async {
          final Uri deepLink = dynamicLink?.link;
          final args = deepLink.path.split('/');
          args.removeWhere((element) => element.isEmpty);
          if (deepLink != null) {
            Navigator.pushNamed(context, deepLink.path, arguments: args);
          }
        },
        onError: (OnLinkErrorException e) async {
          print('onLinkError');
          print(e.message);
        }
    );

    final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
    final Uri deepLink = data?.link;
    if (deepLink != null && !linkOpened) {
      linkOpened = true;
      Navigator.pushNamed(context, deepLink.path).whenComplete(() => linkOpened = false);
    }
  }

Here's the crash log file I got from testers:

Last Exception Backtrace:
0   CoreFoundation                	0x19ac3b9d4 __exceptionPreprocess + 216 (NSException.m:199)
1   libobjc.A.dylib               	0x1ae5ecb54 objc_exception_throw + 56 (objc-exception.mm:565)
2   CoreFoundation                	0x19ab4a4fc +[NSException raise:format:arguments:] + 96 (NSException.m:146)
3   Foundation                    	0x19be91238 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 104 (NSException.m:239)
4   Runner                        	0x1005d8e04 0x10056c000 + 445956 (exception_apple.mm:59)
5   Runner                        	0x1005d8ab8 firebase::firestore::util::Throw(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 20 (exception.cc:86)
6   Runner                        	0x100629048 firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 32 (hard_assert.cc:35)
7   Runner                        	0x1005ce310 0x10056c000 + 402192 (document_reference.cc:64)
8   Runner                        	0x1005f07c4 0x10056c000 + 542660 (firestore.cc:127)
9   Runner                        	0x100605ec0 0x10056c000 + 630464 (FIRFirestore.mm:209)
10  Runner                        	0x100c871c4 -[FLTFirebaseFirestoreReader readValueOfType:] + 356 (FLTFirebaseFirestoreReader.m:38)
11  Flutter                       	0x102beaa68 0x102628000 + 6040168
12  Runner                        	0x100c8710c -[FLTFirebaseFirestoreReader readValueOfType:] + 172 (FLTFirebaseFirestoreReader.m:79)
13  Flutter                       	0x102bebe74 0x102628000 + 6045300
14  Flutter                       	0x102be8cc8 0x102628000 + 6032584
15  Flutter                       	0x10265ee4c 0x102628000 + 224844
16  Flutter                       	0x10295c9c4 0x102628000 + 3361220
17  Flutter                       	0x1028fd860 0x102628000 + 2971744
18  Flutter                       	0x1028ff6c0 0x102628000 + 2979520
19  CoreFoundation                	0x19abbc3d0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28 (CFRunLoop.c:1807)
20  CoreFoundation                	0x19abbbfd4 __CFRunLoopDoTimer + 1004 (CFRunLoop.c:2415)
21  CoreFoundation                	0x19abbb4b4 __CFRunLoopDoTimers + 324 (CFRunLoop.c:2575)
22  CoreFoundation                	0x19abb5840 __CFRunLoopRun + 1912 (CFRunLoop.c:3090)
23  CoreFoundation                	0x19abb4b90 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3242)
24  GraphicsServices              	0x1b0ed7598 GSEventRunModal + 160 (GSEvent.c:2259)
25  UIKitCore                     	0x19d49e638 -[UIApplication _run] + 1052 (UIApplication.m:3266)
26  UIKitCore                     	0x19d4a3bb8 UIApplicationMain + 164 (UIApplication.m:4738)
27  Runner                        	0x1005715e0 main + 64 (AppDelegate.swift:9)
28  libdyld.dylib                 	0x19a893588 start + 4

Here's flutter doctor -v

[✓] Flutter (Channel master, 1.26.0-13.0.pre.66, on macOS 11.1 20C69 darwin-x64, locale en-US)
    • Flutter version 1.26.0-13.0.pre.66 at /Users/username/flutter/flutter
    • Framework revision 024c49da85 (4 days ago), 2021-01-19 19:28:13 -0800
    • Engine revision b58dbc88fc
    • Dart version 2.12.0 (build 2.12.0-240.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/username/Library/Android/sdk
    • Platform android-30, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2018.2.5)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • Mohammed’s iPod touch (mobile)  • ios            • iOS 14.2
    • Chrome (web)                   • chrome                                   • web-javascript • Google Chrome 88.0.4324.96

• No issues found!
@moo7md moo7md added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jan 31, 2021
@moo7md
Copy link
Author

moo7md commented Feb 2, 2021

I found out what the issue was. I analyzed the log file and I noticed that it's complaining about (document_reference.cc:64). This tells me that somewhere in my code, I'm trying to access a document that doesn't exist or the document Id is null which was the case.
Turned out I was trying to get a document with a null value for the document Id. 😅😅

@moo7md moo7md closed this as completed Feb 2, 2021
@firebase firebase locked and limited conversation to collaborators Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant