react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Xcode 14.0 beta 4 reports "Hang Risk" in RCTWebSocket

Open lucasjohnston opened this issue 2 years ago • 33 comments

Description

Error reported: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions. Using Xcode Version 14.0 beta 4 (14A5284g).

Screenshot 2022-08-12 at 17 44 11

Seemingly originates from RCTSRWebSocket.m

Version

0.66.3

Output of npx react-native info

info Fetching system and libraries information... System: OS: macOS 12.5 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 186.13 MB / 16.00 GB Shell: 5.8 - /usr/local/bin/zsh Binaries: Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node Yarn: 1.22.10 - ~/src/github.com/umbermoney/daisy/node_modules/.bin/yarn npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /Users/lucas/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 21, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2 System Images: android-29 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 13.3/13E113 - /usr/bin/xcodebuild Languages: Java: 1.8.0_251 - /Users/lucas/.jenv/shims/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.3 => 0.66.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  1. Create react-native project on Xcode Version 14.0 beta 4 (14A5284g)
  2. Run application

Snack, code example, screenshot, or link to a repository

https://github.com/facebook/react-native/blob/6fcfe2e1b35e9bdf319bcdc1647c8c0d997b58c7/Libraries/WebSocket/RCTSRWebSocket.m#L1636

lucasjohnston avatar Aug 12 '22 16:08 lucasjohnston

Any movement on this? Our app is similarly hamstrung after upgrade to iOS16

titanium-cranium avatar Sep 29 '22 06:09 titanium-cranium

Facing the same issue on iOS 15.x and iOS 16 on Xcode 14.0.1 Any alternate fix to at least patch this issue until we wait for a permanent fix?

Quadrified avatar Sep 29 '22 11:09 Quadrified

Try clone the new repo for your project!

xuannam12 avatar Sep 30 '22 07:09 xuannam12

Facing the same issue on iOS 15.x and iOS 16 on Xcode 14.0.1. I think there is something wrong with the generated FBReactNativeSpec code.

muhabutt avatar Sep 30 '22 20:09 muhabutt

This falls under the same category as discussed here: https://github.com/realm/realm-core/issues/5697

The difference is that this inversion is triggered by a dispatch group but it's the same problem -- the threads in the dispatch group are not running at a QoS higher than "Default". For folks who work on Websocket, there are resolution strategies mentioned in https://github.com/realm/realm-core/issues/5697.

hamzasohail avatar Sep 30 '22 22:09 hamzasohail

any updates on this?

costea93 avatar Oct 05 '22 17:10 costea93

Any updates on this issue, I can reproduce this bug on Fresh react native 0.70.2.

muhabutt avatar Oct 10 '22 05:10 muhabutt

the same error

bodrius avatar Oct 19 '22 17:10 bodrius

same error

xiongxiongjiang avatar Oct 25 '22 06:10 xiongxiongjiang

node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m:1632: warning run: Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_DEFAULT. Investigate ways to avoid priority inversions at:

- (NSRunLoop *)runLoop
{
  dispatch_group_wait(_waitGroup, DISPATCH_TIME_FOREVER);
  return _runLoop;
}

xiongxiongjiang avatar Oct 25 '22 06:10 xiongxiongjiang

+1

alessioemireni avatar Oct 25 '22 08:10 alessioemireni

+1 This seems present on a Fresh RN upgrade

+1 I cannot connect to the Web Socket in the useEffect() triggered by App State after returning from background state Need to move to the other view and back to refresh my app

Xcode 14.0.1

mmelk avatar Oct 31 '22 16:10 mmelk

+1 who can help to fix this issue?

SmileYang966 avatar Nov 01 '22 08:11 SmileYang966

same error

xclidongbo avatar Nov 02 '22 09:11 xclidongbo

+1

c-shimmer avatar Nov 04 '22 01:11 c-shimmer

is there any solution?

xueqiulou avatar Nov 07 '22 08:11 xueqiulou

Hey guys. Please upvote to the original post instead of adding a +1 comment if you have the same problem or interest this post.

JeffGuKang avatar Nov 08 '22 06:11 JeffGuKang

having exactly the same issue. Any updates?

clemente-xyz avatar Nov 09 '22 10:11 clemente-xyz

this just popped to me today after running a pod install

rmoura-92 avatar Nov 09 '22 15:11 rmoura-92

Screenshot 2022-11-09 at 15 34 21 this worked for me as temp measure

described here https://developer.apple.com/documentation/xcode/diagnosing-performance-issues-early

rmoura-92 avatar Nov 09 '22 15:11 rmoura-92

Screenshot 2022-11-09 at 15 34 21 this worked for me

described here https://developer.apple.com/documentation/xcode/diagnosing-performance-issues-early

You just turned off the checker, that doesn't mean the underlying issue is solved.

