Search in sources :

Example 1 with RemoveRepeatsStrategy

use of com.google.firebase.crashlytics.internal.stacktrace.RemoveRepeatsStrategy in project firebase-android-sdk by firebase.

the class CrashlyticsCore method onPreExecute.

// endregion
// region Initialization
public boolean onPreExecute(AppData appData, SettingsDataProvider settingsProvider) {
    // before starting the crash detector make sure that this was built with our build
    // tools.
    // Throw an exception and halt the app if the build ID is required and not present.
    // TODO: This flag is no longer supported and should be removed, as part of a larger refactor
    // now that the buildId is now only used for mapping file association.
    final boolean requiresBuildId = CommonUtils.getBooleanResourceValue(context, CRASHLYTICS_REQUIRE_BUILD_ID, CRASHLYTICS_REQUIRE_BUILD_ID_DEFAULT);
    if (!isBuildIdValid(appData.buildId, requiresBuildId)) {
        throw new IllegalStateException(MISSING_BUILD_ID_MSG);
    }
    final String sessionIdentifier = new CLSUUID(idManager).toString();
    try {
        crashMarker = new CrashlyticsFileMarker(CRASH_MARKER_FILE_NAME, fileStore);
        initializationMarker = new CrashlyticsFileMarker(INITIALIZATION_MARKER_FILE_NAME, fileStore);
        final UserMetadata userMetadata = new UserMetadata(sessionIdentifier, fileStore, backgroundWorker);
        final LogFileManager logFileManager = new LogFileManager(fileStore);
        final StackTraceTrimmingStrategy stackTraceTrimmingStrategy = new MiddleOutFallbackStrategy(MAX_STACK_SIZE, new RemoveRepeatsStrategy(NUM_STACK_REPETITIONS_ALLOWED));
        final SessionReportingCoordinator sessionReportingCoordinator = SessionReportingCoordinator.create(context, idManager, fileStore, appData, logFileManager, userMetadata, stackTraceTrimmingStrategy, settingsProvider);
        controller = new CrashlyticsController(context, backgroundWorker, idManager, dataCollectionArbiter, fileStore, crashMarker, appData, userMetadata, logFileManager, sessionReportingCoordinator, nativeComponent, analyticsEventLogger);
        // If the file is present at this point, then the previous run's initialization
        // did not complete, and we want to perform initialization synchronously this time.
        // We make this check early here because we want to guarantee that the async
        // startup thread we're about to launch doesn't affect the value.
        final boolean initializeSynchronously = didPreviousInitializationFail();
        checkForPreviousCrash();
        controller.enableExceptionHandling(sessionIdentifier, Thread.getDefaultUncaughtExceptionHandler(), settingsProvider);
        if (initializeSynchronously && CommonUtils.canTryConnection(context)) {
            Logger.getLogger().d("Crashlytics did not finish previous background " + "initialization. Initializing synchronously.");
            // finishInitSynchronously blocks the UI thread while it finishes background init.
            finishInitSynchronously(settingsProvider);
            // Returning false here to stop the rest of init from being run in the background thread.
            return false;
        }
    } catch (Exception e) {
        Logger.getLogger().e("Crashlytics was not started due to an exception during initialization", e);
        controller = null;
        return false;
    }
    Logger.getLogger().d("Successfully configured exception handler.");
    return true;
}
Also used : RemoveRepeatsStrategy(com.google.firebase.crashlytics.internal.stacktrace.RemoveRepeatsStrategy) UserMetadata(com.google.firebase.crashlytics.internal.metadata.UserMetadata) LogFileManager(com.google.firebase.crashlytics.internal.metadata.LogFileManager) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) StackTraceTrimmingStrategy(com.google.firebase.crashlytics.internal.stacktrace.StackTraceTrimmingStrategy) MiddleOutFallbackStrategy(com.google.firebase.crashlytics.internal.stacktrace.MiddleOutFallbackStrategy)

Example 2 with RemoveRepeatsStrategy

use of com.google.firebase.crashlytics.internal.stacktrace.RemoveRepeatsStrategy in project firebase-android-sdk by firebase.

the class CrashlyticsCore method onPreExecute.

