flutter_branch_sdk icon indicating copy to clipboard operation
flutter_branch_sdk copied to clipboard

Flutter SDK init falls into loop when race condition happens during the initialization.

Open klim-branch opened this issue 10 months ago • 5 comments

Hi, this is Kun from the Branch Solutions Integration Engineering team.

The Flutter SDK’s initialization is not handled correctly when it gets into a race condition by initializing other 3rd party services with Firebase Messaging Services (default push notification package)

Reproduction step

  • Implement a Firebase Messaging Services to the application.
  • From the Service, start an instance of Notification service (3rd party) and use Branch to receive Branch link data.

We indeed do have a full code example with the reference given from the client side. please send out the email to [email protected].

Initialization:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await FlutterBranchSdk.init(useTestKey: false, enableLogging: true, disableTracking: false);
  WidgetsFlutterBinding.ensureInitialized();

Observation

image

Where you can see that the initialization continuously loop with the message: BranchReferralInitListener - error: Warning. Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session", to true.

From the UX/UI side, since the application is not initialized, it is showing a blank black screen and not loading anything from the application.

https://drive.google.com/file/d/1l0WkH82lH9DCyIEKTW7OgQOO2HLCNKfs/view?usp=sharing

deally, when the Branch init fails, it should just retry for a certain amount of time and return. However, it seems like in this current situation, it is not returning and constantly try to initialize the SDK.

Please check if we are enabling any other async initialization or any initialization error handling for Flutter SDK.

klim-branch avatar Apr 22 '24 08:04 klim-branch

Hi @klim-branch

Let me know which version of the package is being used.

Issue #301 reported similar behavior and was resolved in version 7.2.0

RodrigoSMarques avatar Apr 23 '24 01:04 RodrigoSMarques

Hi @RodrigoSMarques

thank you for the confirmation, I can confirm that the client is using ^7.1.0 version of the SDK.

flutter_branch_sdk: ^7.1.0

Perhaps I will let them know to use version above 7.2.0.

klim-branch avatar Apr 23 '24 02:04 klim-branch

Hi @RodrigoSMarques The client tried with the 7.3.0 version of the SDK and the issue persists.

I've also tried with the sample application given by the client, upgraded our SDK, resolved all of the flutter dependencies to match js: ^0.7.1, and was able to reproduce the issue from my end.

The change that I made from the sample app is the following:

js: ^0.7.1 flutter_branch_sdk: ^7.1.0 -> flutter_branch_sdk: ^7.3.0 Run flutter pub upgrade --major-versions

Could you please kindly take a look into it?

klim-branch avatar Apr 26 '24 02:04 klim-branch

hi @klim-branch

I have added Firebase Cloud Messaging into an application.

I sent the notification, opened the application from the notification and was unable to reproduce the problem.

I need more details to be provided, such as the list of packages used by the application to try to create the same scenario.

RodrigoSMarques avatar Apr 26 '24 10:04 RodrigoSMarques

Hi @RodrigoSMarques thank you for looking into the issue! So to confirm, it seems like the issue is not coming from using Firebase notification package.

Could you please look into the sample code that was shared to you? I will follow up with you from the separate email chain to further discuss on this.

klim-branch avatar Apr 26 '24 13:04 klim-branch

@klim-branch

Version 8.0.0 released.

Take the tests and report the results.

RodrigoSMarques avatar May 17 '24 12:05 RodrigoSMarques

Thank you very much for the support here! Confirming the issue has been resolved with the usage of the SDK version 8.0.0

klim-branch avatar May 22 '24 03:05 klim-branch