Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High CPU load of diagnosticd process while running React Native app on iOS simulator

I have been developing with React Native for some years now but the following behaviour only started recently. After running any React Native app on the iOS simulator (either directly from Xcode or via react-native run-ios) the diagnosticd process slowly increases CPU usage to 150% after a couple of minutes. My laptop becomes unusable because the process is also eating up all file handles of the OS. Googling around only points to excessive logging, but either I'm not looking in the right location or no huge amounts of logging is taking place.

Closing the app by pressing the Home button in the simulator immediately stops the high cpu load.

Is anybody also experiencing this? How can I find out what is causing this?

MacOS Catalina version 10.15.3, Xcode version 11.4, React version 16.9.0, React Native version 0.61.5, Simulator iPhone 11 (iOS 13.4)

like image 325
mvandillen Avatar asked Mar 27 '20 11:03

mvandillen


1 Answers

I think I found the solution. Xcode was logging a lot of lines containing: xcode nw_connection_get_connected_socket Client called nw_connection_get_connected_socket on unconnected nw_connection. This started after some update of Xcode a couple of months ago. Disabling the logging has stopped the diagnosticd process from eating up all OS resources. I followed these instructions: Hide strange unwanted Xcode logs

Basically comes down to adding an environment variable OS_ACTIVITY_MODE with value disable to the Scheme (Run).

What the real reason for the logging is I still don't know. It looks like some sort of polling from React Native.

like image 185
mvandillen Avatar answered Oct 04 '22 05:10

mvandillen