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

Crash reports are ignored without error if Fabric is not initialized #69

Open
apaatsio opened this issue Mar 17, 2019 · 5 comments
Open

Comments

@apaatsio
Copy link

Problem

I managed to produce a situation where I had a crash very soon after the launch of the app when Fabric wasn't fully initialized yet. In such case, a call to FlutterCrashlytics().reportCrash() returns successfully even though it doesn't actually report the crash.

The problem is the else branch here:

if (Fabric.isInitialized()) {
onInitialisedMethodCall(methodCall, result);
} else {
result.success(null);
}

As can be seen, it always returns succesully, even when Fabric is not initialized.

Possible solution

Instead of calling result.success(null), do something like this so that the caller can retry later if they want to:

if (Fabric.isInitialized()) {
  onInitialisedMethodCall(methodCall, result);
} else {
  result.error('CRASHLYTICS_NOT_FULLY_INITIALIZED_YET');
}
@jaumard
Copy link
Contributor

jaumard commented Mar 17, 2019

Hi @apaatsio, we can't return an error, the reason we return a success is because if you ask permission to retrieve data to your user (as you must do in Europe because of the law) user can say no so you'll not call initialized to not have it enabled. But you don't want to all your report the throw an exception after that as it's expected.

What I don't understand is how can you have a crash before initializing fabric ? that's the first thing you should do and await the initialized call to be sure it's initialized after that.

@apaatsio
Copy link
Author

I'm using await.

I believe Fabric.with() is asynchronous under the hood and that's causing the issue.

I added logging like this:

if (methodCall.method.equals("initialize")) {
    Fabric.with(context, new Crashlytics(), new CrashlyticsNdk());
    Log.d("FlutterCrashlytics", "Fabric.isInitialized:" + Fabric.isInitialized());
    result.success(null);
}

and it prints false. So, Fabric is not initialized instantly after running Fabric.with().

@jaumard
Copy link
Contributor

jaumard commented Mar 26, 2019

Shit, dawn Fabric ^^
Are you able to reproduce on both Android and iOS ? or just one platform ?
I need to think of a way to fixing this...

@apaatsio
Copy link
Author

@jaumard I have experienced this only on Android since I don't have an Apple device to test on.

@jaumard
Copy link
Contributor

jaumard commented Mar 28, 2019

From the doc:

public static boolean isInitialized()
Returns true when all kits have finished asynchronous initialization.

so problem is only on Android as iOS API doesn't have this isInitialized method ^^

So maybe the fix is just not to use this method and have a boolean into the class instead.
What do you think ? Can you test that ?

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

2 participants