Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watchdog crash during realm write transaction #7146

Closed
dheeraj-singh511 opened this issue Feb 26, 2021 · 5 comments
Closed

Watchdog crash during realm write transaction #7146

dheeraj-singh511 opened this issue Feb 26, 2021 · 5 comments
Labels
More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. O-Community Reproduction-Required

Comments

@dheeraj-singh511
Copy link

dheeraj-singh511 commented Feb 26, 2021

Goals

OS watchdog is killing app as realm write transaction is taking time during app launch.

Expected Results

Realm write transaction during app launch should not crash app.

Actual Results

The stack trace shows , app is performing a realm write transaction during app launch. It seems the transaction is blocking main thread causing the app to crash.

{"app_cohort":"2|date=1614024000000&sf=143441&tid=38aa64d5d1f674bb0d049eb028f44033741bfc87ef1f5246bf0596462b6879c5&ttype=i","app_name":"myApp","app_version":"4.0.992","timestamp":"2021-02-25 11:45:02.00 -0800","slice_uuid":"27d2728f-ba41-30c0-afbe-fbcb0347c6fb","adam_id":1097606585,"build_version":"4.0.992","platform":2,"bundleID":"com.myOrg.phone2","share_with_app_devs":1,"is_first_party":0,"bug_type":"109","os_version":"iPhone OS 14.4 (18D52)","incident_id":"CD40286A-7B1E-4173-9B80-00807C3544DF","name":"myApp","is_beta":1}
Incident Identifier: CD40286A-7B1E-4173-9B80-00807C3544DF
Beta Identifier: 390D9356-0692-4704-988F-242EFD58C7A6
Hardware Model: iPhone10,4
Process: myApp [3525]
Path: /private/var/containers/Bundle/Application/5BF0C934-A486-4A63-8E62-5B193866FD9D/myApp.app/myApp
Identifier: com.myOrg.phone2
Version: 4.0.992 (4.0.992)
AppStoreTools: 12D4d
AppVariant: 1:iPhone10,4:14
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.myOrg.phone2 [398]

Date/Time: 2021-02-25 11:45:02.2995 -0800
Launch Time: 2021-02-25 11:44:40.9363 -0800
OS Version: iPhone OS 14.4 (18D52)
Release Type: User
Baseband Version: 4.02.01
Report Version: 104

Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Termination Description: SPRINGBOARD, <RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: application<com.myOrg.phone2>:3525 exhausted real (wall clock) time allowance of 10.00 seconds | ProcessVisibility: Background | ProcessState: Running | WatchdogEvent: scene-update | WatchdogVisibility: Background | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 7.030 (user 7.030, system 0.000), 12% CPU", | "Elapsed application CPU time (seconds): 0.009, 0% CPU" | ) reportType:CrashLog maxTerminationResistance:Interactive>
Triggered by Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001b9319c5c 0x1b92f1000 + 167004
1 Realm 0x0000000102ed5ca8 realm::util::File::lock+ 3054760 (bool, bool) + 104
2 Realm 0x0000000102d5c39c realm::DB::do_begin_write+ 1508252 () + 88
3 Realm 0x000000010302d958 realm::impl::transaction::begin+ 4462936 (std::__1::shared_ptrrealm::Transaction const&, realm::BindingContext*, realm::impl::NotifierPackage&) + 356
4 Realm 0x0000000103023bb8 realm::impl::RealmCoordinator::promote_to_write+ 4422584 (realm::Realm&) + 268
5 Realm 0x0000000103080538 realm::Realm::begin_transaction+ 4801848 () + 404
6 Realm 0x0000000102c95914 -[RLMRealm beginWriteTransactionWithError:] + 694548 (RLMRealm.mm:0)
7 RealmSwift 0x00000001035f1484 Realm.write(withoutNotifying:
:) + 251012 (:0)
8 myApp 0x00000001013115d4 specialized closure #1 in UnifiedDatabase.save(item:) + 17323476 (:0)
9 myApp 0x000000010059c108 thunk for @callee_guaranteed () > (@error @owned Error) + 3211528 (<compilergenerated>:0)
10 myApp 0x0000000100750bd8 partial apply for thunk for @callee_guaranteed () > (@error @owned Error) + 5000152 (<compilergenerated>:0)
11 myApp 0x0000000100750dfc thunk for @callee_guaranteed () -> + 5000700 (@error @owned Error)partial apply + 12
12 libswiftObjectiveC.dylib 0x00000001b1d7af40 0x1b1d79000 + 8000
13 myApp 0x000000010074cb98 AppLogTracesDao.setDevicePushToken(devicePushToken:) + 4983704 (:0)
14 myApp 0x0000000101428538 specialized PushNotificationManager.pushRegistry(
:didUpdate:for:) + 18466104 (PushNotificationManager.swift:104)
15 myApp 0x0000000101426370 @objc PushNotificationManager.pushRegistry(
:didUpdate:for:) + 18457456 (:0)

Steps for others to Reproduce

This is a random issue that happens during app lauch.

Version of Realm and Tooling

Realm framework version: 10.5.0

Realm Object Server version: N/A

Xcode version: Version 12.0.1

iOS/OSX version: iPhone OS 14.4

Dependency manager + version: Cocoapods

@DominicFrei
Copy link
Contributor