// endregion
// region Initialization
public boolean onPreExecute(AppData appData, SettingsProvider settingsProvider) {
    // before starting the crash detector make sure that this was built with our build
    // tools.
    // Throw an exception and halt the app if the build ID is required and not present.
    // TODO: This flag is no longer supported and should be removed, as part of a larger refactor
    // now that the buildId is now only used for mapping file association.
    final boolean requiresBuildId = CommonUtils.getBooleanResourceValue(context, CRASHLYTICS_REQUIRE_BUILD_ID, CRASHLYTICS_REQUIRE_BUILD_ID_DEFAULT);
    if (!isBuildIdValid(appData.buildId, requiresBuildId)) {
        throw new IllegalStateException(MISSING_BUILD_ID_MSG);
    }
    final String sessionIdentifier = new CLSUUID(idManager).toString();
    try {
        crashMarker = new CrashlyticsFileMarker(CRASH_MARKER_FILE_NAME, fileStore);
        initializationMarker = new CrashlyticsFileMarker(INITIALIZATION_MARKER_FILE_NAME, fileStore);
        final UserMetadata userMetadata = new UserMetadata(sessionIdentifier, fileStore, backgroundWorker);
        final LogFileManager logFileManager = new LogFileManager(fileStore);
        final StackTraceTrimmingStrategy stackTraceTrimmingStrategy = new MiddleOutFallbackStrategy(MAX_STACK_SIZE, new RemoveRepeatsStrategy(NUM_STACK_REPETITIONS_ALLOWED));
        final SessionReportingCoordinator sessionReportingCoordinator = SessionReportingCoordinator.create(context, idManager, fileStore, appData, logFileManager, userMetadata, stackTraceTrimmingStrategy, settingsProvider, onDemandCounter);
        controller = new CrashlyticsController(context, backgroundWorker, idManager, dataCollectionArbiter, fileStore, crashMarker, appData, userMetadata, logFileManager, sessionReportingCoordinator, nativeComponent, analyticsEventLogger);
        // If the file is present at this point, then the previous run's initialization
        // did not complete, and we want to perform initialization synchronously this time.
        // We make this check early here because we want to guarantee that the async
        // startup thread we're about to launch doesn't affect the value.
        final boolean initializeSynchronously = didPreviousInitializationFail();
        checkForPreviousCrash();
        controller.enableExceptionHandling(sessionIdentifier, Thread.getDefaultUncaughtExceptionHandler(), settingsProvider);
        if (initializeSynchronously && CommonUtils.canTryConnection(context)) {
            Logger.getLogger().d("Crashlytics did not finish previous background " + "initialization. Initializing synchronously.");
            // finishInitSynchronously blocks the UI thread while it finishes background init.
            finishInitSynchronously(settingsProvider);
            // Returning false here to stop the rest of init from being run in the background thread.
            return false;
        }
    } catch (Exception e) {
        Logger.getLogger().e("Crashlytics was not started due to an exception during initialization", e);
        controller = null;
        return false;
    }
    Logger.getLogger().d("Successfully configured exception handler.");
    return true;
}
Also used : RemoveRepeatsStrategy(com.google.firebase.crashlytics.internal.stacktrace.RemoveRepeatsStrategy) UserMetadata(com.google.firebase.crashlytics.internal.metadata.UserMetadata) LogFileManager(com.google.firebase.crashlytics.internal.metadata.LogFileManager) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) StackTraceTrimmingStrategy(com.google.firebase.crashlytics.internal.stacktrace.StackTraceTrimmingStrategy) MiddleOutFallbackStrategy(com.google.firebase.crashlytics.internal.stacktrace.MiddleOutFallbackStrategy)

Aggregations

LogFileManager (com.google.firebase.crashlytics.internal.metadata.LogFileManager)2 UserMetadata (com.google.firebase.crashlytics.internal.metadata.UserMetadata)2 MiddleOutFallbackStrategy (com.google.firebase.crashlytics.internal.stacktrace.MiddleOutFallbackStrategy)2 RemoveRepeatsStrategy (com.google.firebase.crashlytics.internal.stacktrace.RemoveRepeatsStrategy)2 StackTraceTrimmingStrategy (com.google.firebase.crashlytics.internal.stacktrace.StackTraceTrimmingStrategy)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2