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

Parallax triggers Main Thread Checker error #98

Closed
jemartti opened this issue Oct 19, 2018 · 7 comments
Closed

Parallax triggers Main Thread Checker error #98

jemartti opened this issue Oct 19, 2018 · 7 comments

Comments

@jemartti
Copy link

I've been getting some Main Thread Checker errors with JGProgressHUD and I think I've pinned them down to the Parallax effect.

I'm triggering the HUD in an @IBAction:

@IBAction func signInButton(_ sender: Any) {
    let hud = JGProgressHUD(style: .light)
    hud.interactionType = .blockAllTouches
    hud.show(in: view, animated: true)
}

This triggers the Main Thread Checker error:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 1931, TID: 217749, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x0000000208967894 <redacted> + 56
5   CoreMotion                          0x000000020f1e07b0 CoreMotion + 305072
6   CoreMotion                          0x000000020f1e0ce4 CoreMotion + 306404
7   CoreMotion                          0x000000020f1e0bf4 CoreMotion + 306164
8   CoreMotion                          0x000000020f2123d4 CoreMotion + 508884
9   CoreMotion                          0x000000020f212434 CoreMotion + 508980
10  CoreFoundation                      0x00000002096fd4d8 <redacted> + 28
11  CoreFoundation                      0x00000002096fcdbc <redacted> + 276
12  CoreFoundation                      0x00000002096f80c0 <redacted> + 2324
13  CoreFoundation                      0x00000002096f7494 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000002096f81f8 CFRunLoopRun + 84
15  CoreMotion                          0x000000020f211d6c CoreMotion + 507244
16  libsystem_pthread.dylib             0x00000002093729c8 <redacted> + 132
17  libsystem_pthread.dylib             0x0000000209372924 _pthread_start + 52
18  libsystem_pthread.dylib             0x000000020937addc thread_start + 4
(lldb) 

If I disable Parallax, the HUD displays fine with no errors:

@IBAction func signInButton(_ sender: Any) {
    let hud = JGProgressHUD(style: .light)
    hud.interactionType = .blockAllTouches
    hud.parallaxMode = .alwaysOff
    hud.show(in: view, animated: true)
}

I've tried running it on the main thread to be sure but it appears the Parallax stuff is running asynchronously on a background thread somewhere:

DispatchQueue.main.async {
    let hud = JGProgressHUD(style: .light)
    hud.interactionType = .blockAllTouches
    hud.show(in: view, animated: true)
}

I spent a bit of time digging into the JGProgressHUD code but I can't quite figure out what's going on with this. Any suggestions? It's possible I'm incorrectly displaying the HUD.

@JonasGessner
Copy link
Owner

Which version of iOS are you using? And is this happening on the simulator or on a real device?

@markj
Copy link

markj commented Oct 19, 2018

There seems to be some weirdness in iOS12.0.1 I see a similar problem on hardware.

lionheart/openradar-mirror#20515

Is also similar in that performing an action on the UI Thread causes the Core Motion thread to perform an action which in turn triggers the Main Thread Checker error.

@JonasGessner
Copy link
Owner

Thanks @markj! So this is a bug in CoreMotion, not in JGProgressHUD.

@Ran-hub
Copy link

Ran-hub commented Feb 6, 2019

There seems to be some weirdness in iOS12.0.1 I see a similar problem on hardware.

lionheart/openradar-mirror#20515

Is also similar in that performing an action on the UI Thread causes the Core Motion thread to perform an action which in turn triggers the Main Thread Checker error.

HI,
I this error, Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 2145, TID: 557528, Thread name: (none), Queue name: com.google.fira.worker, QoS: 9
Backtrace:
4 DownRoute 0x0000000102ca8120 FIRAIsAppActive + 56
5 DownRoute 0x0000000102ca75cc -[FIRASessionReporter shouldStartNewSession] + 24
6 DownRoute 0x0000000102ca7170 -[FIRASessionReporter initWithPersistedConfig:] + 284
7 DownRoute 0x0000000102c92e58 __48-[FIRAMeasurement startMeasurementOnWorkerQueue]_block_invoke + 1828
8 libdispatch.dylib 0x00000001048e0dc8 _dispatch_client_callout + 16
9 libdispatch.dylib 0x00000001048e2e28 _dispatch_once_callout + 84
10 DownRoute 0x0000000102c92718 -[FIRAMeasurement startMeasurementOnWorkerQueue] + 268
11 DownRoute 0x0000000102c924e4 -[FIRAMeasurement setEnabledOnWorkerQueue:] + 124
12 DownRoute 0x0000000102ca6de8 __52-[FIRAScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 44
13 libdispatch.dylib 0x00000001048df824 _dispatch_call_block_and_release + 24
14 libdispatch.dylib 0x00000001048e0dc8 _dispatch_client_callout + 16
15 libdispatch.dylib 0x00000001048e8e6c _dispatch_lane_serial_drain + 720
16 libdispatch.dylib 0x00000001048e9b60 _dispatch_lane_invoke + 460
17 libdispatch.dylib 0x00000001048f3bfc _dispatch_workloop_worker_thread + 1220
18 libsystem_pthread.dylib 0x00000001e6aad0dc _pthread_wqthread + 312
19 libsystem_pthread.dylib 0x00000001e6aafcec start_wqthread + 4

someone help me onthis

@jkaunert
Copy link

uncheck debug executable in your scheme and try again. (in Xcode, click on your target name in the left side top bar to the right of the stop button > Edit Scheme > Run > Info > uncheck Debug executable > close and relaunch.) This did the trick for me...

@what-name
Copy link

Xcode 10.2.1 - iOS 12.2

@jkaunert this doesn't seem to be the exact way anymore, for me it just simply didn't start the app in debug mode. Instead I disabled the Main Thread Checker under:
Product->Scheme->Edit Scheme...->Run->Diagnostics->uncheck Main Thread Checker.

Works like a charm now.

@jbmaxwell
Copy link

uncheck debug executable in your scheme and try again. (in Xcode, click on your target name in the left side top bar to the right of the stop button > Edit Scheme > Run > Info > uncheck Debug executable > close and relaunch.) This did the trick for me...

Yeah, this works as a temporary workaround. Hopefully a real fix arrives sometime soon...

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

7 participants