flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_dynamic_links] Attempt to invoke virtual method 'android.content.Intent android.app.Activity.getIntent()' on a null object reference

Open ChristianEdwardPadilla opened this issue 3 years ago • 2 comments

Bug report

[firebase_dynamic_links/unknown] Attempt to invoke virtual method 'android.content.Intent android.app.Activity.getIntent()' on a null object reference

Stack trace:

#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296) <asynchronous suspension>
#2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:499) <asynchronous suspension>
#3      MethodChannelFirebaseDynamicLinks.getInitialLink (package:third_party.flutter_plugins.firebase_dynamic_links.interface/src/method_channel/method_channel_firebase_dynamic_links.dart:122) <asynchronous suspension>
#4      DeepLinkHandler.openInitialDeepLink (package:ads.adwords_mobileapp.app.infra.deep_link/deep_link_handler.dart:102)
<asynchronous suspension>

It looks like a native exception is being thrown (and caught) in this try-catch block: https://github.com/firebase/flutterfire/blob/b9f77fd09bf9d64fb616251e2d602f925320875b/packages/firebase_dynamic_links/firebase_dynamic_links/android/src/main/java/io/flutter/plugins/firebase/dynamiclinks/FlutterFirebaseDynamicLinksPlugin.java#L226

Unfortunately the data we have in the Flutter FirebaseException doesn't specify what line or statement threw in Java, so all we know is that .getIntent() is being called on an Activity that happens to be null.

There is asynchronous logic happening here (the bulk of the logic in FlutterFirebaseDynamicLinksPlugin.getDynamicLink is being performed on a separate thread than the main thread). Is it possible that the Activity could be detached while we wait for a result in lines 239-240, so that by the time we call activity.get() in line 242 it could be null?

Steps to reproduce

Unknown, production crash.

FDL version being used: 4.3.0

ChristianEdwardPadilla avatar Sep 15 '22 15:09 ChristianEdwardPadilla

Thanks for the report. Keeping this issue open and labeling for further insights from the team based on the crash log coming from production.

Also, this DeepLinkHandler.openInitialDeepLink (package:ads.adwords_mobileapp.app.infra.deep_link/deep_link_handler.dart:102) seems to be pointing to third party package maybe ?

darshankawar avatar Sep 16 '22 07:09 darshankawar

Thanks darshankawar!

Yes, that's just the call site of the app using this plugin that is seeing prod crashes.

ChristianEdwardPadilla avatar Sep 16 '22 14:09 ChristianEdwardPadilla

Any suggestions from the team here what might be happening? We're still seeing this crash in production.

ChristianEdwardPadilla avatar Oct 04 '22 15:10 ChristianEdwardPadilla

Hey @ChristianEdwardPadilla, did you see a reduction in crashes following the latest FDL release?

russellwheatley avatar Nov 08 '22 14:11 russellwheatley

Yes, this seems to be fixed now, thanks!

ChristianEdwardPadilla avatar Dec 12 '22 15:12 ChristianEdwardPadilla