Orderella / PopupDialog

A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.
http://www.mwfire.de
Other
3.95k stars 521 forks source link

iOS11 UI API background thread error #167

Closed pushchris closed 6 years ago

pushchris commented 7 years ago

Report

Environment

Please provide information on your development environment, so we can build with the same scenario.

Dependency management

What did you do?

Called up a dialog with background blur

What did you expect to happen?

The dialog to appear without any errors.

What happened instead?

While running the app inside of iOS11 with Swift 4 on an iPhone X the dialog appears, but throws the following errors:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 7255, TID: 269161, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   PopupDialog                         0x000000010642738b -[FXBlurView blurLayer] + 43
5   PopupDialog                         0x0000000106426fbb -[FXBlurView blurRadius] + 43
6   PopupDialog                         0x000000010642972d __46-[FXBlurView updateAsynchronously:completion:]_block_invoke + 61
7   libdispatch.dylib                   0x000000010ac643f7 _dispatch_call_block_and_release + 12
8   libdispatch.dylib                   0x000000010ac6543c _dispatch_client_callout + 8
9   libdispatch.dylib                   0x000000010ac6a352 _dispatch_queue_override_invoke + 1458
10  libdispatch.dylib                   0x000000010ac711f9 _dispatch_root_queue_drain + 772
11  libdispatch.dylib                   0x000000010ac70e97 _dispatch_worker_thread3 + 132
12  libsystem_pthread.dylib             0x000000010b1251ca _pthread_wqthread + 1387
13  libsystem_pthread.dylib             0x000000010b124c4d start_wqthread + 13
2017-10-04 12:28:06.860947-0500 Spotter[7255:269161] [reports] Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 7255, TID: 269161, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   PopupDialog                         0x000000010642738b -[FXBlurView blurLayer] + 43
5   PopupDialog                         0x0000000106426fbb -[FXBlurView blurRadius] + 43
6   PopupDialog                         0x000000010642972d __46-[FXBlurView updateAsynchronously:completion:]_block_invoke + 61
7   libdispatch.dylib                   0x000000010ac643f7 _dispatch_call_block_and_release + 12
8   libdispatch.dylib                   0x000000010ac6543c _dispatch_client_callout + 8
9   libdispatch.dylib                   0x000000010ac6a352 _dispatch_queue_override_invoke + 1458
10  libdispatch.dylib                   0x000000010ac711f9 _dispatch_root_queue_drain + 772
11  libdispatch.dylib                   0x000000010ac70e97 _dispatch_worker_thread3 + 132
12  libsystem_pthread.dylib             0x000000010b1251ca _pthread_wqthread + 1387
13  libsystem_pthread.dylib             0x000000010b124c4d start_wqthread + 13

This issue appears to directly correlate with https://github.com/nicklockwood/FXBlurView/issues/143 which reports the same behavior. Is there a reason at this point for continuing to use FXBlurView to handle the blur instead of just using a native blur element?

mwfire commented 7 years ago

Hey @pushchris, just to be sure: You are calling PopupDialog from the main thread, don't you? Can you replicate that with the PopupDialog example project as well?

Other than that, thanks for the PR, I will have to have a close look asap. As this introduces breaking changes, it requires a major version bump and updated documentation. There's 7000 apps using this pod by now, so I don't want to make the transition too painful ;)

mwfire commented 7 years ago

Also, I did move away from the visual effect views very early, as the blur radius is massive. :(

pushchris commented 7 years ago

@mwfire yes, everything is being called from the main thread. In the example project, if you go into the AppDelegate and uncomment the following lines: https://github.com/Orderella/PopupDialog/blob/355e048e5711dd98acb505407adba8fd0f2d0c48/Example/PopupDialog/AppDelegate.swift#L52-L58

Mainly just the liveBlur variable is needed, but that will cause the error mentioned.

As for the blur radius being so large, there are a couple of examples out there of how to set a custom radius for UIVisualEffectView (https://github.com/ML-Works/Bluuur) but you are right, it is a little dramatic.

mwfire commented 7 years ago

@pushchris, thanks a lot! I'll dive into this and update you asap. Thanks 👍

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.