Post

Replies

Boosts

Views

Activity

Bus error: 10 when using NSLog with DoraemonKit
Full crash log I am using DoraemonKit for debugging purposes. My NSLOG calls catching by DoraemonKit. I am getting crash reports from some of my users and I couldn't figure it out. Crash log: 0 libsystem_platform.dylib 0x00000001e1622e2c _platform_memset + 140 1 libsystem_malloc.dylib 0x00000001a75a34cc small_malloc_should_clear + 1352 (magazine_small.c:0) 2 libsystem_malloc.dylib 0x00000001a759fd38 szone_malloc_should_clear + 136 (magazine_malloc.c:238) 3 libsystem_malloc.dylib 0x00000001a75ae618 _malloc_zone_calloc + 88 (malloc.c:1546) 4 Foundation 0x000000019946abf8 -[_NSJSONReader parseData:options:] + 544 (NSJSONSerialization.m:2279) 5 Foundation 0x000000019946a900 +[NSJSONSerialization JSONObjectWithData:options:error:] + 76 (NSJSONSerialization.m:2459) 6 DoraemonKit 0x000000010ba7ffa4 -[NSDictionary(DoraemonUnicodeReadable) descriptionWithLocale:indent:] + 1024 7 Foundation 0x0000000199564640 _NS_os_log_callback + 288 (NSPlatform.m:187) 8 libsystem_trace.dylib 0x00000001ae4cf15c _os_log_fmt_flatten_NSCF + 64 (format.m:54) 9 libsystem_trace.dylib 0x00000001ae4ce908 _os_log_fmt_flatten_object + 216 (format.m:316) 10 libsystem_trace.dylib 0x00000001ae4db940 _os_log_impl_flatten_and_send + 1736 (format.c:799) 11 libsystem_trace.dylib 0x00000001ae4de524 _os_log_with_args_impl + 388 (log.c:2604) 12 CoreFoundation 0x00000001981f39ec _CFLogvEx3 + 188 (CFUtilities.c:1224) 13 Foundation 0x0000000199566b84 _NSLogv + 108 (NSPlatform.m:0) 14 Foundation 0x0000000199566be0 NSLog + 56 (NSPlatform.m:1321) 15 MyApp 0x0000000106a3b914 -[Manager handleReceivedData:] + 72 (Manager.m:119) 16 CoreFoundation 0x000000019816d9a0 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28 (CFNotificationCenter.c:706) My Code: - (void)handleReceivedData:(NSNotification *)notify { NSDictionary *receivedDic = [notify userInfo]; NSLog(@"receivedDicbt: %@",receivedDic); It is pretty basic, actually. I am catching an NSNotification and printing to NSLOG. Then DoraemonKit catches it, as you can see in the stack trace. I've inspected the DoraemonKit and found the Frame 6's file; it is here: https://github.com/didi/DoKit/blob/bf05430692e7b549f4b89d2abec877cd79dafaf4/iOS/DoraemonKit/Src/Core/Category/Foundation%2BDoraemon.m#L45 Exception Type: Exception Type: EXC_CRASH (SIGBUS) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Bus error: 10 Termination Reason: Namespace SIGNAL, Code 0xa What can cause to this problem and how to resolve it?
1
0
657
Dec ’22
Changing the live activity without push notification
I am trying to implement "Live activity" to my app. I am following the Apple docs. Link: https://developer.apple.com/documentation/activitykit/displaying-live-data-with-live-activities Example code: struct LockScreenLiveActivityView: View { let context: ActivityViewContext<PizzaDeliveryAttributes> var body: some View { VStack { Spacer() Text("\(context.state.driverName) is on their way with your pizza!") Spacer() HStack { Spacer() Label { Text("\(context.attributes.numberOfPizzas) Pizzas") } icon: { Image(systemName: "bag") .foregroundColor(.indigo) } .font(.title2) Spacer() Label { Text(timerInterval: context.state.deliveryTimer, countsDown: true) .multilineTextAlignment(.center) .frame(width: 50) .monospacedDigit() } icon: { Image(systemName: "timer") .foregroundColor(.indigo) } .font(.title2) Spacer() } Spacer() } .activitySystemActionForegroundColor(.indigo) .activityBackgroundTint(.cyan) } } Actually, the code is pretty straightforward. We can use the timerInterval for count-down animation. But when the timer ends, I want to update the Live Activity view. If the user re-opens the app, I can update it, but what happens if the user doesn't open the app? Is there a way to update the live activity without using push notifications?
8
9
4.4k
Sep ’22
Weird crash in background mode with Realm DB
I am using background mode for downloading data from the server and storing it in Realm. I am getting weird crash reports from my users. I attached an example crash log. 2022-06-11_09-48-00.9830_+0300-c163f7d73500cb2d0cff0a66c7684b6e7009adcd.crash My code:    private func addParseReportToDb(serverResponses: [AddNewParseReportResponse], trackedProfileRecordId: String) {     let trackedProfile = TrackedProfile.getByPrimaryKey(recordId: trackedProfileRecordId)!     for serverResponse in serverResponses {               let parseReport = ParseReport()       parseReport.biograph = serverResponse.biography               let realm = try! Realm()       try! realm.write({         realm.add(parseReport)       })               createUserFeedWithLatestReports(trackedProfile: trackedProfile)     }   } Above method is calling from below method:    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {           let realm = try! Realm()           let tst = Test()     tst.type = "silent"           try! realm.write({       realm.add(tst)     })           let parseService = InstaParseService()     parseService.downloadLatestReports {       parseService.getUsersForFetch { status in         completionHandler(.newData)       }     }   } parse.downloadLatestReports method calls the addParseReportToDb method. The crash point is realm.add(parseReport) As you can see actually I can add another object before adding the parseReport without any problem. Don't know why but that part crashes sometimes.
1
0
1.5k
Jun ’22