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

Testing on iPhone Xs Device causes a "Main Thread Checker" exception. #3

Closed
sedwo opened this issue Feb 1, 2019 · 6 comments
Closed

Comments

@sedwo
Copy link

sedwo commented Feb 1, 2019

The moment I execute IHProgressHUD.show(withStatus: "")

I get a:

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 9428, TID: 3268605, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0

https://developer.apple.com/documentation/code_diagnostics/main_thread_checker
fyi: SVProgressHUD/SVProgressHUD#822

@Ibrahimhass
Copy link
Member

Ibrahimhass commented Feb 2, 2019

Hey @sedwo
I tried this code snippet on iPhone XS Simulator Xcode version 10.0

DispatchQueue.global(qos: .utility).async { IHProgressHUD.show(withStatus: "") }

I am not able to reprduce the issue you reported. This is my log:

2019-02-02 17:31:57.494634+0530 IHProgressHUD_Example[2599:101779] [framework] CUIThemeStore: No theme registered with id=0 Notification received: NSNotificationName(_rawValue: IHProgressHUDWillAppear) Status user info key: Useful Information. Notification received: NSNotificationName(_rawValue: IHProgressHUDDidAppear) Status user info key: Useful Information. Notification received: NSNotificationName(_rawValue: IHProgressHUDDidAppear) Status user info key: Useful Information. Notification received: NSNotificationName(_rawValue: IHProgressHUDWillDisappear) Status user info key: Useful Information.

Also this was designed to be thread safe so I specifically checked for this issue.

As in the sharedInstance has a check for the main thread

private static let sharedView : IHProgressHUD = { var localInstance : IHProgressHUD? if Thread.current.isMainThread { if IHProgressHUD.isNotAppExtension { if let window = UIApplication.shared.delegate?.window { localInstance = IHProgressHUD.init(frame: window?.bounds ?? CGRect.zero) } else { localInstance = IHProgressHUD() } } else { localInstance = IHProgressHUD.init(frame: UIScreen.main.bounds) } } else { DispatchQueue.main.sync { if IHProgressHUD.isNotAppExtension { if let window = UIApplication.shared.delegate?.window { localInstance = IHProgressHUD.init(frame: window?.bounds ?? CGRect.zero) } else { localInstance = IHProgressHUD() } } else { localInstance = IHProgressHUD.init(frame: UIScreen.main.bounds) } } } return localInstance! }()

PS I am using the code from the example project here on github. Please let me know if I did miss on something or your suggestions as to how I can reproduce it. Thanks :)

@sedwo
Copy link
Author

sedwo commented Feb 2, 2019

Hi @Ibrahimhass,
It doesn't trigger on the simulator, but on a real device. I just happen to have the Xs model, but other models with iOS 12 might exhibit the same catch.

screen shot 2019-02-02 at 8 37 00 am

@Ibrahimhass
Copy link
Member

Hey @sedwo

I tested it on physical devices ie.

  1. iPhone 7 (iOS 12.1)
  2. iPad Model MP2F2HN/A running iOS 11.4.1
  3. iPad Model MP2F2HN/A running iOS 12.1.1

Also, interesting I found a similar issue posted here. Check this specific comment. It's bug in iOS 12.1 on iPhone XS only but it has been fixed in iOS 12.1.1

Please do try checking with iOS 12.1.1 later when you upgrade.

@sedwo
Copy link
Author

sedwo commented Feb 4, 2019

@Ibrahimhass I'm running v12.1.2 on iPhone Xs and it still occurs. I'll leave it for now and disable the check in Xcode.

@sedwo sedwo closed this as completed Feb 4, 2019
@leandrodestro
Copy link

Happened to me as well on my Xs physical device.

@sbrighiu
Copy link

Why dont we just make an option to disable the use of CoreMotion?

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

4 participants