diff --git a/packages/react-native/ios/.bugsnag-cocoa-version b/packages/react-native/ios/.bugsnag-cocoa-version index 272a2cdf3..e203d8fb2 100644 --- a/packages/react-native/ios/.bugsnag-cocoa-version +++ b/packages/react-native/ios/.bugsnag-cocoa-version @@ -1 +1 @@ -c218246f4df20784a81638a288e2b76b939fdd35 +a6596e573b5979b83c84cd4ab29a5bf5b2da9648 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json index 6385e0e41..8d3ab71c8 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json @@ -1,6 +1,6 @@ { "name": "Bugsnag", - "version": "6.1.7", + "version": "6.2.2", "summary": "The Bugsnag crash reporting framework for Apple platforms.", "homepage": "https://bugsnag.com", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v6.1.7" + "tag": "v6.2.2" }, "frameworks": [ "Foundation", diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj index 6e58d6a76..a704ac71a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj @@ -103,9 +103,8 @@ 0089674E2486D43700DC48C2 /* BugsnagPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C72486D43600DC48C2 /* BugsnagPluginTest.m */; }; 0089674F2486D43700DC48C2 /* BugsnagPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C72486D43600DC48C2 /* BugsnagPluginTest.m */; }; 008967502486D43700DC48C2 /* BugsnagPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C72486D43600DC48C2 /* BugsnagPluginTest.m */; }; - 008967512486D43700DC48C2 /* BSGOutOfMemoryWatchdogTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C82486D43600DC48C2 /* BSGOutOfMemoryWatchdogTests.m */; }; - 008967522486D43700DC48C2 /* BSGOutOfMemoryWatchdogTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C82486D43600DC48C2 /* BSGOutOfMemoryWatchdogTests.m */; }; - 008967532486D43700DC48C2 /* BSGOutOfMemoryWatchdogTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C82486D43600DC48C2 /* BSGOutOfMemoryWatchdogTests.m */; }; + 008967512486D43700DC48C2 /* BSGOutOfMemoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C82486D43600DC48C2 /* BSGOutOfMemoryTests.m */; }; + 008967532486D43700DC48C2 /* BSGOutOfMemoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C82486D43600DC48C2 /* BSGOutOfMemoryTests.m */; }; 008967542486D43700DC48C2 /* BugsnagOnCrashTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C92486D43600DC48C2 /* BugsnagOnCrashTest.m */; }; 008967552486D43700DC48C2 /* BugsnagOnCrashTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C92486D43600DC48C2 /* BugsnagOnCrashTest.m */; }; 008967562486D43700DC48C2 /* BugsnagOnCrashTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 008966C92486D43600DC48C2 /* BugsnagOnCrashTest.m */; }; @@ -632,10 +631,6 @@ 00AD1F062486A17900A27979 /* RegisterErrorData.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF52486A17600A27979 /* RegisterErrorData.m */; }; 00AD1F072486A17900A27979 /* RegisterErrorData.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF52486A17600A27979 /* RegisterErrorData.m */; }; 00AD1F082486A17900A27979 /* RegisterErrorData.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF52486A17600A27979 /* RegisterErrorData.m */; }; - 00AD1F0C2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF72486A17700A27979 /* BSGOutOfMemoryWatchdog.m */; }; - 00AD1F0D2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF72486A17700A27979 /* BSGOutOfMemoryWatchdog.m */; }; - 00AD1F0E2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF72486A17700A27979 /* BSGOutOfMemoryWatchdog.m */; }; - 00AD1F0F2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF72486A17700A27979 /* BSGOutOfMemoryWatchdog.m */; }; 00AD1F102486A17900A27979 /* BugsnagSessionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */; }; 00AD1F112486A17900A27979 /* BugsnagSessionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */; }; 00AD1F122486A17900A27979 /* BugsnagSessionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */; }; @@ -645,9 +640,6 @@ 00AD1F172486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 00AD1F182486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 00AD1F192486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 00AD1F1D2486A17900A27979 /* BSGOutOfMemoryWatchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFC2486A17800A27979 /* BSGOutOfMemoryWatchdog.h */; }; - 00AD1F1E2486A17900A27979 /* BSGOutOfMemoryWatchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFC2486A17800A27979 /* BSGOutOfMemoryWatchdog.h */; }; - 00AD1F1F2486A17900A27979 /* BSGOutOfMemoryWatchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFC2486A17800A27979 /* BSGOutOfMemoryWatchdog.h */; }; 00AD1F212486A17900A27979 /* BugsnagErrorReportSink.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFD2486A17800A27979 /* BugsnagErrorReportSink.h */; }; 00AD1F222486A17900A27979 /* BugsnagErrorReportSink.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFD2486A17800A27979 /* BugsnagErrorReportSink.h */; }; 00AD1F232486A17900A27979 /* Bugsnag.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EFE2486A17800A27979 /* Bugsnag.m */; }; @@ -759,7 +751,9 @@ CB10E548250BAD6100AF5824 /* BSGCachesDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = CB10E543250BAD6100AF5824 /* BSGCachesDirectory.m */; }; CB10E549250BAD6100AF5824 /* BSGCachesDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = CB10E543250BAD6100AF5824 /* BSGCachesDirectory.m */; }; CB9103642502320A00E9D1E2 /* BugsnagApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */; }; - CB9103662502404000E9D1E2 /* BSGSerializationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103652502404000E9D1E2 /* BSGSerializationTest.m */; }; + CBA2249B251E429C00B87416 /* TestSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = CBA2249A251E429C00B87416 /* TestSupport.m */; }; + CBA2249C251E429C00B87416 /* TestSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = CBA2249A251E429C00B87416 /* TestSupport.m */; }; + CBA2249D251E429C00B87416 /* TestSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = CBA2249A251E429C00B87416 /* TestSupport.m */; }; CBAA6AB5250BA01D00713376 /* BugsnagKVStore.c in Sources */ = {isa = PBXBuildFile; fileRef = CBAA6AB4250BA01D00713376 /* BugsnagKVStore.c */; }; CBAA6AB6250BA01D00713376 /* BugsnagKVStore.c in Sources */ = {isa = PBXBuildFile; fileRef = CBAA6AB4250BA01D00713376 /* BugsnagKVStore.c */; }; CBAA6AB7250BA01D00713376 /* BugsnagKVStore.c in Sources */ = {isa = PBXBuildFile; fileRef = CBAA6AB4250BA01D00713376 /* BugsnagKVStore.c */; }; @@ -774,6 +768,13 @@ CBAB4DD92510D2460092CBAA /* BugsnagKVStoreObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = CBAB4DD42510D2460092CBAA /* BugsnagKVStoreObjC.m */; }; CBAB4DDA2510D2460092CBAA /* BugsnagKVStoreObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = CBAB4DD42510D2460092CBAA /* BugsnagKVStoreObjC.m */; }; CBAB4DDB2510D2460092CBAA /* BugsnagKVStoreObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = CBAB4DD42510D2460092CBAA /* BugsnagKVStoreObjC.m */; }; + CBB0928C2519F891007698BC /* BugsnagSystemState.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB0928A2519F891007698BC /* BugsnagSystemState.m */; }; + CBB0928D2519F891007698BC /* BugsnagSystemState.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB0928A2519F891007698BC /* BugsnagSystemState.m */; }; + CBB0928E2519F891007698BC /* BugsnagSystemState.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB0928A2519F891007698BC /* BugsnagSystemState.m */; }; + CBB0928F2519F891007698BC /* BugsnagSystemState.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB0928A2519F891007698BC /* BugsnagSystemState.m */; }; + CBB092902519F891007698BC /* BugsnagSystemState.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB0928B2519F891007698BC /* BugsnagSystemState.h */; }; + CBB092912519F891007698BC /* BugsnagSystemState.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB0928B2519F891007698BC /* BugsnagSystemState.h */; }; + CBB092922519F891007698BC /* BugsnagSystemState.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB0928B2519F891007698BC /* BugsnagSystemState.h */; }; CBCF77A325010648004AF22A /* BSGJSONSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = CBCF77A125010648004AF22A /* BSGJSONSerialization.h */; }; CBCF77A425010648004AF22A /* BSGJSONSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = CBCF77A125010648004AF22A /* BSGJSONSerialization.h */; }; CBCF77A525010648004AF22A /* BSGJSONSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = CBCF77A125010648004AF22A /* BSGJSONSerialization.h */; }; @@ -906,7 +907,6 @@ E746298F24890D3200F92D67 /* BSG_KSCrashType.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008969482486DAD000DC48C2 /* BSG_KSCrashType.h */; }; E746299024890D3200F92D67 /* BSG_KSCrashIdentifier.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0089694A2486DAD000DC48C2 /* BSG_KSCrashIdentifier.h */; }; E746299124890D3200F92D67 /* Private.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; }; - E746299424890D3200F92D67 /* BSGOutOfMemoryWatchdog.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00AD1EFC2486A17800A27979 /* BSGOutOfMemoryWatchdog.h */; }; E746299524890D3200F92D67 /* BugsnagCrashSentry.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00AD1F002486A17900A27979 /* BugsnagCrashSentry.h */; }; E746299624890D3200F92D67 /* BugsnagSessionTracker.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */; }; E746299724890D3200F92D67 /* BugsnagErrorReportSink.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00AD1EFD2486A17800A27979 /* BugsnagErrorReportSink.h */; }; @@ -1030,7 +1030,6 @@ E746298F24890D3200F92D67 /* BSG_KSCrashType.h in CopyFiles */, E746299024890D3200F92D67 /* BSG_KSCrashIdentifier.h in CopyFiles */, E746299124890D3200F92D67 /* Private.h in CopyFiles */, - E746299424890D3200F92D67 /* BSGOutOfMemoryWatchdog.h in CopyFiles */, E746299524890D3200F92D67 /* BugsnagCrashSentry.h in CopyFiles */, E746299624890D3200F92D67 /* BugsnagSessionTracker.h in CopyFiles */, E746299724890D3200F92D67 /* BugsnagErrorReportSink.h in CopyFiles */, @@ -1075,7 +1074,7 @@ 008966C52486D43600DC48C2 /* BugsnagUserTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagUserTest.m; sourceTree = ""; }; 008966C62486D43600DC48C2 /* BSGConnectivityTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSGConnectivityTest.m; sourceTree = ""; }; 008966C72486D43600DC48C2 /* BugsnagPluginTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagPluginTest.m; sourceTree = ""; }; - 008966C82486D43600DC48C2 /* BSGOutOfMemoryWatchdogTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSGOutOfMemoryWatchdogTests.m; sourceTree = ""; }; + 008966C82486D43600DC48C2 /* BSGOutOfMemoryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSGOutOfMemoryTests.m; sourceTree = ""; }; 008966C92486D43600DC48C2 /* BugsnagOnCrashTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagOnCrashTest.m; sourceTree = ""; }; 008966CA2486D43600DC48C2 /* BugsnagClientMirrorTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagClientMirrorTest.m; sourceTree = ""; }; 008966CB2486D43600DC48C2 /* BugsnagEnabledBreadcrumbTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagEnabledBreadcrumbTest.m; sourceTree = ""; }; @@ -1253,11 +1252,9 @@ 00AD1CE424869C6C00A27979 /* libBugsnagStatic.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBugsnagStatic.a; sourceTree = BUILT_PRODUCTS_DIR; }; 00AD1EF42486A17600A27979 /* RegisterErrorData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterErrorData.h; sourceTree = ""; }; 00AD1EF52486A17600A27979 /* RegisterErrorData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegisterErrorData.m; sourceTree = ""; }; - 00AD1EF72486A17700A27979 /* BSGOutOfMemoryWatchdog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSGOutOfMemoryWatchdog.m; sourceTree = ""; }; 00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagSessionTracker.h; sourceTree = ""; }; 00AD1EF92486A17700A27979 /* BugsnagErrorReportSink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagErrorReportSink.m; sourceTree = ""; }; 00AD1EFA2486A17700A27979 /* Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Private.h; sourceTree = ""; }; - 00AD1EFC2486A17800A27979 /* BSGOutOfMemoryWatchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSGOutOfMemoryWatchdog.h; sourceTree = ""; }; 00AD1EFD2486A17800A27979 /* BugsnagErrorReportSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagErrorReportSink.h; sourceTree = ""; }; 00AD1EFE2486A17800A27979 /* Bugsnag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bugsnag.m; sourceTree = ""; }; 00AD1EFF2486A17900A27979 /* BugsnagCrashSentry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagCrashSentry.m; sourceTree = ""; }; @@ -1298,12 +1295,15 @@ CB10E542250BAD6100AF5824 /* BSGCachesDirectory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGCachesDirectory.h; sourceTree = ""; }; CB10E543250BAD6100AF5824 /* BSGCachesDirectory.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGCachesDirectory.m; sourceTree = ""; }; CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BugsnagApiClientTest.m; sourceTree = ""; }; - CB9103652502404000E9D1E2 /* BSGSerializationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGSerializationTest.m; sourceTree = ""; }; + CBA22499251E429C00B87416 /* TestSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestSupport.h; sourceTree = ""; }; + CBA2249A251E429C00B87416 /* TestSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestSupport.m; sourceTree = ""; }; CBAA6AB3250BA00500713376 /* BugsnagKVStore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagKVStore.h; sourceTree = ""; }; CBAA6AB4250BA01D00713376 /* BugsnagKVStore.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = BugsnagKVStore.c; sourceTree = ""; }; CBAA6AB9250BA6B100713376 /* BugsnagKVStoreTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BugsnagKVStoreTest.m; sourceTree = ""; }; CBAB4DD32510D2460092CBAA /* BugsnagKVStoreObjC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagKVStoreObjC.h; sourceTree = ""; }; CBAB4DD42510D2460092CBAA /* BugsnagKVStoreObjC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BugsnagKVStoreObjC.m; sourceTree = ""; }; + CBB0928A2519F891007698BC /* BugsnagSystemState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagSystemState.m; sourceTree = ""; }; + CBB0928B2519F891007698BC /* BugsnagSystemState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagSystemState.h; sourceTree = ""; }; CBCF77A125010648004AF22A /* BSGJSONSerialization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGJSONSerialization.h; sourceTree = ""; }; CBCF77A225010648004AF22A /* BSGJSONSerialization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGJSONSerialization.m; sourceTree = ""; }; CBCF77AA250142E0004AF22A /* BSGJSONSerializerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGJSONSerializerTest.m; sourceTree = ""; }; @@ -1603,8 +1603,6 @@ 00AD1C7424869B0E00A27979 /* Bugsnag */ = { isa = PBXGroup; children = ( - 00AD1EFC2486A17800A27979 /* BSGOutOfMemoryWatchdog.h */, - 00AD1EF72486A17700A27979 /* BSGOutOfMemoryWatchdog.m */, 00AD1EFE2486A17800A27979 /* Bugsnag.m */, 00AD1F002486A17900A27979 /* BugsnagCrashSentry.h */, 00AD1EFF2486A17900A27979 /* BugsnagCrashSentry.m */, @@ -1612,6 +1610,8 @@ 00AD1EF92486A17700A27979 /* BugsnagErrorReportSink.m */, 00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */, 00AD1F012486A17900A27979 /* BugsnagSessionTracker.m */, + CBB0928B2519F891007698BC /* BugsnagSystemState.h */, + CBB0928A2519F891007698BC /* BugsnagSystemState.m */, 00AD1EFA2486A17700A27979 /* Private.h */, 00AD1EF42486A17600A27979 /* RegisterErrorData.h */, 00AD1EF52486A17600A27979 /* RegisterErrorData.m */, @@ -1636,8 +1636,7 @@ 00896A3F2486DBDD00DC48C2 /* BSGConfigurationBuilderTests.m */, 008966C62486D43600DC48C2 /* BSGConnectivityTest.m */, CBCF77AA250142E0004AF22A /* BSGJSONSerializerTest.m */, - 008966C82486D43600DC48C2 /* BSGOutOfMemoryWatchdogTests.m */, - CB9103652502404000E9D1E2 /* BSGSerializationTest.m */, + 008966C82486D43600DC48C2 /* BSGOutOfMemoryTests.m */, CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */, E701FA9E2490EF4A008D842F /* BugsnagApiValidationTest.m */, 008966C22486D43600DC48C2 /* BugsnagAppTest.m */, @@ -1687,6 +1686,8 @@ 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */, 008966B72486D43500DC48C2 /* report.json */, 008966AE2486D43500DC48C2 /* Swift Tests */, + CBA22499251E429C00B87416 /* TestSupport.h */, + CBA2249A251E429C00B87416 /* TestSupport.m */, ); path = Tests; sourceTree = ""; @@ -1903,6 +1904,7 @@ 3A700A9624A63AC60068CD1B /* BugsnagStackframe.h in Headers */, 3A700A9724A63AC60068CD1B /* BugsnagMetadataStore.h in Headers */, 3A700A9824A63AC60068CD1B /* BugsnagEndpointConfiguration.h in Headers */, + CBB092902519F891007698BC /* BugsnagSystemState.h in Headers */, 3A700A9924A63AC60068CD1B /* BugsnagBreadcrumb.h in Headers */, 3A700A9A24A63AC60068CD1B /* BSG_KSCrashReportWriter.h in Headers */, 3A700A9B24A63AC60068CD1B /* BugsnagErrorTypes.h in Headers */, @@ -1942,7 +1944,6 @@ 008969632486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */, 00AD1F102486A17900A27979 /* BugsnagSessionTracker.h in Headers */, 008968F42486DAB800DC48C2 /* BugsnagSessionFileStore.h in Headers */, - 00AD1F1D2486A17900A27979 /* BSGOutOfMemoryWatchdog.h in Headers */, 008968882486DA9600DC48C2 /* BugsnagHandledState.h in Headers */, CBCF77A325010648004AF22A /* BSGJSONSerialization.h in Headers */, 00896A082486DAD100DC48C2 /* BSG_KSCrashSentry_Private.h in Headers */, @@ -2003,6 +2004,7 @@ 3A700AAA24A63CFC0068CD1B /* BugsnagStackframe.h in Headers */, 3A700AAB24A63CFC0068CD1B /* BugsnagMetadataStore.h in Headers */, 3A700AAC24A63CFD0068CD1B /* BugsnagEndpointConfiguration.h in Headers */, + CBB092912519F891007698BC /* BugsnagSystemState.h in Headers */, 3A700AAD24A63CFD0068CD1B /* BugsnagBreadcrumb.h in Headers */, 3A700AAE24A63CFD0068CD1B /* BSG_KSCrashReportWriter.h in Headers */, 3A700AAF24A63CFD0068CD1B /* BugsnagErrorTypes.h in Headers */, @@ -2041,7 +2043,6 @@ 008969642486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */, 00AD1F112486A17900A27979 /* BugsnagSessionTracker.h in Headers */, 008968F52486DAB800DC48C2 /* BugsnagSessionFileStore.h in Headers */, - 00AD1F1E2486A17900A27979 /* BSGOutOfMemoryWatchdog.h in Headers */, 008968892486DA9600DC48C2 /* BugsnagHandledState.h in Headers */, 00896A092486DAD100DC48C2 /* BSG_KSCrashSentry_Private.h in Headers */, CBCF77A425010648004AF22A /* BSGJSONSerialization.h in Headers */, @@ -2103,6 +2104,7 @@ 3A700ABE24A63D110068CD1B /* BugsnagStackframe.h in Headers */, 3A700ABF24A63D110068CD1B /* BugsnagMetadataStore.h in Headers */, 3A700AC024A63D110068CD1B /* BugsnagEndpointConfiguration.h in Headers */, + CBB092922519F891007698BC /* BugsnagSystemState.h in Headers */, 3A700AC124A63D110068CD1B /* BugsnagBreadcrumb.h in Headers */, 3A700AC224A63D110068CD1B /* BSG_KSCrashReportWriter.h in Headers */, 3A700AC324A63D110068CD1B /* BugsnagErrorTypes.h in Headers */, @@ -2141,7 +2143,6 @@ 008969652486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */, 00AD1F122486A17900A27979 /* BugsnagSessionTracker.h in Headers */, 008968F62486DAB800DC48C2 /* BugsnagSessionFileStore.h in Headers */, - 00AD1F1F2486A17900A27979 /* BSGOutOfMemoryWatchdog.h in Headers */, 0089688A2486DA9600DC48C2 /* BugsnagHandledState.h in Headers */, 00896A0A2486DAD100DC48C2 /* BSG_KSCrashSentry_Private.h in Headers */, CBCF77A525010648004AF22A /* BSGJSONSerialization.h in Headers */, @@ -2469,6 +2470,7 @@ 008968992486DA9600DC48C2 /* BugsnagStackframe.m in Sources */, 00896A022486DAD100DC48C2 /* BSG_KSCrashSentry_NSException.m in Sources */, 008967D32486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m in Sources */, + CBB0928C2519F891007698BC /* BugsnagSystemState.m in Sources */, 0089699C2486DAD100DC48C2 /* BSG_KSFileUtils.c in Sources */, 008969752486DAD100DC48C2 /* BSG_KSJSONCodec.c in Sources */, 00896A2C2486DAD100DC48C2 /* BSG_KSCrashReport.c in Sources */, @@ -2486,7 +2488,6 @@ 008969692486DAD000DC48C2 /* BSG_KSMach_Arm.c in Sources */, 008969C62486DAD100DC48C2 /* BSG_KSLogger.m in Sources */, 008969662486DAD000DC48C2 /* BSG_KSDynamicLinker.c in Sources */, - 00AD1F0C2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */, 008969C02486DAD100DC48C2 /* BSG_KSString.c in Sources */, 008968062486DA4500DC48C2 /* BugsnagErrorReportApiClient.m in Sources */, 0089682B2486DA5600DC48C2 /* BSGSerialization.m in Sources */, @@ -2523,7 +2524,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 008967512486D43700DC48C2 /* BSGOutOfMemoryWatchdogTests.m in Sources */, + 008967512486D43700DC48C2 /* BSGOutOfMemoryTests.m in Sources */, E701FA9F2490EF4A008D842F /* BugsnagApiValidationTest.m in Sources */, 008967902486D43700DC48C2 /* KSJSONCodec_Tests.m in Sources */, 008967722486D43700DC48C2 /* KSSysCtl_Tests.m in Sources */, @@ -2568,13 +2569,13 @@ 008967422486D43700DC48C2 /* BugsnagSessionTrackerStopTest.m in Sources */, E701FAAF2490EFE8008D842F /* ConfigurationApiValidationTest.m in Sources */, 008967452486D43700DC48C2 /* BugsnagTests.m in Sources */, + CBA2249B251E429C00B87416 /* TestSupport.m in Sources */, 008967332486D43700DC48C2 /* BugsnagClientTests.m in Sources */, 004E353F2487B3BD007FBAE4 /* BugsnagSwiftConfigurationTests.swift in Sources */, 008967542486D43700DC48C2 /* BugsnagOnCrashTest.m in Sources */, 008966F72486D43700DC48C2 /* RegisterErrorDataTest.m in Sources */, 008967152486D43700DC48C2 /* BugsnagCollectionsBSGDictMergeTest.m in Sources */, 008967632486D43700DC48C2 /* BugsnagCollectionsBSGDictSetSafeObjectTest.m in Sources */, - CB9103662502404000E9D1E2 /* BSGSerializationTest.m in Sources */, 008967AB2486D43700DC48C2 /* KSMach_Tests.m in Sources */, 0089672A2486D43700DC48C2 /* BugsnagStacktraceTest.m in Sources */, 0089678D2486D43700DC48C2 /* KSCrashReportConverter_Tests.m in Sources */, @@ -2630,6 +2631,7 @@ 0089689A2486DA9600DC48C2 /* BugsnagStackframe.m in Sources */, 00896A032486DAD100DC48C2 /* BSG_KSCrashSentry_NSException.m in Sources */, 008967D42486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m in Sources */, + CBB0928D2519F891007698BC /* BugsnagSystemState.m in Sources */, 0089699D2486DAD100DC48C2 /* BSG_KSFileUtils.c in Sources */, 008969762486DAD100DC48C2 /* BSG_KSJSONCodec.c in Sources */, 00896A2D2486DAD100DC48C2 /* BSG_KSCrashReport.c in Sources */, @@ -2647,7 +2649,6 @@ 0089696A2486DAD000DC48C2 /* BSG_KSMach_Arm.c in Sources */, 008969C72486DAD100DC48C2 /* BSG_KSLogger.m in Sources */, 008969672486DAD000DC48C2 /* BSG_KSDynamicLinker.c in Sources */, - 00AD1F0D2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */, 008969C12486DAD100DC48C2 /* BSG_KSString.c in Sources */, 008968072486DA4500DC48C2 /* BugsnagErrorReportApiClient.m in Sources */, 0089682C2486DA5600DC48C2 /* BSGSerialization.m in Sources */, @@ -2706,7 +2707,6 @@ 004E353D2487B3B8007FBAE4 /* BugsnagSwiftTests.swift in Sources */, 008967192486D43700DC48C2 /* BugsnagErrorTest.m in Sources */, 008967162486D43700DC48C2 /* BugsnagCollectionsBSGDictMergeTest.m in Sources */, - 008967522486D43700DC48C2 /* BSGOutOfMemoryWatchdogTests.m in Sources */, 008967582486D43700DC48C2 /* BugsnagClientMirrorTest.m in Sources */, 0089676A2486D43700DC48C2 /* BugsnagSessionTrackerTest.m in Sources */, 008967792486D43700DC48C2 /* KSMachHeader_Tests.m in Sources */, @@ -2727,6 +2727,7 @@ 0089673A2486D43700DC48C2 /* BugsnagEventFromKSCrashReportTest.m in Sources */, 0089674C2486D43700DC48C2 /* BSGConnectivityTest.m in Sources */, 008966EF2486D43700DC48C2 /* BugsnagClientPayloadInfoTest.m in Sources */, + CBA2249C251E429C00B87416 /* TestSupport.m in Sources */, 008967642486D43700DC48C2 /* BugsnagCollectionsBSGDictSetSafeObjectTest.m in Sources */, E701FAB02490EFE8008D842F /* ConfigurationApiValidationTest.m in Sources */, 008967282486D43700DC48C2 /* BugsnagStackframeTest.m in Sources */, @@ -2789,6 +2790,7 @@ 0089689B2486DA9600DC48C2 /* BugsnagStackframe.m in Sources */, 00896A042486DAD100DC48C2 /* BSG_KSCrashSentry_NSException.m in Sources */, 008967D52486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m in Sources */, + CBB0928E2519F891007698BC /* BugsnagSystemState.m in Sources */, 0089699E2486DAD100DC48C2 /* BSG_KSFileUtils.c in Sources */, 008969772486DAD100DC48C2 /* BSG_KSJSONCodec.c in Sources */, 00896A2E2486DAD100DC48C2 /* BSG_KSCrashReport.c in Sources */, @@ -2806,7 +2808,6 @@ 0089696B2486DAD000DC48C2 /* BSG_KSMach_Arm.c in Sources */, 008969C82486DAD100DC48C2 /* BSG_KSLogger.m in Sources */, 008969682486DAD000DC48C2 /* BSG_KSDynamicLinker.c in Sources */, - 00AD1F0E2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */, 008969C22486DAD100DC48C2 /* BSG_KSString.c in Sources */, 008968082486DA4500DC48C2 /* BugsnagErrorReportApiClient.m in Sources */, 0089682D2486DA5600DC48C2 /* BSGSerialization.m in Sources */, @@ -2862,7 +2863,7 @@ 008967A72486D43700DC48C2 /* KSString_Tests.m in Sources */, 0089671A2486D43700DC48C2 /* BugsnagErrorTest.m in Sources */, 008967172486D43700DC48C2 /* BugsnagCollectionsBSGDictMergeTest.m in Sources */, - 008967532486D43700DC48C2 /* BSGOutOfMemoryWatchdogTests.m in Sources */, + 008967532486D43700DC48C2 /* BSGOutOfMemoryTests.m in Sources */, 008967592486D43700DC48C2 /* BugsnagClientMirrorTest.m in Sources */, 0089676B2486D43700DC48C2 /* BugsnagSessionTrackerTest.m in Sources */, E701FAA12490EF4A008D842F /* BugsnagApiValidationTest.m in Sources */, @@ -2901,6 +2902,7 @@ 008967982486D43700DC48C2 /* KSCrashState_Tests.m in Sources */, 008967772486D43700DC48C2 /* XCTestCase+KSCrash.m in Sources */, 008967322486D43700DC48C2 /* BugsnagStateEventTest.m in Sources */, + CBA2249D251E429C00B87416 /* TestSupport.m in Sources */, 004E35372487AFF2007FBAE4 /* BugsnagHandledStateTest.m in Sources */, 0089678C2486D43700DC48C2 /* KSCrashReportStore_Tests.m in Sources */, 00896A422486DBDD00DC48C2 /* BSGConfigurationBuilderTests.m in Sources */, @@ -2951,7 +2953,6 @@ E7462907248907C100F92D67 /* BSG_KSCrashSentry_CPPException.mm in Sources */, E7462908248907C100F92D67 /* BSG_KSSystemInfo.m in Sources */, 008968CA2486DA9600DC48C2 /* BugsnagApp.m in Sources */, - 00AD1F0F2486A17900A27979 /* BSGOutOfMemoryWatchdog.m in Sources */, 008967C12486DA1900DC48C2 /* BugsnagClient.m in Sources */, 008968752486DA9500DC48C2 /* BugsnagDevice.m in Sources */, 00E636C224878D84006CBF1A /* BSG_RFC3339DateTool.m in Sources */, @@ -2984,6 +2985,7 @@ 008968CE2486DA9600DC48C2 /* BugsnagThread.m in Sources */, 00AD1F312486A17900A27979 /* BugsnagSessionTracker.m in Sources */, 008968C62486DA9600DC48C2 /* BugsnagUser.m in Sources */, + CBB0928F2519F891007698BC /* BugsnagSystemState.m in Sources */, 008968AE2486DA9600DC48C2 /* BugsnagStateEvent.m in Sources */, 008968942486DA9600DC48C2 /* BugsnagError.m in Sources */, 008967E12486DA2D00DC48C2 /* BSGConfigurationBuilder.m in Sources */, diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BSGOutOfMemoryWatchdog.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BSGOutOfMemoryWatchdog.h deleted file mode 100644 index d98f7ba8c..000000000 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BSGOutOfMemoryWatchdog.h +++ /dev/null @@ -1,24 +0,0 @@ -#import - -#define PLATFORM_WORD_SIZE sizeof(void*)*8 - -@class BugsnagConfiguration; - -@interface BSGOutOfMemoryWatchdog : NSObject - -@property(nonatomic, strong, readonly) NSDictionary *lastBootCachedFileInfo; -@property(nonatomic, readonly) BOOL didOOMLastLaunch; - -/** - * Create a new watchdog using the sentinel path to store app/device state - */ -- (instancetype)initWithSentinelPath:(NSString *)sentinelFilePath - configuration:(BugsnagConfiguration *)config - NS_DESIGNATED_INITIALIZER; - -/** - * Begin monitoring for lifecycle events - */ -- (void)start; - -@end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BSGOutOfMemoryWatchdog.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BSGOutOfMemoryWatchdog.m deleted file mode 100644 index 352773cb7..000000000 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BSGOutOfMemoryWatchdog.m +++ /dev/null @@ -1,353 +0,0 @@ -#import "BugsnagPlatformConditional.h" - -#if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS -#define BSGOOMAvailable 1 -#else -#define BSGOOMAvailable 0 -#endif - -#if BSGOOMAvailable -#import -#endif -#import "BSGOutOfMemoryWatchdog.h" -#import "BSG_KSSystemInfo.h" -#import "BugsnagLogger.h" -#import "Bugsnag.h" -#import "BugsnagSessionTracker.h" -#import "Private.h" -#import "BugsnagErrorTypes.h" -#import "BSG_RFC3339DateTool.h" -#import "BSGJSONSerialization.h" -#import "BugsnagKeys.h" -#import "BugsnagCollections.h" -#import "BugsnagKVStoreObjC.h" - -#define KV_KEY_IS_MONITORING_OOM @"oom-isMonitoringOOM" -#define KV_KEY_IS_ACTIVE @"oom-isActive" -#define KV_KEY_IS_IN_FOREGROUND @"oom-isInForeground" -#define KV_KEY_LAST_LOW_MEMORY_WARNING @"oom-lastLowMemoryWarning" -#define KV_KEY_APP_VERSION @"oom-appVersion" -#define KV_KEY_BUNDLE_VERSION @"oom-bundleVersion" - -#define APP_KEY_IS_MONITORING_OOM @"isMonitoringOOM" -#define APP_KEY_IS_IN_FOREGROUND @"inForeground" -#define APP_KEY_IS_ACTIVE @"isActive" -#define DEVICE_KEY_LAST_LOW_MEMORY_WARNING @"lowMemory" -#define APP_KEY_VERSION @"version" -#define APP_KEY_BUNDLE_VERSION @"bundleVersion" - -@interface BSGOutOfMemoryWatchdog () -@property(nonatomic, getter=isWatching) BOOL watching; -@property(nonatomic, strong) NSString *sentinelFilePath; -@property(nonatomic, strong, readwrite) NSMutableDictionary *cachedFileInfo; -@property(nonatomic, strong, readwrite) NSDictionary *lastBootCachedFileInfo; -@property(nonatomic) NSString *codeBundleId; -@property(nonatomic) BugsnagKVStore *kvStore; -@property(nonatomic) NSDictionary *previousKeyValues; - -- (void)shutdown; -@end - -@implementation BSGOutOfMemoryWatchdog - -- (instancetype)init { - self = [self initWithSentinelPath:nil configuration:nil]; - return self; -} - -- (instancetype)initWithSentinelPath:(NSString *)sentinelFilePath - configuration:(BugsnagConfiguration *)config { - if (sentinelFilePath.length == 0) { - return nil; // disallow enabling a watcher without a file path - } - if (self = [super init]) { - _sentinelFilePath = sentinelFilePath; - -#ifdef BSGOOMAvailable - _kvStore = [BugsnagKVStore new]; - - _previousKeyValues = getKeyValues(_kvStore); - _lastBootCachedFileInfo = [self readSentinelFile]; - _cachedFileInfo = [self generateCacheInfoWithConfig:config]; - - [_kvStore setBoolean:false forKey:KV_KEY_IS_MONITORING_OOM]; - [_kvStore setString:@"" forKey:KV_KEY_LAST_LOW_MEMORY_WARNING]; - NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo]; - [_kvStore setString:systemInfo[@BSG_KSSystemField_BundleShortVersion] forKey:KV_KEY_APP_VERSION]; - [_kvStore setString:systemInfo[@BSG_KSSystemField_BundleVersion] forKey:KV_KEY_BUNDLE_VERSION]; - - _didOOMLastLaunch = calculateDidOOM(_kvStore, _previousKeyValues); -#endif - } - return self; -} - -static NSDictionary *getKeyValues(BugsnagKVStore *store) { - NSMutableDictionary *dict = [NSMutableDictionary new]; - dict[APP_KEY_IS_MONITORING_OOM] = [store NSBooleanForKey:KV_KEY_IS_MONITORING_OOM defaultValue:false]; - dict[APP_KEY_IS_ACTIVE] = [store NSBooleanForKey:KV_KEY_IS_ACTIVE defaultValue:false]; - dict[APP_KEY_IS_IN_FOREGROUND] = [store NSBooleanForKey:KV_KEY_IS_IN_FOREGROUND defaultValue:false]; - dict[APP_KEY_VERSION] = [store stringForKey:KV_KEY_APP_VERSION defaultValue:@""]; - dict[APP_KEY_BUNDLE_VERSION] = [store stringForKey:KV_KEY_BUNDLE_VERSION defaultValue:@""]; - dict[DEVICE_KEY_LAST_LOW_MEMORY_WARNING] = [store stringForKey:KV_KEY_LAST_LOW_MEMORY_WARNING defaultValue:@""]; - return dict; -} - -BOOL calculateDidOOM(BugsnagKVStore *store, NSDictionary *previousValues) { - BOOL wasMonitoring = [[previousValues valueForKey:APP_KEY_IS_MONITORING_OOM] boolValue]; - if(!wasMonitoring) { - return NO; - } - - BOOL wasActive = [[previousValues valueForKey:APP_KEY_IS_ACTIVE] boolValue]; - BOOL wasInForeground = [[previousValues valueForKey:APP_KEY_IS_IN_FOREGROUND] boolValue]; - if(!(wasActive && wasInForeground)) { - return NO; - } - - NSString *oldAppVersion = [previousValues valueForKey:APP_KEY_VERSION]; - NSString *newAppVersion = [store stringForKey:KV_KEY_APP_VERSION defaultValue:@""]; - NSString *oldBundleVersion = [previousValues valueForKey:APP_KEY_BUNDLE_VERSION]; - NSString *newBundleVersion = [store stringForKey:KV_KEY_BUNDLE_VERSION defaultValue:@""]; - - if(![oldAppVersion isEqualToString:newAppVersion] || ![oldBundleVersion isEqualToString:newBundleVersion]) { - return NO; - } - - return YES; -} - -- (void)start { -#if BSGOOMAvailable - if ([self isWatching]) { - return; - } - UIApplicationState state = [BSG_KSSystemInfo currentAppState]; - [self.kvStore setBoolean:true forKey:KV_KEY_IS_MONITORING_OOM]; - [self.kvStore setBoolean:[BSG_KSSystemInfo isInForeground:state] forKey:KV_KEY_IS_IN_FOREGROUND]; - [self.kvStore setBoolean:state == UIApplicationStateActive forKey:KV_KEY_IS_ACTIVE]; - - [self writeSentinelFile]; - NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center addObserver:self - selector:@selector(shutdown:) - name:UIApplicationWillTerminateNotification - object:nil]; - [center addObserver:self - selector:@selector(handleTransitionToBackground:) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - [center addObserver:self - selector:@selector(handleTransitionToForeground:) - name:UIApplicationWillEnterForegroundNotification - object:nil]; - [center addObserver:self - selector:@selector(handleTransitionToActive:) - name:UIApplicationDidBecomeActiveNotification - object:nil]; - [center addObserver:self - selector:@selector(handleTransitionToInactive:) - name:UIApplicationWillResignActiveNotification - object:nil]; - [center addObserver:self - selector:@selector(handleLowMemoryChange:) - name:UIApplicationDidReceiveMemoryWarningNotification - object:nil]; - [center addObserver:self - selector:@selector(handleUpdateSession:) - name:BSGSessionUpdateNotification - object:nil]; - [[Bugsnag configuration] - addObserver:self - forKeyPath:NSStringFromSelector(@selector(releaseStage)) - options:NSKeyValueObservingOptionNew - context:nil]; - self.watching = YES; -#endif -} - -- (void)shutdown:(NSNotification *)note { - [self shutdown]; -} - -- (void)shutdown { - if (![self isWatching]) { - // Avoid unsubscribing from KVO when not observing - // From the docs: - // > Asking to be removed as an observer if not already registered as - // > one results in an NSRangeException. You either call - // > `removeObserver:forKeyPath:context: exactly once for the - // > corresponding call to `addObserver:forKeyPath:options:context:` - return; - } - [self.kvStore setBoolean:false forKey:KV_KEY_IS_MONITORING_OOM]; - self.watching = NO; - [self deleteSentinelFile]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; - @try { - [[Bugsnag configuration] - removeObserver:self - forKeyPath:NSStringFromSelector(@selector(releaseStage))]; - } @catch (NSException *exception) { - // Shouldn't happen, but if for some reason, unregistration happens - // without registration, catch the resulting exception. - } -} - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(NSDictionary *)change - context:(void *)context { - self.cachedFileInfo[BSGKeyApp][BSGKeyReleaseStage] = change[NSKeyValueChangeNewKey]; - [self writeSentinelFile]; -} - -- (void)handleTransitionToActive:(NSNotification *)note { - [self.kvStore setBoolean:true forKey:KV_KEY_IS_ACTIVE]; - self.cachedFileInfo[BSGKeyApp][APP_KEY_IS_ACTIVE] = @YES; - [self writeSentinelFile]; -} - -- (void)handleTransitionToInactive:(NSNotification *)note { - [self.kvStore setBoolean:false forKey:KV_KEY_IS_ACTIVE]; - self.cachedFileInfo[BSGKeyApp][APP_KEY_IS_ACTIVE] = @NO; - [self writeSentinelFile]; -} - -- (void)handleTransitionToForeground:(NSNotification *)note { - [self.kvStore setBoolean:true forKey:KV_KEY_IS_IN_FOREGROUND]; - self.cachedFileInfo[BSGKeyApp][APP_KEY_IS_IN_FOREGROUND] = @YES; - [self writeSentinelFile]; -} - -- (void)handleTransitionToBackground:(NSNotification *)note { - [self.kvStore setBoolean:false forKey:KV_KEY_IS_IN_FOREGROUND]; - self.cachedFileInfo[BSGKeyApp][APP_KEY_IS_IN_FOREGROUND] = @NO; - [self writeSentinelFile]; -} - -- (void)handleLowMemoryChange:(NSNotification *)note { - NSString *date = [BSG_RFC3339DateTool stringFromDate:[NSDate date]]; - [self.kvStore setString:date forKey:KV_KEY_LAST_LOW_MEMORY_WARNING]; - self.cachedFileInfo[BSGKeyDevice][DEVICE_KEY_LAST_LOW_MEMORY_WARNING] = date; - [self writeSentinelFile]; -} - -- (void)handleUpdateSession:(NSNotification *)note { - id session = [note object]; - NSMutableDictionary *cache = (id)self.cachedFileInfo; - if (session) { - cache[BSGKeySession] = session; - } else { - [cache removeObjectForKey:BSGKeySession]; - } - [self writeSentinelFile]; -} - -- (void)setCodeBundleId:(NSString *)codeBundleId { - _codeBundleId = codeBundleId; - BSGDictInsertIfNotNil(self.cachedFileInfo[BSGKeyApp], codeBundleId, BSGKeyCodeBundleId); - - if ([self isWatching]) { - [self writeSentinelFile]; - } -} - -- (void)deleteSentinelFile { - NSError *error = nil; - [[NSFileManager defaultManager] removeItemAtPath:self.sentinelFilePath - error:&error]; - if (error) { - bsg_log_err(@"Failed to delete oom watchdog file: %@", error); - unlink([self.sentinelFilePath UTF8String]); - } -} - -- (NSDictionary *)readSentinelFile { - if (![[NSFileManager defaultManager] fileExistsAtPath:self.sentinelFilePath]) { - return @{}; - } - - NSError *error = nil; - NSData *data = [NSData dataWithContentsOfFile:self.sentinelFilePath options:0 error:&error]; - if (error) { - bsg_log_err(@"Failed to read oom watchdog file: %@", error); - return nil; - } - NSMutableDictionary *contents = [BSGJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; - if (error) { - bsg_log_err(@"Failed to read oom watchdog file: %@", error); - return nil; - } - - // Override JSON data with KV store data - contents[BSGKeyApp][APP_KEY_IS_MONITORING_OOM] = [self.kvStore NSBooleanForKey:KV_KEY_IS_MONITORING_OOM defaultValue:false]; - contents[BSGKeyApp][APP_KEY_IS_ACTIVE] = [self.kvStore NSBooleanForKey:KV_KEY_IS_ACTIVE defaultValue:false]; - contents[BSGKeyApp][APP_KEY_IS_IN_FOREGROUND] = [self.kvStore NSBooleanForKey:KV_KEY_IS_IN_FOREGROUND defaultValue:false]; - contents[BSGKeyDevice][DEVICE_KEY_LAST_LOW_MEMORY_WARNING] = [self.kvStore stringForKey:KV_KEY_LAST_LOW_MEMORY_WARNING defaultValue:@""]; - - return contents; -} - -- (void)writeSentinelFile { - NSError *error = nil; - if (![BSGJSONSerialization isValidJSONObject:self.cachedFileInfo]) { - bsg_log_err(@"Cached oom watchdog data cannot be written as JSON"); - return; - } - NSData *data = [BSGJSONSerialization dataWithJSONObject:self.cachedFileInfo options:0 error:&error]; - if (error) { - bsg_log_err(@"Cached oom watchdog data cannot be written as JSON: %@", error); - return; - } - [data writeToFile:self.sentinelFilePath atomically:YES]; -} - -- (NSMutableDictionary *)generateCacheInfoWithConfig:(BugsnagConfiguration *)config { - NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo]; - NSMutableDictionary *cache = [NSMutableDictionary new]; - NSMutableDictionary *app = [NSMutableDictionary new]; - - app[BSGKeyId] = systemInfo[@BSG_KSSystemField_BundleID] ?: @""; - app[BSGKeyName] = systemInfo[@BSG_KSSystemField_BundleName] ?: @""; - app[BSGKeyReleaseStage] = config.releaseStage; - app[BSGKeyVersion] = systemInfo[@BSG_KSSystemField_BundleShortVersion] ?: @""; - app[BSGKeyBundleVersion] = systemInfo[@BSG_KSSystemField_BundleVersion] ?: @""; - // 'codeBundleId' only (optionally) exists for React Native clients and defaults otherwise to nil - BSGDictInsertIfNotNil(app, self.codeBundleId, BSGKeyCodeBundleId); -#if BSGOOMAvailable - UIApplicationState state = [BSG_KSSystemInfo currentAppState]; - app[@"inForeground"] = @([BSG_KSSystemInfo isInForeground:state]); - app[@"isActive"] = @(state == UIApplicationStateActive); -#else - app[@"inForeground"] = @YES; -#endif -#if BSG_PLATFORM_TVOS - app[BSGKeyType] = @"tvOS"; -#elif BSG_PLATFORM_IOS - app[BSGKeyType] = @"iOS"; -#endif - cache[BSGKeyApp] = app; - - NSMutableDictionary *device = [NSMutableDictionary new]; - device[@"id"] = systemInfo[@BSG_KSSystemField_DeviceAppHash]; - // device[@"lowMemory"] is initially unset - device[@"osBuild"] = systemInfo[@BSG_KSSystemField_OSVersion]; - device[@"osVersion"] = systemInfo[@BSG_KSSystemField_SystemVersion]; - device[@"osName"] = systemInfo[@BSG_KSSystemField_SystemName]; - // Translated from 'iDeviceMaj,Min' into human-readable "iPhone X" description on the server - device[@"model"] = systemInfo[@BSG_KSSystemField_Machine]; - device[@"modelNumber"] = systemInfo[@ BSG_KSSystemField_Model]; - device[@"wordSize"] = @(PLATFORM_WORD_SIZE); - device[@"locale"] = [[NSLocale currentLocale] localeIdentifier]; -#if BSG_PLATFORM_SIMULATOR - device[@"simulator"] = @YES; -#else - device[@"simulator"] = @NO; -#endif - cache[BSGKeyDevice] = device; - - return cache; -} - -@end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m index 3eaf995c0..c662fdc58 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m @@ -34,6 +34,7 @@ #import "BugsnagKeys.h" #import "BugsnagPlugin.h" #import "BugsnagHandledState.h" +#import "BugsnagSystemState.h" static BugsnagClient *bsg_g_bugsnag_client = NULL; @@ -93,6 +94,14 @@ + (BugsnagClient *_Nonnull)startWithConfiguration:(BugsnagConfiguration *_Nonnul } } +/** + * Purge the global client so that it will be regenerated on the next call to start. + * This is only used by the unit tests. + */ ++ (void)purge { + bsg_g_bugsnag_client = nil; +} + + (BugsnagConfiguration *)configuration { if ([self bugsnagStarted]) { return self.client.configuration; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h new file mode 100644 index 000000000..30f9a58a0 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h @@ -0,0 +1,44 @@ +// +// BugsnagSystemInfo.h +// Bugsnag +// +// Created by Karl Stenerud on 21.09.20. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import +#import "BugsnagConfiguration.h" + +#define SYSTEMSTATE_KEY_APP @"app" +#define SYSTEMSTATE_KEY_DEVICE @"device" + +#define SYSTEMSTATE_APP_WAS_TERMINATED @"wasTerminated" +#define SYSTEMSTATE_APP_IS_ACTIVE @"isActive" +#define SYSTEMSTATE_APP_IS_IN_FOREGROUND @"inForeground" +#define SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING @"lowMemory" +#define SYSTEMSTATE_APP_VERSION @"version" +#define SYSTEMSTATE_APP_BUNDLE_VERSION @"bundleVersion" +#define SYSTEMSTATE_APP_DEBUGGER_IS_ACTIVE @"debuggerIsActive" + +#define PLATFORM_WORD_SIZE sizeof(void*)*8 + +NS_ASSUME_NONNULL_BEGIN + +@interface BugsnagSystemState : NSObject + +@property(readonly,nonatomic) NSDictionary *lastLaunchState; +@property(readonly,nonatomic) NSDictionary *currentLaunchState; + +- (instancetype)init NS_UNAVAILABLE; +- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config; + +- (void)setCodeBundleID:(NSString*)codeBundleID; + +/** + * Purge all stored system state. + */ +- (void)purge; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m new file mode 100644 index 000000000..e3a3ffd7a --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m @@ -0,0 +1,248 @@ +// +// BugsnagSystemInfo.m +// Bugsnag +// +// Created by Karl Stenerud on 21.09.20. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import +#if TARGET_OS_OSX +#import +#else +#import +#endif + +#import "BugsnagSystemState.h" +#import "BSGCachesDirectory.h" +#import "BSGJSONSerialization.h" +#import "BugsnagLogger.h" +#import "BugsnagKVStoreObjC.h" +#import "BSG_RFC3339DateTool.h" +#import "BSG_KSSystemInfo.h" +#import "BSG_KSMach.h" +#import "BugsnagKeys.h" +#import "Bugsnag.h" + +#define STATE_DIR @"bugsnag/state" +#define STATE_FILE @"system_state.json" + +static NSDictionary* loadPreviousState(BugsnagKVStore *kvstore, NSString *jsonPath) { + NSData *data = [NSData dataWithContentsOfFile:jsonPath]; + if(data == nil) { + return @{}; + } + + NSError *error = nil; + NSMutableDictionary *state = [BSGJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; + if(error != nil) { + bsg_log_err(@"Invalid previous system state data: %@", error); + return @{}; + } + if(state == nil) { + bsg_log_err(@"Could not load previous system state"); + return @{}; + } + if(![state isKindOfClass:[NSMutableDictionary class]]) { + bsg_log_err(@"Previous system state has incorrect structure"); + return @{}; + } + + NSMutableDictionary *app = state[SYSTEMSTATE_KEY_APP]; + + // KV-store versions of these are authoritative + app[SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING] = [kvstore stringForKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING defaultValue:@""]; + app[SYSTEMSTATE_APP_WAS_TERMINATED] = [kvstore NSBooleanForKey:SYSTEMSTATE_APP_WAS_TERMINATED defaultValue:false]; + app[SYSTEMSTATE_APP_IS_ACTIVE] = [kvstore NSBooleanForKey:SYSTEMSTATE_APP_IS_ACTIVE defaultValue:false]; + app[SYSTEMSTATE_APP_IS_IN_FOREGROUND] = [kvstore NSBooleanForKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND defaultValue:false]; + app[SYSTEMSTATE_APP_DEBUGGER_IS_ACTIVE] = [kvstore NSBooleanForKey:SYSTEMSTATE_APP_DEBUGGER_IS_ACTIVE defaultValue:false]; + + return state; +} + +id blankIfNil(id value) { + if(value == nil || [value isKindOfClass:[NSNull class]]) { + return @""; + } + return value; +} + +static NSMutableDictionary* initCurrentState(BugsnagKVStore *kvstore, BugsnagConfiguration *config) { + NSDictionary *systemInfo = [BSG_KSSystemInfo systemInfo]; + + bool isBeingDebugged = bsg_ksmachisBeingTraced(); + bool isInForeground = true; + bool isActive = true; +#if TARGET_OS_OSX + // MacOS "active" serves the same purpose as "foreground" in iOS + isInForeground = [NSApplication sharedApplication].active; +#else + UIApplicationState appState = [BSG_KSSystemInfo currentAppState]; + isInForeground = [BSG_KSSystemInfo isInForeground:appState]; + isActive = appState == UIApplicationStateActive; +#endif + + [kvstore deleteKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING]; + [kvstore deleteKey:SYSTEMSTATE_APP_WAS_TERMINATED]; + [kvstore setBoolean:isActive forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + [kvstore setBoolean:isInForeground forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [kvstore setBoolean:isBeingDebugged forKey:SYSTEMSTATE_APP_DEBUGGER_IS_ACTIVE]; + + NSMutableDictionary *app = [NSMutableDictionary new]; + app[BSGKeyId] = blankIfNil(systemInfo[@BSG_KSSystemField_BundleID]); + app[BSGKeyName] = blankIfNil(systemInfo[@BSG_KSSystemField_BundleName]); + app[BSGKeyReleaseStage] = config.releaseStage; + app[BSGKeyVersion] = blankIfNil(systemInfo[@BSG_KSSystemField_BundleShortVersion]); + app[BSGKeyBundleVersion] = blankIfNil(systemInfo[@BSG_KSSystemField_BundleVersion]); + app[@"inForeground"] = @(isInForeground); + app[@"isActive"] = @(isActive); +#if BSG_PLATFORM_TVOS + app[BSGKeyType] = @"tvOS"; +#elif BSG_PLATFORM_IOS + app[BSGKeyType] = @"iOS"; +#elif BSG_PLATFORM_OSX + app[BSGKeyType] = @"macOS"; +#endif + app[SYSTEMSTATE_APP_DEBUGGER_IS_ACTIVE] = @(isBeingDebugged); + + NSMutableDictionary *device = [NSMutableDictionary new]; + device[@"id"] = systemInfo[@BSG_KSSystemField_DeviceAppHash]; + // device[@"lowMemory"] is initially unset + device[@"osBuild"] = systemInfo[@BSG_KSSystemField_OSVersion]; + device[@"osVersion"] = systemInfo[@BSG_KSSystemField_SystemVersion]; + device[@"osName"] = systemInfo[@BSG_KSSystemField_SystemName]; + // Translated from 'iDeviceMaj,Min' into human-readable "iPhone X" description on the server + device[@"model"] = systemInfo[@BSG_KSSystemField_Machine]; + device[@"modelNumber"] = systemInfo[@ BSG_KSSystemField_Model]; + device[@"wordSize"] = @(PLATFORM_WORD_SIZE); + device[@"locale"] = [[NSLocale currentLocale] localeIdentifier]; +#if BSG_PLATFORM_SIMULATOR + device[@"simulator"] = @YES; +#else + device[@"simulator"] = @NO; +#endif + + NSMutableDictionary *state = [NSMutableDictionary new]; + state[BSGKeyApp] = app; + state[BSGKeyDevice] = device; + + return state; +} + +NSDictionary *copyLaunchState(NSDictionary *launchState) { + return @{ + BSGKeyApp: [launchState[BSGKeyApp] copy], + BSGKeyDevice: [launchState[BSGKeyDevice] copy], + }; +} + +@interface BugsnagSystemState () + +@property(readwrite,nonatomic) NSMutableDictionary *currentLaunchStateRW; +@property(readwrite,nonatomic) NSDictionary *currentLaunchState; +@property(readonly,nonatomic) NSString *persistenceFilePath; +@property(nonatomic) BugsnagKVStore *kvStore; + +@end + +@implementation BugsnagSystemState + +- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config { + if (self = [super init]) { + _kvStore = [BugsnagKVStore new]; + _persistenceFilePath = [[BSGCachesDirectory getSubdirPath:STATE_DIR] stringByAppendingPathComponent:STATE_FILE]; + _lastLaunchState = loadPreviousState(_kvStore, _persistenceFilePath); + _currentLaunchStateRW = initCurrentState(_kvStore, config); + _currentLaunchState = [_currentLaunchStateRW copy]; + [self sync]; + + __weak __typeof__(self) weakSelf = self; + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; +#if TARGET_OS_OSX + [center addObserverForName:NSApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_WAS_TERMINATED]; + // No need to update since we are shutting down. + }]; + // MacOS "active" serves the same purpose as "foreground" in iOS + [center addObserverForName:NSApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf bgSetAppValue:@YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + }]; + [center addObserverForName:NSApplicationDidResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf bgSetAppValue:@NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + }]; +#else + [center addObserverForName:UIApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_WAS_TERMINATED]; + // No need to update since we are shutting down. + }]; + [center addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf bgSetAppValue:@YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + }]; + [center addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf bgSetAppValue:@NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + }]; + [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + [weakSelf bgSetAppValue:@YES forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + }]; + [center addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [weakSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + [weakSelf bgSetAppValue:@NO forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + }]; + [center addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + NSString *date = [BSG_RFC3339DateTool stringFromDate:[NSDate date]]; + [weakSelf.kvStore setString:date forKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING]; + [weakSelf bgSetAppValue:date forKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING]; + }]; +#endif + } + return self; +} + +- (void)setCodeBundleID:(NSString*)codeBundleID { + [self bgSetAppValue:codeBundleID forKey:BSGKeyCodeBundleId]; +} + +- (void)bgSetAppValue:(id)value forKey:(NSString*)key { + // Run on a BG thread so we don't monopolize the notification queue. + dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ + @synchronized (self) { + self.currentLaunchStateRW[SYSTEMSTATE_KEY_APP][key] = value; + // User-facing state should never mutate from under them. + self.currentLaunchState = copyLaunchState(self.currentLaunchStateRW); + } + [self sync]; + }); +} + + +- (void)sync { + NSDictionary *state = self.currentLaunchState; + NSError *error = nil; + if (![BSGJSONSerialization isValidJSONObject:state]) { + bsg_log_err(@"System state cannot be written as JSON"); + return; + } + NSData *data = [BSGJSONSerialization dataWithJSONObject:state options:0 error:&error]; + if (error) { + bsg_log_err(@"System state cannot be written as JSON: %@", error); + return; + } + [data writeToFile:self.persistenceFilePath atomically:YES]; +} + +- (void)purge { + NSFileManager *fm = [NSFileManager defaultManager]; + NSError *error = nil; + if(![fm removeItemAtPath:self.persistenceFilePath error:&error]) { + bsg_log_err(@"Could not remove persistence file: %@", error); + } + [self.kvStore purge]; + self->_lastLaunchState = loadPreviousState(self.kvStore, self.persistenceFilePath); +} + +@end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m index 8744c9297..0bb6c71f0 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m @@ -38,7 +38,7 @@ #import "BugsnagSessionTracker.h" #import "BugsnagSessionTrackingApiClient.h" #import "BugsnagPluginClient.h" -#import "BSGOutOfMemoryWatchdog.h" +#import "BugsnagSystemState.h" #import "BSG_RFC3339DateTool.h" #import "BSG_KSCrashC.h" #import "BSG_KSCrashType.h" @@ -56,6 +56,12 @@ #import "BSG_KSCrash.h" #import "BSGJSONSerialization.h" +#if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS +#define BSGOOMAvailable 1 +#else +#define BSGOOMAvailable 0 +#endif + #if BSG_PLATFORM_IOS #import #elif BSG_PLATFORM_OSX @@ -295,7 +301,7 @@ void BSGWriteSessionCrashData(BugsnagSession *session) { @interface BugsnagClient () @property(nonatomic, strong) BugsnagCrashSentry *crashSentry; @property(nonatomic, strong) BugsnagErrorReportApiClient *errorReportApiClient; -@property (nonatomic, strong) BSGOutOfMemoryWatchdog *oomWatchdog; +@property (nonatomic, strong) BugsnagSystemState *systemState; @property (nonatomic, strong) BugsnagPluginClient *pluginClient; @property (nonatomic) BOOL appDidCrashLastLaunch; @property (nonatomic, strong) BugsnagMetadata *metadata; @@ -342,10 +348,6 @@ - (instancetype)initWithErrorClass:(NSString *)errorClass stacktrace:(NSArray *)stacktrace; @end -@interface BSGOutOfMemoryWatchdog () -@property(nonatomic) NSString *codeBundleId; -@end - @interface BugsnagSessionTracker () @property(nonatomic) NSString *codeBundleId; @end @@ -374,23 +376,19 @@ @implementation BugsnagClient @synthesize configuration; - (id)initWithConfiguration:(BugsnagConfiguration *)initConfiguration { - static NSString *const BSGWatchdogSentinelFileName = @"bugsnag_oom_watchdog.json"; static NSString *const BSGCrashSentinelFileName = @"bugsnag_handled_crash.txt"; if ((self = [super init])) { // Take a shallow copy of the configuration self.configuration = [initConfiguration copy]; self.state = [[BugsnagMetadata alloc] init]; self.notifier = [BugsnagNotifier new]; + self.systemState = [[BugsnagSystemState alloc] initWithConfiguration:self.configuration]; NSString *cacheDir = [NSSearchPathForDirectoriesInDomains( NSCachesDirectory, NSUserDomainMask, YES) firstObject]; if (cacheDir) { - NSString *sentinelPath = [cacheDir stringByAppendingPathComponent:BSGWatchdogSentinelFileName]; NSString *crashPath = [cacheDir stringByAppendingPathComponent:BSGCrashSentinelFileName]; - watchdogSentinelPath = strdup([sentinelPath UTF8String]); crashSentinelPath = strdup([crashPath UTF8String]); - self.oomWatchdog = [[BSGOutOfMemoryWatchdog alloc] initWithSentinelPath:sentinelPath - configuration:configuration]; } self.stateEventBlocks = [NSMutableArray new]; @@ -548,6 +546,8 @@ - (void)initializeNotificationNameMap { } - (void)start { + [configuration validate]; + [self.crashSentry install:self.configuration apiClient:self.errorReportApiClient onCrash:&BSSerializeDataCrashHandler]; @@ -603,21 +603,6 @@ - (void)start { #endif _started = YES; - // autoDetectErrors disables all unhandled event reporting - BOOL configuredToReportOOMs = self.configuration.autoDetectErrors && self.configuration.enabledErrorTypes.ooms; - - // Disable if a debugger is enabled, since the development cycle of starting - // and restarting an app is also an uncatchable kill - BOOL noDebuggerEnabled = !bsg_ksmachisBeingTraced(); - - // Disable if in an app extension, since app extensions have a different - // app lifecycle and the heuristic used for finding app terminations rooted - // in fixable code does not apply - BOOL notInAppExtension = ![BSG_KSSystemInfo isRunningInAppExtension]; - - if (configuredToReportOOMs && noDebuggerEnabled && notInAppExtension) { - [self.oomWatchdog start]; - } [self.sessionTracker startNewSessionIfAutoCaptureEnabled]; @@ -636,6 +621,72 @@ - (void)start { [self.metadata addMetadata:BSGParseDeviceMetadata(@{@"system": systemInfo}) toSection:BSGKeyDevice]; } +- (bool)shouldReportOOM { +#if BSGOOMAvailable + // Disable if in an app extension, since app extensions have a different + // app lifecycle and the heuristic used for finding app terminations rooted + // in fixable code does not apply + if([BSG_KSSystemInfo isRunningInAppExtension]) { + return NO; + } + + // autoDetectErrors disables all unhandled event reporting + if(!self.configuration.autoDetectErrors) { + return NO; + } + + // Are OOMs enabled? + if(!self.configuration.enabledErrorTypes.ooms) { + return NO; + } + + return [self didLikelyOOM]; +#else + return NO; +#endif +} + +/** + * These heuristics aren't 100% guaranteed to be correct, but they're correct often enough to be useful. + */ +- (bool)didLikelyOOM { +#if BSGOOMAvailable + NSDictionary *currAppState = self.systemState.currentLaunchState[SYSTEMSTATE_KEY_APP]; + NSDictionary *prevAppState = self.systemState.lastLaunchState[SYSTEMSTATE_KEY_APP]; + + // Disable if a debugger was active, since the development cycle of + // starting and restarting an app is also an uncatchable kill + if([prevAppState[SYSTEMSTATE_APP_DEBUGGER_IS_ACTIVE] boolValue]) { + return NO; + } + + // If the app code changed between launches, assume no OOM. + if (![prevAppState[SYSTEMSTATE_APP_VERSION] isEqualToString:currAppState[SYSTEMSTATE_APP_VERSION]]) { + return NO; + } + if (![prevAppState[SYSTEMSTATE_APP_BUNDLE_VERSION] isEqualToString:currAppState[SYSTEMSTATE_APP_BUNDLE_VERSION]]) { + return NO; + } + + // If the app was inactive or backgrounded, we can't determine if it was OOM or not. + if(![prevAppState[SYSTEMSTATE_APP_IS_ACTIVE] boolValue]) { + return NO; + } + if(![prevAppState[SYSTEMSTATE_APP_IS_IN_FOREGROUND] boolValue]) { + return NO; + } + + // If the app terminated normally, it wasn't an OOM. + if([prevAppState[SYSTEMSTATE_APP_WAS_TERMINATED] boolValue]) { + return NO; + } + + return YES; +#else + return NO; +#endif +} + - (void)addTerminationObserver:(NSString *)name { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unsubscribeFromNotifications:) @@ -646,6 +697,7 @@ - (void)addTerminationObserver:(NSString *)name { - (void)computeDidCrashLastLaunch { const BSG_KSCrash_State *crashState = bsg_kscrashstate_currentState(); #if BSG_PLATFORM_TVOS || BSG_PLATFORM_IOS + BOOL didOOMLastLaunch = [self shouldReportOOM]; NSFileManager *manager = [NSFileManager defaultManager]; NSString *didCrashSentinelPath = [NSString stringWithUTF8String:crashSentinelPath]; BOOL appCrashSentinelExists = [manager fileExistsAtPath:didCrashSentinelPath]; @@ -658,7 +710,7 @@ - (void)computeDidCrashLastLaunch { unlink(crashSentinelPath); } } - self.appDidCrashLastLaunch = handledCrashLastLaunch || [self.oomWatchdog didOOMLastLaunch]; + self.appDidCrashLastLaunch = handledCrashLastLaunch || didOOMLastLaunch; // Ignore potential false positive OOM if previous session crashed and was // reported. There are two checks in place: @@ -668,7 +720,7 @@ - (void)computeDidCrashLastLaunch { // 2. crash sentinel file exists: This file is written in the event of a crash // and insures against the crash callback crashing - if (!handledCrashLastLaunch && [self.oomWatchdog didOOMLastLaunch]) { + if (!handledCrashLastLaunch && didOOMLastLaunch) { [self notifyOutOfMemoryEvent]; } #else @@ -679,7 +731,7 @@ - (void)computeDidCrashLastLaunch { - (void)setCodeBundleId:(NSString *)codeBundleId { _codeBundleId = codeBundleId; [self.state addMetadata:codeBundleId withKey:BSGKeyCodeBundleId toSection:BSGKeyApp]; - self.oomWatchdog.codeBundleId = codeBundleId; + [self.systemState setCodeBundleID:codeBundleId]; self.sessionTracker.codeBundleId = codeBundleId; } @@ -929,7 +981,7 @@ - (void)notify:(NSException *)exception - (void)notifyOutOfMemoryEvent { static NSString *const BSGOutOfMemoryErrorClass = @"Out Of Memory"; static NSString *const BSGOutOfMemoryMessageFormat = @"The app was likely terminated by the operating system while in the %@"; - NSMutableDictionary *lastLaunchInfo = [[self.oomWatchdog lastBootCachedFileInfo] mutableCopy]; + NSMutableDictionary *lastLaunchInfo = [self.systemState.lastLaunchState mutableCopy]; NSArray *crumbs = [self.breadcrumbs cachedBreadcrumbs]; if (crumbs.count > 0) { lastLaunchInfo[@"breadcrumbs"] = crumbs; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m index 1777801dc..73e3a57ad 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m @@ -1,4 +1,6 @@ #import "BSGConfigurationBuilder.h" + +#import "BSG_KSLogger.h" #import "BugsnagConfiguration.h" #import "BugsnagEndpointConfiguration.h" #import "BugsnagKeys.h" @@ -8,20 +10,38 @@ static BOOL BSGValueIsBoolean(id object) { && CFGetTypeID((__bridge CFTypeRef)object) == CFBooleanGetTypeID(); } -@interface BugsnagConfiguration () -+ (BOOL)isValidApiKey:(NSString *)apiKey; -@end - @implementation BSGConfigurationBuilder + (BugsnagConfiguration *)configurationFromOptions:(NSDictionary *)options { NSString *apiKey = options[@"apiKey"]; + if (apiKey != nil && ![apiKey isKindOfClass:[NSString class]]) { + @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Bugsnag apiKey must be a string" userInfo:nil]; + } + BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:apiKey]; - if (![BugsnagConfiguration isValidApiKey:apiKey]) { - return config; + NSArray *validKeys = @[ + BSGKeyApiKey, + BSGKeyAppType, + BSGKeyAppVersion, + BSGKeyAutoDetectErrors, + BSGKeyAutoTrackSessions, + BSGKeyBundleVersion, + BSGKeyEnabledReleaseStages, + BSGKeyEndpoints, + BSGKeyMaxBreadcrumbs, + BSGKeyPersistUser, + BSGKeyRedactedKeys, + BSGKeyReleaseStage, + BSGKeySendThreads, + ]; + + NSMutableSet *unknownKeys = [NSMutableSet setWithArray:options.allKeys]; + [unknownKeys minusSet:[NSSet setWithArray:validKeys]]; + if (unknownKeys.count > 0) { + BSG_KSLOG_WARN(@"Unknown dictionary keys passed in configuration options: %@", unknownKeys); } - + [self loadString:config options:options key:BSGKeyAppType]; [self loadString:config options:options key:BSGKeyAppVersion]; [self loadBoolean:config options:options key:BSGKeyAutoDetectErrors]; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m index c081a18f4..ff6432d6b 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m @@ -24,26 +24,11 @@ // THE SOFTWARE. // -#import "BugsnagPlatformConditional.h" - #import "BugsnagConfiguration.h" -#import "BugsnagKeys.h" -#import "BSG_RFC3339DateTool.h" -#import "BugsnagUser.h" -#import "BugsnagSessionTracker.h" -#import "BugsnagLogger.h" + #import "BSGConfigurationBuilder.h" -#import "BugsnagBreadcrumbs.h" -#import "BugsnagMetadataStore.h" -#import "BSGSerialization.h" -#import "BugsnagEndpointConfiguration.h" -#import "BugsnagErrorTypes.h" -#import "BugsnagStateEvent.h" -#import "BugsnagCollections.h" -#import "BugsnagMetadataInternal.h" - -static NSString *const BSGApiKeyMissingError = @"No Bugsnag API Key set"; -static NSString *const BSGInitError = @"Init is unavailable. Use [[BugsnagConfiguration alloc] initWithApiKey:] instead."; +#import "Private.h" + static const int BSGApiKeyLength = 32; // User info persistence keys @@ -156,10 +141,6 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone { * @returns A boolean representing whether the apiKey is valid. */ + (BOOL)isValidApiKey:(NSString *)apiKey { - if ([self isApiKeyMissing:apiKey]) { - return false; - } - NSCharacterSet *chars = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"] invertedSet]; @@ -168,19 +149,6 @@ + (BOOL)isValidApiKey:(NSString *)apiKey { return isHex && [apiKey length] == BSGApiKeyLength; } -/** - * Check if the API Key is missing, i.e. it's nil, not a string or is empty. - * - * This is distinct from 'isValidApiKey' to allow throwing an exception in this case, but not - * if the API Key is in the wrong format. - * - * @param apiKey The API key. - * @returns A boolean representing whether the API key is nil, of the wrong type or is an empty string - */ -+ (BOOL)isApiKeyMissing:(NSString *)apiKey { - return apiKey == nil || ![apiKey isKindOfClass:[NSString class]] || [apiKey length] == 0; -} - // ----------------------------------------------------------------------------- // MARK: - Initializers // ----------------------------------------------------------------------------- @@ -189,7 +157,8 @@ + (BOOL)isApiKeyMissing:(NSString *)apiKey { * Should not be called, but if it _is_ then fail meaningfully rather than silently */ - (instancetype)init { - @throw BSGInitError; + @throw [NSException exceptionWithName:NSInternalInconsistencyException reason: + @"-[BugsnagConfiguration init] is unavailable. Use -[BugsnagConfiguration initWithApiKey:] instead." userInfo:nil]; } /** @@ -622,26 +591,19 @@ - (void)setBundleVersion:(NSString *)newVersion { // MARK: - -@synthesize apiKey = _apiKey; - -- (NSString *)apiKey { - return _apiKey; -} - -- (void)setApiKey:(NSString *)apiKey { - if ([BugsnagConfiguration isApiKeyMissing:apiKey]) { - @throw BSGApiKeyMissingError; +- (void)validate { + if (self.apiKey.length == 0) { + @throw [NSException exceptionWithName:NSInvalidArgumentException reason: + @"No Bugsnag API key has been provided" userInfo:nil]; } - if (![BugsnagConfiguration isValidApiKey:apiKey]) { - bsg_log_warn(@"Invalid configuration. apiKey should be a 32-character hexademical string, got \"%@\"", apiKey); + if (![BugsnagConfiguration isValidApiKey:self.apiKey]) { + bsg_log_warn(@"Invalid Bugsnag apiKey: expected a 32-character hexademical string, got \"%@\"", self.apiKey); } - - [self willChangeValueForKey:NSStringFromSelector(@selector(apiKey))]; - _apiKey = apiKey; - [self didChangeValueForKey:NSStringFromSelector(@selector(apiKey))]; } +// MARK: - + - (void)addPlugin:(id _Nonnull)plugin { [_plugins addObject:plugin]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagErrorTypes.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagErrorTypes.m index e7bd60c58..04cb5922f 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagErrorTypes.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagErrorTypes.m @@ -17,12 +17,7 @@ - (instancetype)init { _cppExceptions = true; _machExceptions = true; _unhandledRejections = true; - -#if DEBUG - _ooms = false; -#else _ooms = true; -#endif } return self; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.h index 0f2f874ae..9e9cbb8c5 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.h @@ -12,7 +12,13 @@ NS_ASSUME_NONNULL_BEGIN @interface BSGCachesDirectory : NSObject -+ (NSString*) cachesDirectory; ++ (NSString *)cachesDirectory; + +/** + * Get a subdir relative to the caches directory. If the relative path doesn't exist, it will be created. + * This method will report errors but will not crash; if the path is invalid, it will return the caches path. + */ ++ (NSString *)getSubdirPath:(NSString *)relativePath; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.m index 8d448e63a..b0a9d0ea2 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGCachesDirectory.m @@ -13,8 +13,9 @@ @implementation BSGCachesDirectory static NSString* g_cachesPath = nil; -+ (NSString*) cachesDirectory { - static NSString* cachesPath = nil; ++ (NSString *)cachesDirectory { + // Default to an unusable location that will always fail. + static NSString* cachesPath = @"/"; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -34,4 +35,18 @@ + (NSString*) cachesDirectory { return cachesPath; } ++ (NSString *)getSubdirPath:(NSString *)relativePath { + NSString *cachesDir = [self cachesDirectory]; + NSString *subdirPath = [cachesDir stringByAppendingPathComponent:relativePath]; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSError *error = nil; + if(![fileManager createDirectoryAtPath:subdirPath withIntermediateDirectories:YES attributes:nil error:&error]) { + BSG_KSLOG_ERROR(@"Could not create caches subdir %@: %@", subdirPath, error); + // Make the best of it, just return the top-level caches dir. + return cachesDir; + } + return subdirPath; +} + @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.h index 876cda4b6..70047c173 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.h @@ -37,6 +37,4 @@ BOOL BSGIsSanitizedType(id _Nullable obj); */ id _Nullable BSGSanitizeObject(id _Nullable obj); -NSDictionary *_Nullable BSGDeserializeJson(char *_Nullable json); - #endif diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m index 209c1412c..1261169e3 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m @@ -58,25 +58,3 @@ id BSGSanitizeObject(id obj) { } return output; } - -NSDictionary *BSGDeserializeJson(char *json) { - if (json != NULL) { - NSString *str = [NSString stringWithCString:json encoding:NSUTF8StringEncoding]; - - if (str != nil) { - NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding] ; - if (data != nil) { - NSError *error; - NSDictionary *decode = [BSGJSONSerialization JSONObjectWithData:data - options:0 - error:&error]; - if (error != nil) { - bsg_log_err(@"Failed to deserialize JSON: %@", error); - } else { - return decode; - } - } - } - } - return nil; -} diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m index 4ab4bf0f9..49558d088 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m @@ -24,10 +24,13 @@ #import "BSG_RFC3339DateTool.h" -// New formatter: Everything is UTC +// New formatter: Everything is UTC with milliseconds +static NSDateFormatter *g_currentDateFormatter; + +// Old formatter: Everything is UTC, no milliseconds static NSDateFormatter *g_utcDateFormatter; -// Old formatter: Time zones can be specified +// Oldx2 formatter: Time zones can be specified static NSDateFormatter *g_timezoneAllowedDateFormatter; @implementation BSG_RFC3339DateTool @@ -36,6 +39,11 @@ + (void)initialize { NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; NSTimeZone *zone = [NSTimeZone timeZoneForSecondsFromGMT:0]; + g_currentDateFormatter = [NSDateFormatter new]; + [g_currentDateFormatter setLocale:locale]; + [g_currentDateFormatter setTimeZone:zone]; + [g_currentDateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"]; + g_utcDateFormatter = [NSDateFormatter new]; [g_utcDateFormatter setLocale:locale]; [g_utcDateFormatter setTimeZone:zone]; @@ -52,19 +60,25 @@ + (NSString *)stringFromDate:(NSDate *)date { if (![date isKindOfClass:[NSDate class]]) { return nil; } - return [g_utcDateFormatter stringFromDate:date]; + return [g_currentDateFormatter stringFromDate:date]; } + (NSDate *)dateFromString:(NSString *)string { if (![string isKindOfClass:[NSString class]]) { return nil; } - NSDate *date = [g_utcDateFormatter dateFromString:string]; - if (!date) { - // Fallback to older date format that included time zones - date = [g_timezoneAllowedDateFormatter dateFromString:string]; + NSDate *date = nil; + + if((date = [g_currentDateFormatter dateFromString:string]) != nil) { + return date; + } + + // Fallback to older date formats + if((date = [g_utcDateFormatter dateFromString:string]) != nil) { + return date; } - return date; + + return [g_timezoneAllowedDateFormatter dateFromString:string]; } + (NSString *)stringFromUNIXTimestamp:(unsigned long long)timestamp { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c index f233f0505..e4352854d 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c @@ -16,9 +16,11 @@ #include #include #include +#include static DIR* g_currentDir = NULL; static int g_currentDirFD = 0; +static char g_path[PATH_MAX+1]; static int openKeyRead(const char* name) { return openat(g_currentDirFD, name, O_RDONLY, 0); @@ -55,6 +57,8 @@ void bsgkv_open(const char* path, int* err) { return; } + strncpy(g_path, path, sizeof(g_path)); + g_path[sizeof(g_path)-1] = 0; *err = 0; } @@ -69,6 +73,53 @@ void bsgkv_close(void) { } } +void bsgkv_purge(int* err) { + // Set up a baseline path buffer to append the file names onto. + char path[sizeof(g_path)]; + strcpy(path, g_path); + size_t basePathLength = strlen(path); + if(basePathLength >= PATH_MAX-2) { + *err = E2BIG; + return; + } + path[basePathLength++] = '/'; + path[basePathLength] = 0; + char* const filename = path + basePathLength; + const size_t nameMaxLength = PATH_MAX - basePathLength; + + *err = 0; + + // Step through K-V store directory, deleting all regular files. + rewinddir(g_currentDir); + for(;;) { + errno = 0; + struct dirent* dent = readdir(g_currentDir); + if(dent == NULL) { + if(errno != 0) { + *err = errno; + return; + } + break; + } + if(dent->d_type != DT_REG) { + continue; + } + if(dent->d_namlen > nameMaxLength) { + // Set an error but don't stop purging + *err = E2BIG; + } else { + memcpy(filename, dent->d_name, dent->d_namlen); + filename[dent->d_namlen] = 0; + if(unlink(path) != 0) { + // Set an error but don't stop purging + *err = errno; + } + } + } + + rewinddir(g_currentDir); +} + void bsgkv_delete(const char* key, int* err) { if(unlinkat(g_currentDirFD, key, 0) < 0) { if(errno != ENOENT) { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.h index 4dc192ab5..88413f39a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.h @@ -45,6 +45,11 @@ void bsgkv_open(const char* restrict path, int* restrict err); */ void bsgkv_close(void); +/** + * Purge the KV store, deleting all values. + */ +void bsgkv_purge(int* err); + /** * Delete the value associated with the specified key. * Deleting a non-existent key has no effect, and returns success. diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.h index e64e93c30..45a4db8ae 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.h @@ -18,6 +18,13 @@ NS_ASSUME_NONNULL_BEGIN */ @interface BugsnagKVStore : NSObject +/** + * Purge the KV store, deleting all values. + */ +- (void)purge; + +- (void)deleteKey:(NSString *)key; + - (void)setBoolean:(bool)value forKey:(NSString*)key; - (bool)booleanForKey:(NSString*)key defaultValue:(bool)defaultValue; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.m index a269f3bab..c3b85e6c5 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStoreObjC.m @@ -16,8 +16,7 @@ static void bsgkv_init() { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - NSString *cachesDir = [BSGCachesDirectory cachesDirectory]; - const char *kvstoreDir = [[cachesDir stringByAppendingPathComponent:KV_DIR] cStringUsingEncoding:NSUTF8StringEncoding]; + const char *kvstoreDir = [[BSGCachesDirectory getSubdirPath:KV_DIR] UTF8String]; int err = 0; bsgkv_open(kvstoreDir, &err); if(err != 0) { @@ -32,6 +31,22 @@ + (void)initialize { bsgkv_init(); } +- (void)purge { + int err = 0; + bsgkv_purge(&err); + if(err != 0) { + bsg_log_err(@"Error purging kv store. errno = %d", err); + } +} + +- (void)deleteKey:(NSString *)key { + int err = 0; + bsgkv_delete([key UTF8String], &err); + if(err != 0) { + bsg_log_err(@"Error deleting key %@ from kv store. errno = %d", key, err); + } +} + - (void)setBoolean:(bool)value forKey:(NSString*)key { int err = 0; bsgkv_setBoolean([key UTF8String], value, &err); @@ -57,10 +72,7 @@ - (NSNumber*)NSBooleanForKey:(NSString*)key defaultValue:(bool)defaultValue { - (void)setString:(NSString*)value forKey:(NSString*)key { int err = 0; if(value == nil || (id)value == [NSNull null]) { - bsgkv_delete([key UTF8String], &err); - if(err != 0) { - bsg_log_err(@"Error deleting key %@ from kv store. errno = %d", key, err); - } + [self deleteKey:key]; } else { bsgkv_setString([key UTF8String], [value UTF8String], &err); if(err != 0) { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m index f3015091d..39bbb18d3 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m @@ -37,6 +37,7 @@ //#define BSG_KSLogger_LocalLevel TRACE #import "BSG_KSLogger.h" #import "BugsnagThread.h" +#import "BSGJSONSerialization.h" #import "BSGSerialization.h" #import "Bugsnag.h" #import "BugsnagCollections.h" @@ -45,6 +46,9 @@ #if BSG_HAS_UIKIT #import #endif +#if TARGET_OS_OSX +#import +#endif // ============================================================================ #pragma mark - Default Constants - @@ -234,8 +238,8 @@ - (BOOL)install { return false; } -#if BSG_HAS_UIKIT NSNotificationCenter *nCenter = [NSNotificationCenter defaultCenter]; +#if BSG_HAS_UIKIT [nCenter addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification @@ -256,6 +260,20 @@ - (BOOL)install { selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil]; +#elif TARGET_OS_OSX + // MacOS "active" serves the same purpose as "foreground" in iOS + [nCenter addObserver:self + selector:@selector(applicationDidEnterBackground) + name:NSApplicationDidResignActiveNotification + object:nil]; + [nCenter addObserver:self + selector:@selector(applicationWillEnterForeground) + name:NSApplicationDidBecomeActiveNotification + object:nil]; + [nCenter addObserver:self + selector:@selector(applicationWillTerminate) + name:NSApplicationWillTerminateNotification + object:nil]; #endif return true; @@ -308,17 +326,28 @@ - (void)sendAllReports { numFrames = 0; } } - - char *trace = bsg_kscrash_captureThreadTrace(depth, numFrames, callstack, recordAllThreads); + + NSString *tracePath = [NSTemporaryDirectory() stringByAppendingPathComponent: + [NSUUID UUID].UUIDString]; + bsg_kscrash_captureThreadTrace(depth, numFrames, callstack, recordAllThreads, + tracePath.fileSystemRepresentation); free(callstack); - NSDictionary *json = BSGDeserializeJson(trace); - free(trace); + + NSData *jsonData = [NSData dataWithContentsOfFile:tracePath]; + NSError *error = nil; + NSDictionary *json = [BSGJSONSerialization + JSONObjectWithData:jsonData options:0 error:&error]; + + [[NSFileManager defaultManager] removeItemAtPath:tracePath error:NULL]; if (json) { return [BugsnagThread threadsFromArray:[json valueForKeyPath:@"crash.threads"] binaryImages:json[@"binary_images"] depth:depth errorType:nil]; + } else { + BSG_KSLOG_ERROR(@"Failed to decode thread trace JSON, error = %@", + error); } return @[]; } @@ -327,7 +356,7 @@ - (NSDictionary *)captureAppStats { BSG_KSCrash_State state = crashContext()->state; bsg_kscrashstate_updateDurationStats(&state); NSMutableDictionary *dict = [NSMutableDictionary new]; - BSGDictSetSafeObject(dict, @(state.activeDurationSinceLaunch), @BSG_KSCrashField_ActiveTimeSinceLaunch); + BSGDictSetSafeObject(dict, @(state.foregroundDurationSinceLaunch), @BSG_KSCrashField_ActiveTimeSinceLaunch); BSGDictSetSafeObject(dict, @(state.backgroundDurationSinceLaunch), @BSG_KSCrashField_BGTimeSinceLaunch); BSGDictSetSafeObject(dict, @(state.applicationIsInForeground), @BSG_KSCrashField_AppInFG); return dict; @@ -364,12 +393,12 @@ -(TYPE)NAME { \ } BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(NSTimeInterval, - activeDurationSinceLastCrash) + foregroundDurationSinceLastCrash) BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(NSTimeInterval, backgroundDurationSinceLastCrash) BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(int, launchesSinceLastCrash) BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(int, sessionsSinceLastCrash) -BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(NSTimeInterval, activeDurationSinceLaunch) +BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(NSTimeInterval, foregroundDurationSinceLaunch) BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(NSTimeInterval, backgroundDurationSinceLaunch) BSG_SYNTHESIZE_CRASH_STATE_PROPERTY(int, sessionsSinceLaunch) @@ -464,11 +493,11 @@ - (const char *)encodeAsJSONString:(id)object { // ============================================================================ - (void)applicationDidBecomeActive { - bsg_kscrashstate_notifyAppActive(true); + bsg_kscrashstate_notifyAppInForeground(true); } - (void)applicationWillResignActive { - bsg_kscrashstate_notifyAppActive(false); + bsg_kscrashstate_notifyAppInForeground(true); } - (void)applicationDidEnterBackground { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashAdvanced.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashAdvanced.h index 059dff84e..a2e237a12 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashAdvanced.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashAdvanced.h @@ -38,7 +38,7 @@ /** Total active time elapsed since the last crash. */ @property(nonatomic, readonly, assign) - NSTimeInterval activeDurationSinceLastCrash; + NSTimeInterval foregroundDurationSinceLastCrash; /** Total time backgrounded elapsed since the last crash. */ @property(nonatomic, readonly, assign) @@ -51,7 +51,7 @@ @property(nonatomic, readonly, assign) int sessionsSinceLastCrash; /** Total active time elapsed since launch. */ -@property(nonatomic, readonly, assign) NSTimeInterval activeDurationSinceLaunch; +@property(nonatomic, readonly, assign) NSTimeInterval foregroundDurationSinceLaunch; /** Total time backgrounded elapsed since launch. */ @property(nonatomic, readonly, assign) diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c index 454d3e6d8..c31a503ec 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c @@ -151,6 +151,7 @@ void bsg_kscrash_reinstall(const char *const crashReportFilePath, BSG_KSLOG_ERROR("Failed to initialize persistent crash state"); } context->state.appLaunchTime = mach_absolute_time(); + context->state.appStateTransitionTime = mach_absolute_time(); } BSG_KSCrashType bsg_kscrash_setHandlingCrashTypes(BSG_KSCrashType crashTypes) { @@ -217,7 +218,10 @@ void bsg_kscrash_setThreadTracingEnabled(bool threadTracingEnabled) { crashContext()->crash.threadTracingEnabled = threadTracingEnabled; } -char *bsg_kscrash_captureThreadTrace(int discardDepth, int frameCount, uintptr_t *callstack, const bool recordAllThreads) { +void bsg_kscrash_captureThreadTrace(int discardDepth, int frameCount, + uintptr_t *callstack, + const bool recordAllThreads, + const char *path) { BSG_KSCrash_Context *globalContext = crashContext(); BSG_KSCrash_Context localContext = {}; BSG_KSCrash_Context *context = &localContext; @@ -240,11 +244,13 @@ char *bsg_kscrash_captureThreadTrace(int discardDepth, int frameCount, uintptr_t if (context->crash.threadTracingEnabled) { bsg_kscrashsentry_suspend_threads_user(); } - - char *trace = bsg_kscrw_i_captureThreadTrace(context); + + // Threads may have been suspended while holding locks in malloc, the + // Objective-C runtime, or other subsystems, so we must only call + // async-signal-safe functions. + bsg_kscrw_i_captureThreadTrace(context, path); if (context->crash.threadTracingEnabled) { bsg_kscrashsentry_resume_threads_user(false); } - return trace; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.h index 52d2d2e03..8bb293e47 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.h @@ -169,9 +169,13 @@ BSG_KSCrash_Context *crashContext(void); * * @param discardDepth - the number of stack frames to discard * - * @return a trace of all the threads as a JSON string. + * @param path the absolute path of the file where the thread trace should be + * written. The file will be created if it does not exist. */ -char *bsg_kscrash_captureThreadTrace(int discardDepth, int frameCount, uintptr_t *callstack, const bool recordAllThreads); +void bsg_kscrash_captureThreadTrace(int discardDepth, int frameCount, + uintptr_t *callstack, + const bool recordAllThreads, + const char *path); #ifdef __cplusplus } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c index ab011a84c..02fd6de11 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c @@ -1252,20 +1252,25 @@ void bsg_kscrw_i_writeError(const BSG_KSCrashReportWriter *const writer, case BSG_KSCrashTypeMachException: writer->beginObject(writer, BSG_KSCrashField_Mach); { + char buffer[20] = {0}; + writer->addUIntegerElement(writer, BSG_KSCrashField_Exception, (unsigned)machExceptionType); if (machExceptionName != NULL) { writer->addStringElement(writer, BSG_KSCrashField_ExceptionName, machExceptionName); } - writer->addUIntegerElement(writer, BSG_KSCrashField_Code, - (unsigned)machCode); + + snprintf(buffer, sizeof(buffer), "0x%llx", machCode); + writer->addStringElement(writer, BSG_KSCrashField_Code, buffer); + if (machCodeName != NULL) { writer->addStringElement(writer, BSG_KSCrashField_CodeName, machCodeName); } - writer->addUIntegerElement(writer, BSG_KSCrashField_Subcode, - (unsigned)machSubCode); + + snprintf(buffer, sizeof(buffer), "0x%llx", machSubCode); + writer->addStringElement(writer, BSG_KSCrashField_Subcode, buffer); } writer->endContainer(writer); writer->addStringElement(writer, BSG_KSCrashField_Type, @@ -1346,8 +1351,6 @@ void bsg_kscrw_i_writeAppStats(const BSG_KSCrashReportWriter *const writer, BSG_KSCrash_State *state) { writer->beginObject(writer, key); { - writer->addBooleanElement(writer, BSG_KSCrashField_AppActive, - state->applicationIsActive); writer->addBooleanElement(writer, BSG_KSCrashField_AppInFG, state->applicationIsInForeground); @@ -1357,7 +1360,7 @@ void bsg_kscrw_i_writeAppStats(const BSG_KSCrashReportWriter *const writer, state->sessionsSinceLastCrash); writer->addFloatingPointElement(writer, BSG_KSCrashField_ActiveTimeSinceCrash, - state->activeDurationSinceLastCrash); + state->foregroundDurationSinceLastCrash); writer->addFloatingPointElement( writer, BSG_KSCrashField_BGTimeSinceCrash, state->backgroundDurationSinceLastCrash); @@ -1366,7 +1369,7 @@ void bsg_kscrw_i_writeAppStats(const BSG_KSCrashReportWriter *const writer, state->sessionsSinceLaunch); writer->addFloatingPointElement(writer, BSG_KSCrashField_ActiveTimeSinceLaunch, - state->activeDurationSinceLaunch); + state->foregroundDurationSinceLaunch); writer->addFloatingPointElement(writer, BSG_KSCrashField_BGTimeSinceLaunch, state->backgroundDurationSinceLaunch); @@ -1654,45 +1657,24 @@ void bsg_kscrashreport_logCrash(const BSG_KSCrash_Context *const crashContext) { bsg_kscrw_i_logCrashThreadBacktrace(&crashContext->crash); } -int bsg_kscrw_i_collectJsonData(const char *const data, const size_t length, void *const userData) { - BSG_ThreadDataBuffer *thread_data = (BSG_ThreadDataBuffer *)userData; - if (thread_data->data == NULL) { - // Allocate initial memory for JSON data - void *ptr = malloc(BSG_THREAD_DATA_SIZE_INITIAL); - if (ptr != NULL) { - thread_data->data = ptr; - *thread_data->data = '\0'; - thread_data->allocated_size = BSG_THREAD_DATA_SIZE_INITIAL; - } else { // failed to allocate enough memory - abandon collection - return BSG_KSJSON_ERROR_CANNOT_ADD_DATA; - } - } - while (strlen(thread_data->data) + length >= thread_data->allocated_size) { - // Expand memory to hold further data - void *ptr = realloc(thread_data->data, thread_data->allocated_size + BSG_THREAD_DATA_SIZE_INCREMENT); - if (ptr != NULL) { - thread_data->data = ptr; - thread_data->allocated_size += BSG_THREAD_DATA_SIZE_INCREMENT; - } else { // failed to allocate enough memory - abandon collection - return BSG_KSJSON_ERROR_CANNOT_ADD_DATA; - } +void bsg_kscrw_i_captureThreadTrace(const BSG_KSCrash_Context *crashContext, + const char *path) { + int fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0644); + if (fd < 0) { + BSG_KSLOG_ERROR("Could not open file %s: %s", path, strerror(errno)); + return; } - strncat(thread_data->data, data, length); - return BSG_KSJSON_OK; -} - -char *bsg_kscrw_i_captureThreadTrace(const BSG_KSCrash_Context *crashContext) { BSG_KSJSONEncodeContext jsonContext; BSG_KSCrashReportWriter concreteWriter; BSG_KSCrashReportWriter *writer = &concreteWriter; bsg_kscrw_i_prepareReportWriter(writer, &jsonContext); - BSG_ThreadDataBuffer userData = { NULL, 0 }; - bsg_ksjsonbeginEncode(bsg_getJsonContext(writer), false, bsg_kscrw_i_collectJsonData, &userData); + bsg_ksjsonbeginEncode(bsg_getJsonContext(writer), false, + bsg_kscrw_i_addJSONData, &fd); writer->beginObject(writer, BSG_KSCrashField_Report); bsg_kscrw_i_writeTraceInfo(crashContext, writer); writer->endContainer(writer); bsg_ksjsonendEncode(bsg_getJsonContext(writer)); - return userData.data; + close(fd); } void bsg_kscrw_i_writeTraceInfo(const BSG_KSCrash_Context *crashContext, diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.h index 719e5aeda..91318726c 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.h @@ -64,15 +64,17 @@ void bsg_kscrashreport_writeMinimalReport( void bsg_kscrashreport_logCrash(const BSG_KSCrash_Context *const crashContext); /** - * Captures a thread trace for use by the Objective-C layer to append to handled errors. - * This suspends all threads while the information is being gathered. + * Captures a thread trace for use by the Objective-C layer to append to handled + * errors. (async-safe). * * @param crashContext Contextual information about the crash and environment. * The caller must fill this out before passing it in. * - * @return the thread trace encoded as a JSON string + * @param path the absolute path of the file where the thread trace should be + * written. The file will be created if it does not exist. */ -char *bsg_kscrw_i_captureThreadTrace(const BSG_KSCrash_Context *crashContext); +void bsg_kscrw_i_captureThreadTrace(const BSG_KSCrash_Context *crashContext, + const char *path); #ifdef __cplusplus } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReportFields.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReportFields.h index 73d7970f8..475c7e005 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReportFields.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReportFields.h @@ -145,7 +145,6 @@ #define BSG_KSCrashField_ActiveTimeSinceCrash "active_time_since_last_crash" #define BSG_KSCrashField_ActiveTimeSinceLaunch "active_time_since_launch" -#define BSG_KSCrashField_AppActive "application_active" #define BSG_KSCrashField_AppInFG "application_in_foreground" #define BSG_KSCrashField_BGTimeSinceCrash "background_time_since_last_crash" #define BSG_KSCrashField_BGTimeSinceLaunch "background_time_since_launch" diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h index 192f85eb6..6a7348302 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h @@ -40,10 +40,11 @@ extern "C" { #include "BSG_KSCrashType.h" typedef struct { + // Saved data - /** Total active time elapsed since the last crash. */ - double activeDurationSinceLastCrash; + /** Total time elapsed in the foreground since the last crash. */ + double foregroundDurationSinceLastCrash; /** Total time backgrounded elapsed since the last crash. */ double backgroundDurationSinceLastCrash; @@ -54,8 +55,8 @@ typedef struct { /** Number of sessions (launch, resume from suspend) since last crash. */ int sessionsSinceLastCrash; - /** Total active time elapsed since launch. */ - double activeDurationSinceLaunch; + /** Total time elapsed in the foreground since launch. */ + double foregroundDurationSinceLaunch; /** Total time backgrounded elapsed since launch. */ double backgroundDurationSinceLaunch; @@ -74,13 +75,10 @@ typedef struct { /** Timestamp for when the app was launched (mach_absolute_time()) */ uint64_t appLaunchTime; - /** Timestamp for when the app state was last changed (active<-> inactive, - * background<->foreground) (mach_absolute_time()) */ + /** Timestamp for when the app state was last changed + * (background<->foreground) (mach_absolute_time()) */ uint64_t appStateTransitionTime; - /** If true, the application is currently active. */ - bool applicationIsActive; - /** If true, the application is currently in the foreground. */ bool applicationIsInForeground; @@ -96,12 +94,6 @@ typedef struct { */ bool bsg_kscrashstate_init(const char *stateFilePath, BSG_KSCrash_State *state); -/** Notify the crash reporter of the application active state. - * - * @param isActive true if the application is active, otherwise false. - */ -void bsg_kscrashstate_notifyAppActive(bool isActive); - /** Notify the crash reporter of the application foreground/background state. * * @param isInForeground true if the application is in the foreground, false if diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m index 09c6adf2a..410f6ff21 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m @@ -52,7 +52,7 @@ #define BSG_kKeyFormatVersion "version" #define BSG_kKeyCrashedLastLaunch "crashedLastLaunch" -#define BSG_kKeyActiveDurationSinceLastCrash "activeDurationSinceLastCrash" +#define BSG_kKeyActiveDurationSinceLastCrash "foregroundDurationSinceLastCrash" #define BSG_kKeyBackgroundDurationSinceLastCrash \ "backgroundDurationSinceLastCrash" #define BSG_kKeyLaunchesSinceLastCrash "launchesSinceLastCrash" @@ -93,7 +93,7 @@ int bsg_kscrashstate_i_onFloatingPointElement(const char *const name, BSG_KSCrash_State *state = userData; if (strcmp(name, BSG_kKeyActiveDurationSinceLastCrash) == 0) { - state->activeDurationSinceLastCrash = value; + state->foregroundDurationSinceLastCrash = value; } if (strcmp(name, BSG_kKeyBackgroundDurationSinceLastCrash) == 0) { state->backgroundDurationSinceLastCrash = value; @@ -189,8 +189,8 @@ bool bsg_kscrashstate_i_loadState(BSG_KSCrash_State *const context, return false; } - context->activeDurationSinceLastCrash = [objectContext[@"activeDurationSinceLastCrash"] doubleValue]; - context->activeDurationSinceLaunch = [objectContext[@"activeDurationSinceLaunch"] doubleValue]; + context->foregroundDurationSinceLastCrash = [objectContext[@"foregroundDurationSinceLastCrash"] doubleValue]; + context->foregroundDurationSinceLaunch = [objectContext[@"foregroundDurationSinceLaunch"] doubleValue]; context->appLaunchTime = [objectContext[@"appLaunchTime"] unsignedLongLongValue]; context->appStateTransitionTime = [objectContext[@"appStateTransitionTime"] unsignedLongLongValue]; context->launchesSinceLastCrash = [objectContext[@"launchesSinceLastCrash"] intValue]; @@ -198,7 +198,6 @@ bool bsg_kscrashstate_i_loadState(BSG_KSCrash_State *const context, context->sessionsSinceLaunch = [objectContext[@"sessionsSinceLaunch"] intValue]; context->crashedLastLaunch = [objectContext[@"crashedLastLaunch"] boolValue]; context->crashedThisLaunch = [objectContext[@"crashedThisLaunch"] boolValue]; - context->applicationIsActive = [objectContext[@"applicationIsActive"] boolValue]; context->applicationIsInForeground = [objectContext[@"applicationIsInForeground"] boolValue]; context->backgroundDurationSinceLaunch = [objectContext[@"backgroundDurationSinceLaunch"] doubleValue]; context->backgroundDurationSinceLastCrash = [objectContext[@"backgroundDurationSinceLastCrash"] doubleValue]; @@ -244,7 +243,7 @@ bool bsg_kscrashstate_i_saveState(const BSG_KSCrash_State *const state, } if ((result = bsg_ksjsonaddFloatingPointElement( &JSONContext, BSG_kKeyActiveDurationSinceLastCrash, - state->activeDurationSinceLastCrash)) != BSG_KSJSON_OK) { + state->foregroundDurationSinceLastCrash)) != BSG_KSJSON_OK) { goto done; } if ((result = bsg_ksjsonaddFloatingPointElement( @@ -286,10 +285,10 @@ bool bsg_kscrashstate_init(const char *const stateFilePath, bsg_kscrashstate_i_loadState(state, stateFilePath); state->sessionsSinceLaunch = 1; - state->activeDurationSinceLaunch = 0; + state->foregroundDurationSinceLaunch = 0; state->backgroundDurationSinceLaunch = 0; if (state->crashedLastLaunch) { - state->activeDurationSinceLastCrash = 0; + state->foregroundDurationSinceLastCrash = 0; state->backgroundDurationSinceLastCrash = 0; state->launchesSinceLastCrash = 0; state->sessionsSinceLastCrash = 0; @@ -311,36 +310,28 @@ bool bsg_kscrashstate_init(const char *const stateFilePath, return bsg_kscrashstate_i_saveState(state, stateFilePath); } -void bsg_kscrashstate_notifyAppActive(const bool isActive) { - BSG_KSCrash_State *const state = bsg_g_state; - - state->applicationIsActive = isActive; - if (isActive) { - state->appStateTransitionTime = mach_absolute_time(); - } else { - double duration = bsg_ksmachtimeDifferenceInSeconds( - mach_absolute_time(), state->appStateTransitionTime); - state->activeDurationSinceLaunch += duration; - state->activeDurationSinceLastCrash += duration; - } -} - void bsg_kscrashstate_notifyAppInForeground(const bool isInForeground) { BSG_KSCrash_State *const state = bsg_g_state; const char *const stateFilePath = bsg_g_stateFilePath; + if (state->applicationIsInForeground == isInForeground) { + return; + } state->applicationIsInForeground = isInForeground; + uint64_t timeNow = mach_absolute_time(); + double duration = bsg_ksmachtimeDifferenceInSeconds( + timeNow, state->appStateTransitionTime); if (isInForeground) { - double duration = bsg_ksmachtimeDifferenceInSeconds( - mach_absolute_time(), state->appStateTransitionTime); state->backgroundDurationSinceLaunch += duration; state->backgroundDurationSinceLastCrash += duration; state->sessionsSinceLastCrash++; state->sessionsSinceLaunch++; } else { - state->appStateTransitionTime = mach_absolute_time(); + state->foregroundDurationSinceLaunch += duration; + state->foregroundDurationSinceLastCrash += duration; bsg_kscrashstate_i_saveState(state, stateFilePath); } + state->appStateTransitionTime = timeNow; } void bsg_kscrashstate_notifyAppTerminate(void) { @@ -367,10 +358,10 @@ void bsg_kscrashstate_notifyAppCrash(BSG_KSCrashType type) { void bsg_kscrashstate_updateDurationStats(BSG_KSCrash_State *const state) { const double duration = bsg_ksmachtimeDifferenceInSeconds( mach_absolute_time(), state->appStateTransitionTime); - if (state->applicationIsActive) { - state->activeDurationSinceLaunch += duration; - state->activeDurationSinceLastCrash += duration; - } else if (!state->applicationIsInForeground) { + if (state->applicationIsInForeground) { + state->foregroundDurationSinceLaunch += duration; + state->foregroundDurationSinceLastCrash += duration; + } else { state->backgroundDurationSinceLaunch += duration; state->backgroundDurationSinceLastCrash += duration; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.m index eb3a08355..277ff55dd 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.m @@ -11,82 +11,12 @@ #import #import "BSG_KSDynamicLinker.h" #import "BSG_KSMachHeaders.h" -#import "BugsnagPlatformConditional.h" - -// MARK: - Locking - -static const NSOperatingSystemVersion minSdkForUnfairLock = - #if BSG_PLATFORM_IOS - {10,0,0}; - #elif BSG_PLATFORM_OSX - {10,12,0}; - #elif BSG_PLATFORM_TVOS - {10,0,0}; - #elif BSG_PLATFORM_WATCHOS - {3,0,0} - #endif - -// Pragma's hide unavoidable (and expected) deprecation/unavailable warnings -_Pragma("clang diagnostic push") -_Pragma("clang diagnostic ignored \"-Wunguarded-availability\"") -static os_unfair_lock bsg_mach_binary_images_access_lock_unfair = OS_UNFAIR_LOCK_INIT; -_Pragma("clang diagnostic pop") - -_Pragma("clang diagnostic push") -_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -static OSSpinLock bsg_mach_binary_images_access_lock_spin = OS_SPINLOCK_INIT; -_Pragma("clang diagnostic pop") - -// Lock helpers. These use bulky Pragmas to hide warnings so are in their own functions for clarity. - -void bsg_spin_lock() { - _Pragma("clang diagnostic push") - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") - OSSpinLockLock(&bsg_mach_binary_images_access_lock_spin); - _Pragma("clang diagnostic pop") -} - -void bsg_spin_unlock() { - _Pragma("clang diagnostic push") - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") - OSSpinLockUnlock(&bsg_mach_binary_images_access_lock_spin); - _Pragma("clang diagnostic pop") -} - -void bsg_unfair_lock() { - _Pragma("clang diagnostic push") - _Pragma("clang diagnostic ignored \"-Wunguarded-availability\"") - os_unfair_lock_lock(&bsg_mach_binary_images_access_lock_unfair); - _Pragma("clang diagnostic pop") -} - -void bsg_unfair_unlock() { - _Pragma("clang diagnostic push") - _Pragma("clang diagnostic ignored \"-Wunguarded-availability\"") - os_unfair_lock_unlock(&bsg_mach_binary_images_access_lock_unfair); - _Pragma("clang diagnostic pop") -} - -void bsg_mach_headers_cache_lock() { - if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:minSdkForUnfairLock]) { - bsg_unfair_lock(); - } else { - bsg_spin_lock(); - } -} - -void bsg_mach_headers_cache_unlock() { - if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:minSdkForUnfairLock]) { - bsg_unfair_unlock(); - } else { - bsg_spin_unlock(); - } -} // MARK: - Mach Header Linked List static BSG_Mach_Header_Info *bsg_g_mach_headers_images_head; static BSG_Mach_Header_Info *bsg_g_mach_headers_images_tail; +static dispatch_queue_t bsg_g_serial_queue; BSG_Mach_Header_Info *bsg_mach_headers_get_images() { return bsg_g_mach_headers_images_head; @@ -103,6 +33,7 @@ void bsg_mach_headers_initialize() { bsg_g_mach_headers_images_head = NULL; bsg_g_mach_headers_images_tail = NULL; + bsg_g_serial_queue = dispatch_queue_create("com.bugsnag.mach-headers", DISPATCH_QUEUE_SERIAL); } void bsg_mach_headers_register_for_changes() { @@ -190,24 +121,19 @@ bool bsg_mach_headers_populate_info(const struct mach_header *header, intptr_t s } void bsg_mach_headers_add_image(const struct mach_header *header, intptr_t slide) { - BSG_Mach_Header_Info *newImage = malloc(sizeof(BSG_Mach_Header_Info)); if (newImage != NULL) { if (bsg_mach_headers_populate_info(header, slide, newImage)) { - - bsg_mach_headers_cache_lock(); - - if (bsg_g_mach_headers_images_head == NULL) { - bsg_g_mach_headers_images_head = newImage; - } else { - bsg_g_mach_headers_images_tail->next = newImage; - } - bsg_g_mach_headers_images_tail = newImage; - - bsg_mach_headers_cache_unlock(); + dispatch_sync(bsg_g_serial_queue, ^{ + if (bsg_g_mach_headers_images_head == NULL) { + bsg_g_mach_headers_images_head = newImage; + } else { + bsg_g_mach_headers_images_tail->next = newImage; + } + bsg_g_mach_headers_images_tail = newImage; + }); } } - } /** diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m index 5aaac9702..7ff0cc916 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m @@ -12,7 +12,7 @@ #import "BugsnagDeviceWithState.h" #import "BugsnagCollections.h" #import "BugsnagLogger.h" -#import "BSGOutOfMemoryWatchdog.h" +#import "BugsnagSystemState.h" #import "Bugsnag.h" NSDictionary *BSGParseDeviceMetadata(NSDictionary *event) { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m index 494c670ef..50fb61eb1 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m @@ -23,7 +23,7 @@ - (instancetype)init { #else self.name = @"Bugsnag Objective-C"; #endif - self.version = @"6.1.7"; + self.version = @"6.2.2"; self.url = @"https://github.com/bugsnag/bugsnag-cocoa"; self.dependencies = [NSMutableArray new]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h index 1fec8adf7..758f19afa 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h @@ -5,22 +5,47 @@ #ifndef BUGSNAG_PRIVATE_H #define BUGSNAG_PRIVATE_H +#import "BSG_RFC3339DateTool.h" #import "Bugsnag.h" #import "BugsnagBreadcrumb.h" #import "BugsnagBreadcrumbs.h" +#import "BugsnagKeys.h" +#import "BugsnagLogger.h" +#import "BugsnagMetadataInternal.h" +#import "BugsnagPlatformConditional.h" + +@class BugsnagConfiguration; + +#pragma mark - + +@interface BugsnagConfiguration () + +/// Throws an NSInvalidArgumentException if the API key is empty or missing. +/// Logs a warning message if the API key is not in the expected format. +- (void)validate; + +@end + +#pragma mark - @interface BugsnagBreadcrumb () - (NSDictionary *_Nullable)objectValue; + @end +#pragma mark - + @interface BugsnagBreadcrumbs () /** * Reads and return breadcrumb data currently stored on disk */ - (NSArray *_Nullable)cachedBreadcrumbs; + @end +#pragma mark - + @interface Bugsnag () /** Get the current Bugsnag configuration. diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/Bugsnag.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/Bugsnag.h index 98090da0b..828aa89a6 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/Bugsnag.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/Bugsnag.h @@ -50,19 +50,28 @@ /** Start listening for crashes. * - * This method initializes Bugsnag with the configuration set in your PList. Any uncaught - * NSExceptions, C++ exceptions, mach exceptions or signals will be logged to - * disk before your app crashes. The next time your app boots, we send any such - * reports to Bugsnag. + * This method initializes Bugsnag with the configuration set in your Info.plist. + * + * If a Bugsnag apiKey string has not been added to your Info.plist or is empty, an + * NSException will be thrown to indicate that the configuration is not valid. + * + * Once successfully initialized, NSExceptions, C++ exceptions, Mach exceptions and + * signals will be logged to disk before your app crashes. The next time your app + * launches, these reports will be sent to your Bugsnag dashboard. */ + (BugsnagClient *_Nonnull)start; /** Start listening for crashes. * - * This method initializes Bugsnag with the default configuration. Any uncaught - * NSExceptions, C++ exceptions, mach exceptions or signals will be logged to - * disk before your app crashes. The next time your app boots, we send any such - * reports to Bugsnag. + * This method initializes Bugsnag with the default configuration and the provided + * apiKey. + * + * If apiKey is nil or is empty, an NSException will be thrown to indicate that the + * configuration is not valid. + * + * Once successfully initialized, NSExceptions, C++ exceptions, Mach exceptions and + * signals will be logged to disk before your app crashes. The next time your app + * launches, these reports will be sent to your Bugsnag dashboard. * * @param apiKey The API key from your Bugsnag dashboard. */ @@ -70,10 +79,14 @@ /** Start listening for crashes. * - * This method initializes Bugsnag. Any uncaught NSExceptions, uncaught - * C++ exceptions, mach exceptions or signals will be logged to disk before - * your app crashes. The next time your app boots, we send any such - * reports to Bugsnag. + * This method initializes Bugsnag with the provided configuration object. + * + * If the configuration's apiKey is nil or is empty, an NSException will be thrown + * to indicate that the configuration is not valid. + * + * Once successfully initialized, NSExceptions, C++ exceptions, Mach exceptions and + * signals will be logged to disk before your app crashes. The next time your app + * launches, these reports will be sent to your Bugsnag dashboard. * * @param configuration The configuration to use. */ diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h index 22ccb8b3f..a948fbfac 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h @@ -37,6 +37,8 @@ @class BugsnagEndpointConfiguration; @class BugsnagErrorTypes; +NS_ASSUME_NONNULL_BEGIN + /** * Controls whether Bugsnag should capture and serialize the state of all threads at the time * of an error. @@ -104,7 +106,17 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); * * @return a BugsnagConfiguration containing the options set in the plist file */ -+ (instancetype _Nonnull)loadConfig; ++ (instancetype)loadConfig; + +/** + * Initializes a new configuration object with the provided API key. + */ +- (instancetype)initWithApiKey:(NSString *)apiKey NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(_:)); + +/** + * Required declaration to suppress a superclass designated-initializer error + */ +- (instancetype)init NS_UNAVAILABLE NS_SWIFT_UNAVAILABLE("Use initWithApiKey:"); // ----------------------------------------------------------------------------- // MARK: - Properties @@ -216,18 +228,6 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); */ @property BugsnagErrorTypes *_Nonnull enabledErrorTypes; -/** - * Required declaration to suppress a superclass designated-initializer error - */ -- (instancetype _Nonnull )init NS_UNAVAILABLE NS_SWIFT_UNAVAILABLE("Use initWithApiKey:"); - -/** - * The designated initializer. - */ -- (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey - NS_DESIGNATED_INITIALIZER - NS_SWIFT_NAME(init(_:)); - /** * Set the endpoints to send data to. By default we'll send error reports to * https://notify.bugsnag.com, and sessions to https://sessions.bugsnag.com, but you can @@ -324,3 +324,5 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); - (void)addPlugin:(id _Nonnull)plugin; @end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md index c78bfb848..b67b0ccc7 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md @@ -1,6 +1,50 @@ Changelog ========= +## 6.2.2 (2020-10-21) + +## Enhancements + +* Support "foreground" duration in MacOS as well. + [848](https://github.com/bugsnag/bugsnag-cocoa/pull/848) + +* Timestamp accuracy in reports has been increased from seconds to milliseconds. + [847](https://github.com/bugsnag/bugsnag-cocoa/pull/847) + +* Calculation of "foreground" duration now also includes time in + UIApplicationStateActive and UIApplicationStateInactive states in order to + match Apple's definition of "foreground". + [839](https://github.com/bugsnag/bugsnag-cocoa/pull/839) + +## 6.2.1 (2020-10-15) + +## Bug fixes + +* Changed synchronization method when responding to dynamic library image events + to a dispatch queue, which is a more bulletproof and battle-hardened approach. + [837](https://github.com/bugsnag/bugsnag-cocoa/pull/837) + +* Fixed a deadlock which can occur when calling `notify` + [833](https://github.com/bugsnag/bugsnag-cocoa/pull/833) + +## 6.2.0 (2020-10-07) + +### Enhancements + +* An invalid or missing API key now causes an NSException to be thrown upon + calling [Bugsnag start]. This check used to occur during configuration, + and only for malformed API keys. + [828](https://github.com/bugsnag/bugsnag-cocoa/pull/828) + +* Exception Mach code and subcode are now written to the crash report as + stringified hex values instead of integers to avoid potential data loss from + JSON readers that lose the lower bits from unsigned 64-bit numbers. + [827](https://github.com/bugsnag/bugsnag-cocoa/pull/827) + +* Improved out-of-memory event detection by disabling reporting when a debugger + is attached. OOM reporting is now enabled by default in debug builds. + [820](https://github.com/bugsnag/bugsnag-cocoa/pull/820) + ## 6.1.7 (2020-10-01) ## Bug fixes diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist index b53798e37..a31377df8 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.1.7 + 6.2.1 CFBundleVersion 1 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION index 186d9d539..ca0639438 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION @@ -1 +1 @@ -6.1.7 +6.2.2 diff --git a/packages/react-native/update-ios.sh b/packages/react-native/update-ios.sh index 38e5b1ac9..74b620848 100755 --- a/packages/react-native/update-ios.sh +++ b/packages/react-native/update-ios.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -IOS_REPO_DIR=../../../cocoa +IOS_REPO_DIR=../../../bugsnag-cocoa IOS_DST=ios/vendor/bugsnag-cocoa echo "Clearing out ${IOS_DST}"