voloshink avatar Nov 12 '22 20:11 voloshink

I got this too. XCode 14.1. RN 0.69.5 Is anyone actually experiencing any problems from this? Could it be a pre-existing non-issue that XCode just started complaining about?

bjornmosten avatar Nov 15 '22 15:11 bjornmosten

I don't work on React but as I mentioned in my comment above, this issue is pointing to a priority inversion. Priority inversions won't crash your program but can cause performance issues especially when system is under heavy resource contention. This inversion is coming from the React framework itself. Folks who maintain the React framework should audit their usage of dispatch_group_wait -- it's a primitive that doesn't provide priority inversion avoidance.The link (https://developer.apple.com/documentation/xcode/diagnosing-performance-issues-early) explains how these inversions should be addressed.

As for app developers who are seeing this (because they are using React), they should keep an eye on whether this inversion is causing hangs in their app for their app users. If it is, you probably want to deep dive more in the architecture of your app to avoid this inversion.

hamzasohail avatar Nov 15 '22 17:11 hamzasohail

I started having this issue out of the blue. Originally I think it came up when adding a new dependency (react-native-mixpanel) but now im having the issue on all my branches, even without that dep.

matthewmturner avatar Dec 02 '22 15:12 matthewmturner

I get this same error only when running to device. Not happening when building to an iPhone simulator.

System: OS: macOS 12.5.1 CPU: (10) arm64 Apple M1 Max Memory: 3.67 GB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.2.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 9.2.0 - /opt/homebrew/bin/npm Watchman: 2022.12.05.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Crare avatar Dec 12 '22 10:12 Crare

I had the same problem ( and I finally fixed it without really knowing why..., probably an indexing issue from XCODE 14).

If may be it can help you, these are the steps I follow : 1) I cleaned the build folder from XCODE (Product > Clean Build Folder) 2) I removed the DerivedData folder in ~/Library/Developer/Xcode/DerivedData 3) I restarted my computer

After that, I opened my app workspace from XCODE, a file indexing process started and took a very long time (something like 15 or 20 minutes).

Once indexing process finished, I tried to build again and VOILA, this time it worked !

I really hope it will help you.

Regards,

Jean-Baptiste

My system: OS: macOS 12.6 Monterey CPU: 1.8 GHz Intel Core i5 Memory: 8 GB 1600 Mhz DDR3 Node : v16.17.1 Xcode: 14.0.1 React: 18.1.0 React-native: 0.70.6

jbb-dev avatar Dec 19 '22 13:12 jbb-dev

I had the same problem ( and I finally fixed it without really knowing why..., probably an indexing issue from XCODE 14).

If may be it can help you, these are the steps I follow : 1) I cleaned the build folder from XCODE (Product > Clean Build Folder) 2) I removed the DerivedData folder in ~/Library/Developer/Xcode/DerivedData 3) I restarted my computer

After that, I opened my app workspace from XCODE, a file indexing process started and took a very long time (something like 15 or 20 minutes).

Once indexing process finished, I tried to build again and VOILA, this time it worked !

I really hope it will help you.

Regards,

Jean-Baptiste

My system: OS: macOS 12.6 Monterey CPU: 1.8 GHz Intel Core i5 Memory: 8 GB 1600 Mhz DDR3 Node : v16.17.1 Xcode: 14.0.1 React: 18.1.0 React-native: 0.70.6

Thank you! It works for me!

rezkiy37 avatar Dec 28 '22 13:12 rezkiy37

I had the same problem ( and I finally fixed it without really knowing why..., probably an indexing issue from XCODE 14).

If may be it can help you, these are the steps I follow : 1) I cleaned the build folder from XCODE (Product > Clean Build Folder) 2) I removed the DerivedData folder in ~/Library/Developer/Xcode/DerivedData 3) I restarted my computer

After that, I opened my app workspace from XCODE, a file indexing process started and took a very long time (something like 15 or 20 minutes).

Once indexing process finished, I tried to build again and VOILA, this time it worked !

I really hope it will help you.

Regards,

Jean-Baptiste

My system: OS: macOS 12.6 Monterey CPU: 1.8 GHz Intel Core i5 Memory: 8 GB 1600 Mhz DDR3 Node : v16.17.1 Xcode: 14.0.1 React: 18.1.0 React-native: 0.70.6

Thanks @jbb-dev

For those looking for the derivedData folder, from Xcode 6 you can find the path under ~/Users/YOUR_USERNAME/Library/Developer/Xcode/DerivedData

Also you can go to Xcode's settings and on the locations tab you can see your derived data path.

The folder is hidden, make sure to press Shift + Cmd + . to show the hidden folders.

RubenPM-dev avatar Jan 20 '23 10:01 RubenPM-dev

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

xueqiulou avatar Jan 20 '23 10:01 xueqiulou