SimplicityMobile / Simplicity

A simple way to implement Facebook and Google login in your iOS apps.
Apache License 2.0
681 stars 66 forks source link

Modifying autolayout from background thread #31

Closed mikkelam closed 7 years ago

mikkelam commented 7 years ago

Hi, I'm getting this error when using the google login feature

This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.

I believe it is a result of using datatask in the google loginhandler.

Please checkout this stackoverflow post , I believe it could be fixed by wrapping the callback call with:

if error == nil {
    dispatch_async(dispatch_get_main_queue(), {
        self.handleRequest(...)I
    })
}
edjiang commented 7 years ago

Hey @mikkelam! Which specific line are you talking about?

The Simplicity callback is intentionally on the background thread, since most of what people would want to do is to make other network calls, etc. So if you'd like to perform UI operations on the Simplicity callback, I would recommend that you wrap your own callback with a Dispatch call. If you do that, does that solve your error?

mikkelam commented 7 years ago

Are you not getting this error when trying to use google login? I'm getting it on ios 9.3.1. Simplicity is modifying autolayout engine by messing with the safariview is what I think is the issue.

This is the only code I am using

let google = Google()
google.scopes = ["email"]
google.login {
    (result, error) in
        if let accessToken = result{
            //Dostuff
        }else{
            //Some error
    }
    }
}
edjiang commented 7 years ago

Nope! Not getting this at all, and I just specifically tried Google w/ iOS 9.3.1. If you'd like I can screenshare sometime later today or tomorrow and try to help you get it figured out. Have you tried wrapping your // Do stuff with Dispatch? Do errors still occur?

mikkelam commented 7 years ago

@edjiang I wrapped my code with Dispatch and it fixed the issues :) Thanks mate, great project 👍

edjiang commented 7 years ago

No problem; glad it's helpful to you!