diff --git a/rnmodules/react-native-kb/ios/Kb.h b/rnmodules/react-native-kb/ios/Kb.h index 8c919fbfa7dc..e27b59108a4d 100644 --- a/rnmodules/react-native-kb/ios/Kb.h +++ b/rnmodules/react-native-kb/ios/Kb.h @@ -24,3 +24,6 @@ FOUNDATION_EXPORT void KbSetDeviceToken(NSString *token); FOUNDATION_EXPORT void KbSetInitialNotification(NSDictionary *notification); FOUNDATION_EXPORT void KbEmitPushNotification(NSDictionary *notification); FOUNDATION_EXPORT NSDictionary *KbGetAndClearInitialNotification(void); + +// Init result - stored for inclusion in ReadArr error logs +FOUNDATION_EXPORT void KbSetInitResult(NSString *result); diff --git a/rnmodules/react-native-kb/ios/Kb.mm b/rnmodules/react-native-kb/ios/Kb.mm index 0673eaf9aaee..7f9805b06697 100644 --- a/rnmodules/react-native-kb/ios/Kb.mm +++ b/rnmodules/react-native-kb/ios/Kb.mm @@ -78,6 +78,7 @@ - (void)dealloc { static BOOL kbPasteImageEnabled = NO; static NSString *kbStoredDeviceToken = nil; static NSDictionary *kbInitialNotification = nil; +static NSString *kbInitResult = nil; @interface RCTBridge (JSIRuntime) - (void *)runtime; @@ -396,10 +397,11 @@ - (NSDictionary *)getConstants { } if (consecutiveErrors <= 5 || consecutiveErrors % 50 == 0) { __typeof__(self) strongSelf = weakSelf; - os_log(OS_LOG_DEFAULT, "ReadArr loop[%llu] error streak=%llu total=%llu domain=%{public}s code=%ld desc=%{public}s self=%p bridge=%p jsRuntime=%p currentRuntime=%p", + os_log(OS_LOG_DEFAULT, "ReadArr loop[%llu] error streak=%llu total=%llu domain=%{public}s code=%ld desc=%{public}s initResult=%{public}s self=%p bridge=%p jsRuntime=%p currentRuntime=%p", (unsigned long long)readLoopGen, (unsigned long long)consecutiveErrors, (unsigned long long)totalErrors, KBStringOrNil(error.domain), (long)error.code, - KBStringOrNil(error.localizedDescription), strongSelf, strongSelf.bridge, + KBStringOrNil(error.localizedDescription), KBStringOrNil(kbInitResult), + strongSelf, strongSelf.bridge, strongSelf ? [strongSelf javaScriptRuntimePointer] : nil, currentRuntime); } // Back off on error to avoid spinning at ~35K/sec and starving the main thread CPU @@ -752,3 +754,7 @@ void KbEmitPushNotification(NSDictionary *notification) { kbInitialNotification = nil; return notification; } + +void KbSetInitResult(NSString *result) { + kbInitResult = result; +} diff --git a/shared/ios/Keybase/AppDelegate.swift b/shared/ios/Keybase/AppDelegate.swift index 5bdf4a3075be..7642a613be33 100644 --- a/shared/ios/Keybase/AppDelegate.swift +++ b/shared/ios/Keybase/AppDelegate.swift @@ -254,15 +254,17 @@ public class AppDelegate: ExpoAppDelegate, UNUserNotificationCenterDelegate, securityAccessGroupOverride, nil, nil, systemVer, isIPad, nil, isIOS, shareIntentDonator, &err ) if let err { + let initResult = "FAILED: \(err.localizedDescription) (code=\(err.code) domain=\(err.domain))" + KbSetInitResult(initResult) // Log to system log with public annotation so it's not redacted in logarchive. os_log( .error, log: AppDelegate.initLog, "KeybaseInit FAILED: %{public}@ (code=%ld domain=%{public}@)", err.localizedDescription, err.code, err.domain) // Also write to ios.log so it's captured in xcappdata even without a device attached. - self.writeStartupTimingLog( - "KeybaseInit FAILED: \(err.localizedDescription) (code=\(err.code) domain=\(err.domain))") + self.writeStartupTimingLog("KeybaseInit \(initResult)") } else { + KbSetInitResult("succeeded") self.writeStartupTimingLog("KeybaseInit succeeded") }