43

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,637
  • 6
  • 45
  • 63

3 Answers3

48

UPDATE

There's actually a very convenient way to silence certain logs for a specific simulator:

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

It is also recommended to silence other common non-important logs as well:

xcrun simctl spawn booted log config --subsystem com.apple.CoreBluetooth --mode level:off
xcrun simctl spawn booted log config --subsystem com.apple.CoreTelephony --mode level:off

Original answer (background)

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

Dejan Skledar
  • 11,280
  • 7
  • 44
  • 70
storoj
  • 1,851
  • 2
  • 18
  • 25
7

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
  • 8,381
  • 2
  • 55
  • 49
joshbillions
  • 1,048
  • 8
  • 19
  • 12
    What does this do exactly? – BergerBytes Jun 28 '17 at 20:23
  • 61
    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
  • 5
    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
  • 22
    This solution should not be accepted - it causes important diagnostic messages to disappear. – David Airapetyan Sep 15 '17 at 16:14
  • 1
    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
  • 3
    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
  • 1
    This will just silence all system logs, even the ones that you need to see. – Sophy Swicz Jun 23 '22 at 14:45
  • Sorry guys, I asked this question a while ago and now revisited it after quite some time and noticed new proper answer. Marked it as an accepted one. – uerceg Oct 19 '22 at 08:03
0
  • Open Xcode and select your project.
  • Go to the "Project Navigator" and select the root project node.
  • Select the "General" tab at the top of the project editor.
  • Scroll down to the "Linked Frameworks and Libraries" section.
  • Look for the library you want to check for updates (e.g. BoringSSL) and find the version number listed next to it.
  • Search for the latest version of that library online, either on the library's official website or on a package manager such as CocoaPods or Carthage.
  • Compare the version number you found in Xcode with the latest version available online.
  • If there is a newer version available, follow the steps provided by the library or package manager to update to the latest version.