diiiary / capacitor-plugin-ios-swipe-back

9 stars 25 forks source link

"UI API called on a background thread" #3

Open PowerOfM opened 4 years ago

PowerOfM commented 4 years ago

Hello, I've followed the installation steps (yarn add capacitor-plugin-ios-swipe-back and npx cap sync), and included the following setup code in the entry point of the app:

if (window.Capacitor && window.Capacitor.Plugins.IosSwipeBack) {
  window.Capacitor.Plugins.IosSwipeBack.enable()
    .then(res => console.log('swipe back enabled', res))
    .catch(err => console.error('error with swipe back', err))
}

The plugin works and the log shows "swipe back enabled", but it also shows what appears to be an exception:

⚡️  To Native ->  IosSwipeBack enable 6556699
=================================================================
Main Thread Checker: UI API called on a background thread: -[WKWebView setAllowsBackForwardNavigationGestures:]
PID: 6882, TID: 685526, Thread name: (none), Queue name: bridge, QoS: 0
Backtrace:
4   CapacitorPluginIosSwipeBack         0x0000000105f0085e $s27CapacitorPluginIosSwipeBack0cdE0C6enableyySo13CAPPluginCallCF + 366
5   CapacitorPluginIosSwipeBack         0x0000000105f00a54 $s27CapacitorPluginIosSwipeBack0cdE0C6enableyySo13CAPPluginCallCFTo + 68
6   Capacitor                           0x0000000105ce43ec $s9Capacitor9CAPBridgeC12handleJSCall4callyAA0D0C_tFyycfU_Tf2nnni_n + 748
7   Capacitor                           0x0000000105cb8000 $sIeg_IeyB_TR + 48
8   libdispatch.dylib                   0x0000000106cef8ac _dispatch_call_block_and_release + 12
9   libdispatch.dylib                   0x0000000106cf0a88 _dispatch_client_callout + 8
10  libdispatch.dylib                   0x0000000106cf7356 _dispatch_lane_serial_drain + 796
11  libdispatch.dylib                   0x0000000106cf8027 _dispatch_lane_invoke + 439
12  libdispatch.dylib                   0x0000000106d03e90 _dispatch_workloop_worker_thread + 882
13  libsystem_pthread.dylib             0x00007fff5dfa5a3d _pthread_wqthread + 290
14  libsystem_pthread.dylib             0x00007fff5dfa4b77 start_wqthread + 15
2020-11-10 18:51:13.351443-0800 App[6882:685526] [reports] Main Thread Checker: UI API called on a background thread: -[WKWebView setAllowsBackForwardNavigationGestures:]
PID: 6882, TID: 685526, Thread name: (none), Queue name: bridge, QoS: 0
Backtrace:
4   CapacitorPluginIosSwipeBack         0x0000000105f0085e $s27CapacitorPluginIosSwipeBack0cdE0C6enableyySo13CAPPluginCallCF + 366
5   CapacitorPluginIosSwipeBack         0x0000000105f00a54 $s27CapacitorPluginIosSwipeBack0cdE0C6enableyySo13CAPPluginCallCFTo + 68
6   Capacitor                           0x0000000105ce43ec $s9Capacitor9CAPBridgeC12handleJSCall4callyAA0D0C_tFyycfU_Tf2nnni_n + 748
7   Capacitor                           0x0000000105cb8000 $sIeg_IeyB_TR + 48
8   libdispatch.dylib                   0x0000000106cef8ac _dispatch_call_block_and_release + 12
9   libdispatch.dylib                   0x0000000106cf0a88 _dispatch_client_callout + 8
10  libdispatch.dylib                   0x0000000106cf7356 _dispatch_lane_serial_drain + 796
11  libdispatch.dylib                   0x0000000106cf8027 _dispatch_lane_invoke + 439
12  libdispatch.dylib                   0x0000000106d03e90 _dispatch_workloop_worker_thread + 882
13  libsystem_pthread.dylib             0x00007fff5dfa5a3d _pthread_wqthread + 290
14  libsystem_pthread.dylib             0x00007fff5dfa4b77 start_wqthread + 15
⚡️  TO JS {"error":0}
⚡️  [log] - swipe back enabled {"error":0}

XCode also shows a warning for Plugin.swift stating that the assignment to allowsBackForwardNavigationGestures should be done on the main thread.