Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread_policy_set(1) returned 46 #38

Closed
Cavallando opened this issue Feb 3, 2022 · 6 comments
Closed

thread_policy_set(1) returned 46 #38

Cavallando opened this issue Feb 3, 2022 · 6 comments

Comments

@Cavallando
Copy link

Hi there,

This library was super easy to setup and use so thank you!

Upon adding this library to our RN App we started seeing our Xcode logs flooded with:

thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46
thread_policy_set(1) returned 46

These logs start as soon as the app starts and do not end, even with no state updates on RN side.

I confirmed that removing react-native-ux-cam made the logs stop. Reporting this mainly because it makes debugging other things in Xcode like our own native modules and other libraries difficult.

Any help is much appreciated! Thanks!

@richardgroves
Copy link
Contributor

This is an internal OS log message that Apple have left on.

Setting this environment variable - https://stackoverflow.com/a/39461256/701926 - will stop it from filling your XCode logs.

AFAICS it is triggered by some thread querying in our deadlock detector, but it's not obvious which syscall is triggering it to report to Apple.

@Cavallando
Copy link
Author

Cavallando commented Feb 4, 2022

@richardgroves thanks for getting back to me!

Unfortunately none of the suggestions on that stack overflow worked for me, FWIW both OS_ACTIVITY_MODE and OS_ACTIVITY_DT_MODE disabled some logs as expected but specifically the thread_policy_set(1) returned 46 log is still prevalent.

Is it possible that this needs to be set in ux-cams project and shipped with that setting? I hear you on the non-obvious sys call, but IMHO hiding the log doesn't feel like the appropriate fix for this. At least not for the users of the package.

Also I understand you all might be blocked on this by Apple things.

EDIT: For more understanding, I've also opened up a question on Apple developer forum here

@richardgroves
Copy link
Contributor

Hi @Cavallando Sorry to hear the suggested solutions isn't working for you.
Can I just check - are you seeing this on an M1 / Apple Silicon computer rather than an Intel based Mac?
Is it just on Simulators or actual devices too?

@Cavallando
Copy link
Author

No worries at all @richardgroves, appreciate the quick responses!

I'm currently on an M1 Max, macOS 12.1, running Xcode 13.2.1. When running under our debug scheme, I am only seeing the thread policy logs on Simulator and not on Physical device

@Cavallando
Copy link
Author

I'm still following along with some tips from apple developer forum post, this doesnt feel like the proper fix still but to hide these logs you can put the following in your AppDelegate.m to hide stderr output specifically:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   ...other code
   BOOL success = dup2(fd, STDERR_FILENO) >= 0;
   assert(success);
}

I will post back here with more updates once I have them!

@yotamishak
Copy link

yotamishak commented Jul 6, 2022

@Cavallando

I can't even imagine the amount of time you saved me by opening this issue!! Thank you, great find!

Also for the record, I am running on M1 pro, macOS 12.4, Xcode 13.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants