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

ORKHealthKitQuantityTypeAnswerFormat crashes #1450

Open
mab5vot9us9a opened this issue Mar 11, 2021 · 0 comments
Open

ORKHealthKitQuantityTypeAnswerFormat crashes #1450

mab5vot9us9a opened this issue Mar 11, 2021 · 0 comments

Comments

@mab5vot9us9a
Copy link

mab5vot9us9a commented Mar 11, 2021

Setting

  • Swift: Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
  • ResearchKit: main branch (0651bf0)
  • iOS: 14.4 (18D52) & Simulator 14.4 (18D46)
  • Device: iPhone 12 Pro & Simulator (iPhone 12 Pro)

When trying to use ORKHealthKitQuantityTypeAnswerFormat in a survey, the app crashes with

2021-03-11 14:12:47.787140+0100 app[10884:14047917] <ORKTaskViewController: 0x7fa7c280ba00> <ORKQuestionStepViewController: 0x7fa7c2847800>
2021-03-11 14:12:47.813883+0100 app[10884:14047917] -[ORKHealthKitQuantityTypeAnswerFormat hideUnitWhenAnswerIsEmpty]: unrecognized selector sent to instance 0x600000fcab20
2021-03-11 14:12:47.825667+0100 app[10884:14047917] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ORKHealthKitQuantityTypeAnswerFormat hideUnitWhenAnswerIsEmpty]: unrecognized selector sent to instance 0x600000fcab20'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff20421af6 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20177e78 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff204306f7 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
	3   CoreFoundation                      0x00007fff20426036 ___forwarding___ + 1489
	4   CoreFoundation                      0x00007fff20428068 _CF_forwarding_prep_0 + 120
	5   ResearchKit                         0x000000010428e05e -[ORKSurveyAnswerCellForNumber numberCell_initialize] + 446
	6   ResearchKit                         0x000000010428f8ae -[ORKSurveyAnswerCellForNumber prepareView] + 94
	7   ResearchKit                         0x00000001041896ac -[ORKSurveyAnswerCell setStep:] + 92
	8   ResearchKit                         0x00000001041895b4 -[ORKSurveyAnswerCell initWithStyle:reuseIdentifier:step:answer:delegate:] + 292
	9   ResearchKit                         0x0000000104372ab3 -[ORKQuestionStepViewController answerCellForTableView:] + 1283
	10  ResearchKit                         0x000000010436d4ff -[ORKQuestionStepViewController stepDidChange] + 4767
	11  ResearchKit                         0x000000010436eb57 -[ORKQuestionStepViewController viewDidLoad] + 71
	12  UIKitCore                           0x00007fff23f5e36e -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 88
	13  UIKitCore                           0x00007fff23f62cd7 -[UIViewController loadViewIfRequired] + 1084
	14  UIKitCore                           0x00007fff23e97f1a -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 162
	15  UIKitCore                           0x00007fff23e98204 -[UINavigationController _startTransition:fromViewController:toViewController:] + 154
	16  UIKitCore                           0x00007fff23e9927d -[UINavigationController _startDeferredTransitionIfNeeded:] + 851
	17  UIKitCore                           0x00007fff23e80259 -[UINavigationController _setViewControllers_7_0:transition:animated:operation:] + 3773
	18  UIKitCore                           0x00007fff23e7f097 -[UINavigationController _setViewControllers:transition:animated:operation:] + 566
	19  UIKitCore                           0x00007fff23e7e29d __54-[UINavigationController setViewControllers:animated:]_block_invoke + 1452
	20  UIKitCore                           0x00007fff23f71274 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 153
	21  UIKitCore                           0x00007fff23e7dc35 -[UINavigationController setViewControllers:animated:] + 600
	22  ResearchKit                         0x00000001041259fe -[ORKTaskViewController showStepViewController:goForward:animated:] + 3038
	23  ResearchKit                         0x0000000104123411 -[ORKTaskViewController viewWillAppear:] + 433
	24  UIKitCore                           0x00007fff23f68c66 -[UIViewController _setViewAppearState:isAnimating:] + 654
	25  UIKitCore                           0x00007fff23f6948f -[UIViewController __viewWillAppear:] + 106
	26  UIKitCore                           0x00007fff23e3e1c3 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.466 + 1201
	27  UIKitCore                           0x00007fff24b9107a -[_UIAfterCACommitBlock run] + 54
	28  UIKitCore                           0x00007fff246a5954 _runAfterCACommitDeferredBlocks + 333
	29  UIKitCore                           0x00007fff246959fc _cleanUpAfterCAFlushAndRunDeferredBlocks + 221
	30  UIKitCore                           0x00007fff246c72ac _afterCACommitHandler + 85
	31  CoreFoundation                      0x00007fff2038f1f8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	32  CoreFoundation                      0x00007fff20389a77 __CFRunLoopDoObservers + 547
	33  CoreFoundation                      0x00007fff2038a01a __CFRunLoopRun + 1113
	34  CoreFoundation                      0x00007fff203896d6 CFRunLoopRunSpecific + 567
	35  GraphicsServices                    0x00007fff2c257db3 GSEventRunModal + 139
	36  UIKitCore                           0x00007fff24696cf7 -[UIApplication _run] + 912
	37  UIKitCore                           0x00007fff2469bba8 UIApplicationMain + 101
	38  app                                 0x000000010184e98b main + 75
	39  libdyld.dylib                       0x00007fff2025a3e9 start + 1
	40  ???                                 0x0000000000000007 0x0 + 7
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ORKHealthKitQuantityTypeAnswerFormat hideUnitWhenAnswerIsEmpty]: unrecognized selector sent to instance 0x600000fcab20'
terminating with uncaught exception of type NSException
CoreSimulator 732.18.6 - Device: iPhone 12 Pro (A9B7C477-7F9A-4507-AD26-8388ABB76A90) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone 12 Pro

An example step to reproduce this crash would be:

let heartRate = ORKQuestionStep(identifier: "heart-rate")
heartRate.title = "Heart Rate"
heartRate.text = "What is your current heart rate?"
let heartRateType = HKQuantityType.quantityType(forIdentifier: .heartRate)!
let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute())
heartRate.answerFormat = ORKHealthKitQuantityTypeAnswerFormat(quantityType: heartRateType,
                                                              unit: heartRateUnit,
                                                              style: .integer)
heartRate.isOptional = false

This DOES NOT happen when the Question is part of an ORKFormStep. So the following does NOT crash the app.

let heartRateType = HKQuantityType.quantityType(forIdentifier: .heartRate)!
let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute())
let heartRateAnswer = ORKHealthKitQuantityTypeAnswerFormat(quantityType: heartRateType,
                                                           unit: heartRateUnit,
                                                           style: .integer)
let heartRateItem = ORKFormItem(identifier: "heart-rate",
                            text: "Heart Rate",
                            answerFormat: heartRateAnswer)

heartRateItem.isOptional = false

let hrSeparator = ORKFormItem(sectionTitle: "What is your current heart rate?")

let heartRateGroup = ORKFormStep(identifier: "heart-rate-group")
heartRateGroup.title = "Heart Rate"
heartRateGroup.formItems = [hrSeparator, heartRateItem]
heartRateGroup.isOptional = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant