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

[SleepAnalysis improvement] background observer ; method to insert sleep sample #218

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

ghashi
Copy link

@ghashi ghashi commented Apr 5, 2022

Description

This PR adds 2 features:

  1. Add possibility to observe SleepAnalysis
  2. Add method to insert SleepAnalysis into HealthKit

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have checked my code and corrected any misspellings

…orySampleWithType:value:startDate:endDate:] receives invalid data

the app can crash with the following error message:

"_HKObjectValidationFailureException: startDate (2022-09-09 15:18:00 +0000) cannot occur after endDate (2022-09-09 12:55:00 +0000)"

Incident Identifier: 1AD60E81-2DA4-4F60-B253-468458246B34
Hardware Model:      iPhone10,4
Process:             App [13285]
Path:                /private/var/containers/Bundle/Application/9147D7CD-0417-4791-A315-096A22A8C85E/App.app/App
AppStoreTools:       14A305
AppVariant:          1:iPhone10,4:15
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]

Date/Time:           2022-09-11 14:40:09.0556 -0300
Launch Time:         2022-09-11 14:40:04.6203 -0300
OS Version:          iPhone OS 15.6.1 (19G82)
Release Type:        User
Baseband Version:    5.03.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  2

Last Exception Backtrace:
0   CoreFoundation                	0x1811cfd1c __exceptionPreprocess + 216 (NSException.m:200)
1   libobjc.A.dylib               	0x1989efee4 objc_exception_throw + 56 (objc-exception.mm:565)
2   CoreFoundation                	0x181222f08 +[NSException raise:format:] + 108 (NSException.m:156)
3   HealthKit                     	0x18d4ae8f4 -[HKObject _validateForCreation] + 140 (HKObject.m:127)
4   HealthKit                     	0x18d4ae684 +[HKObject _newDataObjectWithMetadata:device:config:] + 268 (HKObject.m:112)
5   HealthKit                     	0x18d4ae534 +[HKSample _newSampleWithType:startDate:endDate:device:metadata:config:] + 176 (HKSample.m:42)
6   HealthKit                     	0x18d4afdd0 +[HKCategorySample categorySampleWithType:value:startDate:endDate:device:metadata:] + 268 (HKCategorySample.m:42)
7   App                           	0x102d5e018 -[RCTAppleHealthKit(Methods_Sleep) sleep_saveSleepSamples:callback:] + 396 (RCTAppleHealthKit+Methods_Sleep.m:56)
8   App                           	0x102d6f9c0 -[RCTAppleHealthKit saveSleepSample:callback:] + 80 (RCTAppleHealthKit.m:461)
9   CoreFoundation                	0x18115ddd0 __invoking___ + 144 (:-1)
10  CoreFoundation                	0x181179ea8 -[NSInvocation invoke] + 300 (NSForwarding.m:3378)
11  CoreFoundation                	0x1811ae2cc -[NSInvocation invokeWithTarget:] + 76 (NSForwarding.m:3475)
12  App                           	0x102e01978 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 388 (RCTModuleMethod.mm:584)
13  App                           	0x102e039ac facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 452 (RCTNativeModule.mm:181)
14  App                           	0x102e0363c facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const + 56 (RCTNativeModule.mm:103)
15  App                           	0x102e0363c invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 100 (RCTNativeModule.mm:95)
16  libdispatch.dylib             	0x180e8f094 _dispatch_call_block_and_release + 24 (init.c:1517)
17  libdispatch.dylib             	0x180e90094 _dispatch_client_callout + 16 (object.m:560)
18  libdispatch.dylib             	0x180e6b4a4 _dispatch_lane_serial_drain$VARIANT$armv81 + 600 (inline_internal.h:2622)
19  libdispatch.dylib             	0x180e6bf44 _dispatch_lane_invoke$VARIANT$armv81 + 388 (queue.c:3944)
20  libdispatch.dylib             	0x180e758e0 _dispatch_workloop_worker_thread + 608 (queue.c:6732)
21  libsystem_pthread.dylib       	0x1dc51ce10 _pthread_wqthread + 284 (pthread.c:2599)
22  libsystem_pthread.dylib       	0x1dc51c93c start_wqthread + 8 (:-1)
@RuanAzevedo RuanAzevedo requested review from a team and removed request for a team January 5, 2023 01:47
@julian-kingman-lark
Copy link

@RuanAzevedo this looks like a useful feature, will it be reviewed and merged?

@RuanAzevedo RuanAzevedo changed the base branch from master to development January 25, 2023 15:30
@jeffrean
Copy link

+1 this would be a super helpful feature

@dv-gt
Copy link

dv-gt commented Dec 10, 2023

+1 for this nice feature.

@GGGava any update for this PR??

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

Successfully merging this pull request may close these issues.

None yet

4 participants