36

When debugging app in Xcode 9 beta while it's running on iPhone with iOS 11 beta installed, I started to notice following messages when performing networking calls:

[] network_config_register_boringssl_log_debug_updates Failed to register for BoringSSL log debug updates
[BoringSSL] Function boringssl_context_get_peer_npn_data: line 1212 Peer's advertised NPN data is NULL or empty

Any idea what is causing this?

uerceg
  • 4,419
  • 6
  • 43
  • 63

2 Answers2

14

UPD There's actually much more convenient way to silence certain logs:

xcrun simctl spawn booted\
  log config\
  --subsystem com.apple.network\
  --category boringssl\
  --mode "level:off"

These annoying messages come from libboringssl.dylib :: boringssl_metrics_log_event:

int boringssl_metrics_log_event(...) {
  ...
  if (g_boringssl_log != nil && os_log_type_enabled(g_boringssl_log, OS_LOG_TYPE_ERROR) {
    os_log_error(g_boringssl_log, "%s(%d) Failed to log metrics", "boringssl_metrics_log_metric_block_invoke", 151);
  }
  ...
}

An easy way to silence these messages is to nullify g_boringssl_log.

g_boringssl_log is a global variable:

os_log_t g_boringssl_log = nil;

It gets initialized in boringssl_log_open:

void boringssl_log_open() {
   static dispatch_token onceToken = nil;
   dispatch_once(onceToken, ^{
     g_boringssl_log = os_log_create("com.apple.network", "boringssl");
   });
}

IMO the easiest solution to nullify g_boring_ssl is to skip the execution of dispatch_once.

That could be achieved with setting a breakpoint to __boringssl_log_open_block_invoke with action thread return. This breakpoint will be called once thanks to dispatch_once, but the function's body will not be executed because of immediate thread return. So g_boringssl_log will never be initialized, and there will be no logs in the Console.

PS I might also recommend setting a similar breakpoint for ____nwlog_connection_log_block_invoke from libnetwork.dylib.

An example of breakpoint

storoj
  • 1,244
  • 1
  • 13
  • 20
12

Open the Xcode Scheme editor and add a new environment variable OS_ACTIVITY_MODE and set to disable.

NOTE: Beware, this will disable ALL NSLog outputs, not just the BoringSSL messages.

enter image description here

Elijah
  • 7,883
  • 2
  • 53
  • 49
joshbillions
  • 1,025
  • 8
  • 18
  • 10
    What does this do exactly? – BergerBytes Jun 28 '17 at 20:23
  • 55
    Why is this an accepted answer? The question was "What is causing this?", not "How do I hide it?" – dbn Jul 05 '17 at 16:45
  • 4
    This answer suppresses the logs, but there is no explanation about the actual error and there is no mention about exact fix for it. – Bhanu Prakash Jul 28 '17 at 09:05
  • 18
    This solution should not be accepted - it causes important diagnostic messages to disappear. – David Airapetyan Sep 15 '17 at 16:14
  • In addition to hiding NSLog outputs as other have mentioned, it also hides os_log outputs. Beware. – Justin Vallely May 12 '22 at 21:49
  • This approach seems to stop all NSLog logging, which is a problem. For a more nuanced approach that builds on this answer, above, but does not eliminate all NSLog logging, see the answer by cduhn at [Hide strange unwanted Xcode 8 logs](https://stackoverflow.com/questions/37800790/hide-strange-unwanted-xcode-8-logs). – Matthew Rips Jul 01 '17 at 13:45