mostafa-mansour1 / previewAnyFile

Cordova Plugin to preview any file in native mode by providing the local or external URL
MIT License
33 stars 31 forks source link

UI API called on a background thread: -[UIViewController init] #26

Closed Siedlerchr closed 3 years ago

Siedlerchr commented 3 years ago

Hi,

I found another smalll issue: in Thread Checker: UI API called on a background thread: -[UIViewController init] The fix is simple. The init of the PrevieControl has to be moved to the Main Thread.

Backtrace:
4   myapp                          0x0000000104890710 $sSo19QLPreviewControllerCABycfcTO + 24
5   myapp                          0x0000000104888800 $sSo19QLPreviewControllerCABycfC + 32
6   myapp                          0x0000000104889e34 $s10myapp14PreviewAnyFileC11previewPath8_commandySo20CDVInvokedUrlCommandC_tFySb_10Foundation3URLVSgSo7NSErrorCSgtcfU_ + 672
7   myapp                          0x000000010488f970 $s10myapp14PreviewAnyFileC12downloadfile8withName04fileG010completionySS_SSySb_10Foundation3URLVSgSo7NSErrorCSgtctFyAK_So13NSURLResponseCSgs5Error_pSgtcfU_ + 1292
8   myapp                          0x000000010488fdf4 $s10Foundation3URLVSgSo13NSURLResponseCSgs5Error_pSgIegngg_So5NSURLCSgAGSo7NSErrorCSgIeyByyy_TR + 412
9   CFNetwork                           0x0000000186496400 CFNetServiceBrowserSearchForServices + 75244
10  CFNetwork                           0x00000001864abc4c _CFHTTPMessageSetResponseProxyURL + 18640
11  libdispatch.dylib                   0x0000000105fc40b4 _dispatch_call_block_and_release + 32
12  libdispatch.dylib                   0x0000000105fc5de0 _dispatch_client_callout + 20
13  libdispatch.dylib                   0x0000000105fcdef0 _dispatch_lane_serial_drain + 788
14  libdispatch.dylib                   0x0000000105fced48 _dispatch_lane_invoke + 496
15  libdispatch.dylib                   0x0000000105fdba50 _dispatch_workloop_worker_thread + 1600
16  libsystem_pthread.dylib             0x00000001d0dba7a4 _pthread_wqthread + 276
17  libsystem_pthread.dylib             0x00000001d0dc174c start_wqthread + 8
2021-06-10 11:02:00.295861+0200 myapp[1102:422107] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController init]
PID: 1102, TID: 422107, Thread name: (none), Queue name: com.apple.NSURLSession-delegate, QoS: 0
Backtrace:
4   myapp                          0x0000000104890710 $sSo19QLPreviewControllerCABycfcTO + 24
5   myapp                          0x0000000104888800 $sSo19QLPreviewControllerCABycfC + 32
6   myapp                          0x0000000104889e34 $s10myapp14PreviewAnyFileC11previewPath8_commandySo20CDVInvokedUrlCommandC_tFySb_10Foundation3URLVSgSo7NSErrorCSgtcfU_ + 672
7   myapp                          0x000000010488f970 $s10myapp14PreviewAnyFileC12downloadfile8withName04fileG010completionySS_SSySb_10Foundation3URLVSgSo7NSErrorCSgtctFyAK_So13NSURLResponseCSgs5Error_pSgtcfU_ + 1292
8   myapp                          0x000000010488fdf4 $s10Foundation3URLVSgSo13NSURLResponseCSgs5Error_pSgIegngg_So5NSURLCSgAGSo7NSErrorCSgIeyByyy_TR + 412
9   CFNetwork                           0x0000000186496400 CFNetServiceBrowserSearchForServices + 75244
10  CFNetwork                           0x00000001864abc4c _CFHTTPMessageSetResponseProxyURL + 18640
11  libdispatch.dylib                   0x0000000105fc40b4 _dispatch_call_block_and_release + 32
12  libdispatch.dylib                   0x0000000105fc5de0 _dispatch_client_callout + 20
13  libdispatch.dylib                   0x0000000105fcdef0 _dispatch_lane_serial_drain + 788
14  libdispatch.dylib                   0x0000000105fced48 _dispatch_lane_invoke + 496
15  libdispatch.dylib                   0x0000000105fdba50 _dispatch_workloop_worker_thread + 1600
16  libsystem_pthread.dylib             0x00000001d0dba7a4 _pthread_wqthread + 276
17  libsystem_pthread.dylib             0x00000001d0dc174c start_wqthread + 8
2021-06-10 11:02:10.089118+0200 myapp[1102:421886] open status SUCCESS