@dheeraj-singh511 Thank you for submitting this issue.

Can you show us a bit more about your start up? Especially what you do with your Realm?
Is there data synchronised in the beginning? Is this happening due to a migration? Is there something else that causes a write transaction?

Maybe you can even provide a code sample / repository that reproduces this (even if it's just random)?

@dheeraj-singh511
Copy link
Author

dheeraj-singh511 commented Mar 2, 2021

@DominicFrei - Here are some details I noticed during this crash based on our app logs and crash log. Hope it helps

  • By the time we hit this write transaction, realm was already configured and we were able to read data from it more than once
  • There was also a successful delete transaction
  • This is not a upgrade scenario so the migration script did not execute
  • I noticed that there was write attempt at the same time from thread 4. Thread 4 stack trace below
  • We are not executing any data synchronization script during launch. However we are using realm compaction feature while configuring realm

Thread 4 name: Dispatch queue: com.example.myappSDKRegistrationAdapter
Thread 4:
0 libsystem_kernel.dylib 0x00000001b931866c 0x1b92f1000 + 161388
1 libsystem_pthread.dylib 0x00000001d5bf9d74 0x1d5bf3000 + 28020
2 libsystem_pthread.dylib 0x00000001d5bf9cc8 0x1d5bf3000 + 27848
3 Realm 0x0000000102d5c388 realm::DB::do_begin_write+ 1508232 () + 68
4 Realm 0x000000010302d958 realm::impl::transaction::begin+ 4462936 (std::__1::shared_ptrrealm::Transaction const&, realm::BindingContext*, realm::impl::NotifierPackage&) + 356
5 Realm 0x0000000103023bb8 realm::impl::RealmCoordinator::promote_to_write+ 4422584 (realm::Realm&) + 268
6 Realm 0x0000000103080538 realm::Realm::begin_transaction+ 4801848 () + 404
7 Realm 0x0000000102c95914 -[RLMRealm beginWriteTransactionWithError:] + 694548 (RLMRealm.mm:0)
8 RealmSwift 0x00000001035f1484 Realm.write(withoutNotifying:
:) + 251012 (:0)
9 myapp 0x000000010058984c specialized closure #1 in UnifiedDatabase.deleteAll() + 3135564 (:0)
10 myapp 0x000000010059c108 thunk for @callee_guaranteed () -> (@error @owned Error) + 3211528 (:0)
11 myapp 0x00000001005e0a40 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) + 3492416 (:0)
12 myapp 0x00000001005e0a78 thunk for @callee_guaranteed () -> + 3492472 (@error @owned Error)partial apply + 12
13 libswiftObjectiveC.dylib 0x00000001b1d7af40 0x1b1d79000 + 8000
14 myapp 0x00000001005e03c8 SDKAccountInfoDAO.deleteExistingAccountInfo() + 3490760 (:0)
15 myapp 0x00000001005e02e0 SDKAccountInfoDAO.updateSdkAccountInfo(sdkAccountInfo:) + 3490528 (SDKAccountInfoDAO.swift:124)
16 myapp 0x0000000100c06a2c MSCRegistrationManager.configureAccountConfirmed(
:) + 9939500 (:0)
17 myapp 0x0000000100c0e7ac @objc MSCRegistrationManager.configureAccountConfirmed+ 9971628 (
:) + 56
18 myappSdkFramework 0x00000001050e66a8 -[myappSDKModuleAdapter processResponseMessage:withSelector:] + 1337000 (myappSDKModuleAdapter.m:122)
19 libdispatch.dylib 0x000000018d011298 0x18cfb1000 + 393880
20 libdispatch.dylib 0x000000018d012280 0x18cfb1000 + 397952s
21 libdispatch.dylib 0x000000018cfee4f0 0x18cfb1000 + 251120
22 libdispatch.dylib 0x000000018cfeefdc 0x18cfb1000 + 253916
23 libdispatch.dylib 0x000000018cff8800 0x18cfb1000 + 292864
24 libsystem_pthread.dylib 0x00000001d5bfd5a4 0x1d5bf3000 + 42404
25 libsystem_pthread.dylib 0x00000001d5c00874 0x1d5bf3000 + 55412

@DominicFrei
Copy link
Contributor

@DominicFrei - Here are some details I noticed during this crash based on our app logs and crash log. Hope it helps

  • By the time we hit this write transaction, realm was already configured and we were able to read data from it more than once
  • There was also a successful delete transaction
  • This is not a upgrade scenario so the migration script did not execute
  • I noticed that there was write attempt at the same time from thread 4. Thread 4 stack trace below
  • We are not executing any data synchronization script during launch. However we are using realm compaction feature while configuring realm

Thanks for sharing this information. @dheeraj-singh511
I understood more about what would not be the reason.

Since you already narrowed done which parts of the code might be responsible for the problem, can you show us this part of the code as an example so that I can better understand what is going on?

@leemaguire
Copy link
Contributor

@dheeraj-singh511 are you using Realm.asyncOpen? If not this can help you here.

@DominicFrei DominicFrei added More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. Reproduction-Required labels Mar 24, 2021
@no-response
Copy link

no-response bot commented Apr 7, 2021

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Apr 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. O-Community Reproduction-Required
Projects
None yet
Development

No branches or pull requests

3 participants