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

Problem with CoreMotion causes UI API called on a background thread, IPhone X series #251

Closed
hackerpex opened this issue Apr 10, 2019 · 5 comments

Comments

@hackerpex
Copy link

this problem just block presentation on ios 12x only int IPhone X series

this part of code was commented and solve the problem

// let motionEffectsX = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
// motionEffectsX.maximumRelativeValue = offset
// motionEffectsX.minimumRelativeValue = -offset
//
// let motionEffectsY = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis)
// motionEffectsY.maximumRelativeValue = offset
// motionEffectsY.minimumRelativeValue = -offset

// let group = UIMotionEffectGroup()
// group.motionEffects = [motionEffectsX, motionEffectsY]
//
// addMotionEffect(group)

@tarekeg
Copy link

tarekeg commented Apr 20, 2019

thanks a lot

@stefanrenne
Copy link
Contributor

stefanrenne commented May 13, 2019

Wrapping that piece of code with a dispatch async also solves the problem

DispatchQueue.main.async {
     let motionEffectsX = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
     motionEffectsX.maximumRelativeValue = offset
     motionEffectsX.minimumRelativeValue = -offset
            
     let motionEffectsY = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis)
     motionEffectsY.maximumRelativeValue = offset
     motionEffectsY.minimumRelativeValue = -offset
            
     let group = UIMotionEffectGroup()
     group.motionEffects = [motionEffectsX, motionEffectsY]
            
     self.addMotionEffect(group)
}

Created a PR for this #252

@PGLongo
Copy link
Collaborator

PGLongo commented May 28, 2019

merged the pr

@PGLongo PGLongo closed this as completed May 28, 2019
@jbmaxwell
Copy link

I'm running 5.2.1 and still get this error. Is it not merged?

@jbmaxwell
Copy link

jbmaxwell commented Jun 4, 2019

Updated my project to Xcode 10.2, Swift 5, cloned your repo and updated PKHUD to 5.2.2, and same Main Thread Checker error. This is on iPhone XR, btw.

NickAgerMoletest pushed a commit to Moletest-Scotland/PKHUD that referenced this issue Sep 18, 2019
* see pkluz#245 (with my comment)
* see pkluz#251 - which documents an attempted fix in pull request pkluz/PKHUD/pkluz#252
* see another attempt which just conditionally enables the code - pkluz/PKHUD/pkluz#260
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

5 participants