segment-integrations / analytics-ios-integration-amplitude

The Amplitude analytics-ios integration.
MIT License
11 stars 45 forks source link

Main thread API violations #28

Closed danielgalasko closed 7 years ago

danielgalasko commented 7 years ago

Hi,

We are currently experiencing main thread API asserts for this integration that prevent us from running tests on our CI. It also throws these asserts while developing.

The issue begins in SEGAmplitudeIntegration that calls [[Amplitude instance] initializeApiKey:apiKey];

This call should be called on a main queue OR prompt Amplitude to update their SDK to do this. I am linking Amplitude for this one.

It all boils down to how Amplitude uses UIApplication:

        UIApplication *app = [self getSharedApplication];
        if (app != nil) {
            UIApplicationState state = app.applicationState;
            if (state != UIApplicationStateBackground) {
                // If this is called while the app is running in the background, for example
                // via a push notification, don't call enterForeground
                [self enterForeground];
            }
        }

So either Segment fixes this or Amplitude but it would be nice to see this resolved. Happy to submit a patch PR

screen shot 2017-10-11 at 4 53 55 pm
danielgalasko commented 7 years ago

In the meanwhile I have submitted https://github.com/amplitude/Amplitude-iOS/pull/148 to address this I am just not sure which one will be done first.

The article that outlines the issue this causes in hanging the simulator is discussed here

ladanazita commented 7 years ago

Thanks for raising this @danielgalasko ! Looks like @djih merged those changes - closing.

djih commented 7 years ago

@ladanazita I love how the updates are automatically pulled into the Segment integration