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

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] #44

Open
vinodgleecus opened this issue May 20, 2019 · 4 comments

Comments

@vinodgleecus
Copy link

vinodgleecus commented May 20, 2019

I just implemented this simple method to fetch all available tags/zones

import UIKit
import Parse
import EstimoteProximitySDK

class HomeViewController: UIViewController {

let estimoteCloudCredentials = CloudCredentials(appID: "xxxxxxxx", appToken: "xxxxxxxxxxxxx")
var proximityObserver: ProximityObserver!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    self.tabBarController?.title = "HOME"
    
    DispatchQueue.main.async {
        self.loadNearByBeacons()
    }
}

private func loadNearByBeacons(){
    
    self.proximityObserver = ProximityObserver(
        credentials: estimoteCloudCredentials,
        onError: { error in
            print("proximity observer error: \(error)")
    })
    
    let blueberryZone = ProximityZone(tag: "DevOffice", range: ProximityRange.custom(desiredMeanTriggerDistance: 1.0)!)
    blueberryZone.onEnter = { zoneContext in
        print("Entered near range of tag 'DevOffice'. DeviceIdentifier: \(zoneContext.deviceIdentifier)")
    }
    blueberryZone.onExit = { zoneContext in
        print("Exited near range of tag 'DevOffice'. DeviceIdentifier: \(zoneContext.deviceIdentifier)")
    }
    
    blueberryZone.onContextChange = { contexts in
        print("Now in range of \(contexts.count) contexts")
    }
    // ... etc. You can define as many zones as you need.
    // Start proximity observation
    //self.observe.startObserving([blueberryZone])
    self.proximityObserver.startObserving([blueberryZone])
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.tabBarController?.title = "HOME"
}

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destination.
    // Pass the selected object to the new view controller.
}
*/

}

I'm getting this crash while fetching NearbyTags from Cloud

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 457, TID: 60500, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 libobjc.A.dylib 0x000000019c7476f4 + 56
5 CoreMotion 0x00000001a2e91638 CoreMotion + 292408
6 CoreMotion 0x00000001a2e91b68 CoreMotion + 293736
7 CoreMotion 0x00000001a2e91a78 CoreMotion + 293496
8 CoreMotion 0x00000001a2ebf8a8 CoreMotion + 481448
9 CoreMotion 0x00000001a2ebf8ec CoreMotion + 481516
10 CoreFoundation 0x000000019d4d378c + 28
11 CoreFoundation 0x000000019d4d3074 + 276
12 CoreFoundation 0x000000019d4ce368 + 2276
13 CoreFoundation 0x000000019d4cd764 CFRunLoopRunSpecific + 452
14 CoreFoundation 0x000000019d4ce498 CFRunLoopRun + 84
15 CoreMotion 0x00000001a2ebf280 CoreMotion + 479872
16 libsystem_pthread.dylib 0x000000019d14d920 + 132
17 libsystem_pthread.dylib 0x000000019d14d87c _pthread_start + 48
18 libsystem_pthread.dylib 0x000000019d155dcc thread_start + 4
2019-05-20 16:53:40.004753+0530 Critik[457:60500] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 457, TID: 60500, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4 libobjc.A.dylib 0x000000019c7476f4 + 56
5 CoreMotion 0x00000001a2e91638 CoreMotion + 292408
6 CoreMotion 0x00000001a2e91b68 CoreMotion + 293736
7 CoreMotion 0x00000001a2e91a78 CoreMotion + 293496
8 CoreMotion 0x00000001a2ebf8a8 CoreMotion + 481448
9 CoreMotion 0x00000001a2ebf8ec CoreMotion + 481516
10 CoreFoundation 0x000000019d4d378c + 28
11 CoreFoundation 0x000000019d4d3074 + 276
12 CoreFoundation 0x000000019d4ce368 + 2276
13 CoreFoundation 0x000000019d4cd764 CFRunLoopRunSpecific + 452
14 CoreFoundation 0x000000019d4ce498 CFRunLoopRun + 84
15 CoreMotion 0x00000001a2ebf280 CoreMotion + 479872
16 libsystem_pthread.dylib 0x000000019d14d920 + 132
17 libsystem_pthread.dylib 0x000000019d14d87c _pthread_start + 48
18 libsystem_pthread.dylib 0x000000019d155dcc thread_start + 4

@vinodgleecus
Copy link
Author

vinodgleecus commented Jun 4, 2019

can anyone please respond to this?

@chwastek
Copy link
Contributor

chwastek commented Jun 13, 2019

hey @vinodgleecus
firstly sorry for not responding for so long!
secondly: could you share bit more?

  • does it happen all the time/sometimes?
  • which version of the SDK are you using?
  • do you get logs from Proximity SDK?
  • are you 100% sure that you have at least one device with DevOffice tag?

Regards

@vinodgleecus
Copy link
Author

yes it happens every time
pod 'EstimoteProximitySDK','~> 1.2.1'
no, I didn't any logs
yes Am 100% Sure

@divrt-anvesht
Copy link

divrt-anvesht commented Aug 9, 2019

I too have same problem "Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]" in my current App Store app. @Estimote could you please fix this issue ASAP. I am using EstimoteProximitySDK (1.4.1) in my app.
This weird bug in iPhone X and later devices making app stuck for a while....

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

3 participants