Skip to content

iOS crash due to recursive call while starting app in the ongoing state with the native consent missing #18

Closed
@shankari

Description

@shankari

This is a super corner case, but I want to document it in case we can fix it as part of the upcoming refactoring. This happens only IFF:

  • the app is in ONGOING_STATE while being launched
  • the app has no native consent set

If there is no native consent set, but there is local consent, we call markConsented
which calls initWithConsent, which creates the TripDiaryStateMachine using self.tripDiaryStateMachine = [TripDiaryStateMachine instance];

While creating the TripDiaryStateMachine, we look to see whether the currState is the ongoingTripState

    if (self.currState == kOngoingTripState) {
        // If we restarted, we recreate the location manager, but then it won't have
        // the fine location turned on, since that is not carried through over restarts.
        // So let's restart the tracking
        [TripDiaryActions startTracking:CFCTransitionTripRestarted withLocationMgr:self.locMgr];
        // Note that if the phone was shut down when the app was in the ongoing trip state, and it was
        // turned back on at home, we will start tracking here but will most probably not get a visit transition
        // so the data collection will be turned on until the NEXT trip ends. This is why we need remote pushes, I think.
        // would be good to test, though.
    }

startTrackingActions generates a notification

    [[NSNotificationCenter defaultCenter] postNotificationName:CFCTransitionNotificationName
                                                        object:CFCTransitionTripStarted];

which calls fireGenericTransitionFor, which in turn calls

    if ([TripDiaryStateMachine instance].currState == kWaitingForTripStartState &&

This is a recursive call, so this fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions