Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

bug: UIApplication methods are called on background thread #486

Merged
merged 1 commit into from
Aug 16, 2017

Conversation

Ignigena
Copy link

@Ignigena Ignigena commented Aug 15, 2017

As long as RNFetchBlob is called inside of a mounted component, the issue doesn't present itself. However, if one of these methods are called from outside a mounted component, Xcode will complain about setNetworkActivityIndicatorVisible being called from a background thread:

Main Thread Checker: UI API called on a background thread: -[UIApplication setNetworkActivityIndicatorVisible:]
PID: 829, TID: 23395, Thread name: (none), Queue name: NSOperationQueue 0x1c043df80 (QOS: UNSPECIFIED), QoS: 0
Backtrace:
4   MyApp                               0x0000000101ff48b8 -[RNFetchBlobNetwork URLSession:task:didCompleteWithError:] + 356
5   CFNetwork                           0x0000000185b97b78 <redacted> + 72
6   Foundation                          0x0000000185e862c0 <redacted> + 16
7   Foundation                          0x0000000185dc6b70 <redacted> + 72
8   Foundation                          0x0000000185db6828 <redacted> + 868
9   libdispatch.dylib                   0x0000000102971d4c _dispatch_client_callout + 16
10  libdispatch.dylib                   0x000000010297e984 _dispatch_block_invoke_direct + 240
11  libdispatch.dylib                   0x0000000102971d4c _dispatch_client_callout + 16
12  libdispatch.dylib                   0x000000010297e984 _dispatch_block_invoke_direct + 240
13  libdispatch.dylib                   0x000000010297e860 dispatch_block_perform + 104
14  Foundation                          0x0000000185e87f98 <redacted> + 376
15  libdispatch.dylib                   0x0000000102971d4c _dispatch_client_callout + 16
16  libdispatch.dylib                   0x000000010297f9a0 _dispatch_continuation_pop + 624
17  libdispatch.dylib                   0x000000010297de48 _dispatch_async_redirect_invoke + 684
18  libdispatch.dylib                   0x0000000102984080 _dispatch_root_queue_drain + 616
19  libdispatch.dylib                   0x0000000102983db8 _dispatch_worker_thread4 + 68
20  libsystem_pthread.dylib             0x00000001841ff338 _pthread_wqthread + 1260
21  libsystem_pthread.dylib             0x00000001841fee40 start_wqthread + 4

Best practice is to always wrap these methods in a dispatch_async call to ensure they are called on the foreground thread.

@wkh237 wkh237 merged commit 6ab9ba0 into wkh237:0.10.9 Aug 16, 2017
@wkh237
Copy link
Owner

wkh237 commented Aug 16, 2017

@Ignigena , thanks for the PR 👍

danielsuo added a commit to danielsuo/react-native-fetch-blob that referenced this pull request Feb 13, 2018
* upstream/0.10.9:
  Fixed problem with type casting (wkh237#513)
  My proposed 0.10.9 changes (wkh237#489)
  wkh237#268 Cancelled task should not trigger `then` promise function
  Add ability to cancel android DownloadManager fetches (wkh237#502)
  Fix iOS initialization race condition (wkh237#499)
  prevent UIApplication methods from being called on background thread (wkh237#486)
  Implemenet fs.hash() -- wkh237#439 "Feature: Calculate file hash" (wkh237#476)
  I forgot one error string for the Android readFile() method (wkh237#475)
  Fix for wkh237#467 (wkh237#472)
  Fix for issue wkh237#468, wkh237#461, wkh237#460 and minor cleanup (wkh237#469)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants