50ButtonsEach / fliclib-ios

The fliclib framework for iOS
35 stars 5 forks source link

UI API called on a background thread #31

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi!

I'm integrating the Flic button into a Swift iOS project, and sometimes inconsistently, I get the following error:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 2403, TID: 1846784, Thread name: (none), Queue name: com.flicLib.queue, QoS: 0
Backtrace:
4   fliclib                             0x00000001033c3424 -[SCLFlicButton internal_buttonCharacteristicsWasUpdated:] + 588
5   fliclib                             0x00000001033c4d44 -[SCLFlicButton peripheral:didUpdateValueForCharacteristic:error:] + 304
6   fliclib                             0x00000001033b0f90 -[BCBPeripheral peripheral:didUpdateValueForCharacteristic:error:] + 452
7   CoreBluetooth                       0x000000018909ab4c <redacted> + 248
8   CoreBluetooth                       0x000000018909acac <redacted> + 132
9   CoreBluetooth                       0x0000000189096498 <redacted> + 364
10  CoreBluetooth                       0x0000000189090fc8 <redacted> + 208
11  CoreBluetooth                       0x000000018909f540 <redacted> + 60
12  libdispatch.dylib                   0x00000001040952cc _dispatch_call_block_and_release + 24
13  libdispatch.dylib                   0x000000010409528c _dispatch_client_callout + 16
14  libdispatch.dylib                   0x00000001040a3f80 _dispatch_queue_serial_drain + 696
15  libdispatch.dylib                   0x00000001040987ec _dispatch_queue_invoke + 332
16  libdispatch.dylib                   0x00000001040a3d9c _dispatch_queue_serial_drain + 212
17  libdispatch.dylib                   0x00000001040987ec _dispatch_queue_invoke + 332
18  libdispatch.dylib                   0x00000001040a4f6c _dispatch_root_queue_drain_deferred_wlh + 428
19  libdispatch.dylib                   0x00000001040ac020 _dispatch_workloop_worker_thread + 652
20  libsystem_pthread.dylib             0x000000018380af1c _pthread_wqthread + 932
21  libsystem_pthread.dylib             0x000000018380ab6c start_wqthread + 4

This doesn't seem to be originating from my own code, as I've double-checked all places where I interface with the UI, and wrapped properly so that it executes on main thread.

It occurs right after a buttonUp/Click event -- but not consistently.

AntonMeier commented 6 years ago

Hello, you are correct. There is one condition there that should have been dispatched to main. I will try to push an update as soon as possible.

AntonMeier commented 6 years ago

v1.2.2 should fix this issue. It only occurred if you had the button in lowLatency mode and connected longer than 5 minutes, which would explain why you only saw it occasionally .