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

Retrieving even a single iOS ECG measurement w/ voltage data causes app to crash #64

Open
maxbeech opened this issue Oct 8, 2023 · 1 comment

Comments

@maxbeech
Copy link

maxbeech commented Oct 8, 2023

Hi there, thanks so much for the fantastic package!!

I am trying to retrieve iOS ECG data including voltage information within my Flutter app.
Sadly the app crashes when I try to retrieve just a single ECG reading. I have tracked them back and they crash within the Swift file at the line let voltageQuery = HKElectrocardiogramQuery(ecgSample) { (query, [result][1]) in ie. when it's actually retrieving the data (relevant Apple documentation here).

Whenever I do it, I get the memory error:

* thread #3, queue = 'com.apple.HealthKit.HKHealthStore.client.0x281d32630', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
Target 0: (Runner) stopped.

I get the same error on both an iPhone 7 and iPhone 11 (both running min. iOS 14) using various different readings.

Does anyone know how to avoid this happening please?

I'm not sure if say there's a way to retrieve a part of a reading for example, as I think the app is just struggling to handle the size of variable.

Thanks a lot!

@Famous-guy
Copy link

It sounds like you're encountering a memory access error when attempting to retrieve ECG data within your Flutter app using the health_kit plugin. Memory access errors like EXC_BAD_ACCESS typically occur when your app tries to access memory that it doesn't have permission to access or when attempting to access memory that has already been deallocated.

Here are a few steps you can take to troubleshoot and potentially resolve this issue:

Check Permissions: Ensure that your app has the necessary permissions to access health data, including ECG data, on the iOS device. You may need to request permission explicitly in your app's Info.plist file and handle permission requests properly in your Flutter code.

Verify Data Retrieval: Double-check that your code for retrieving ECG data is correct and properly configured. Make sure you're using the correct APIs and following Apple's guidelines for querying health data, as outlined in the relevant documentation.

Error Handling: Implement proper error handling in your code to catch and handle any exceptions or errors that may occur during data retrieval. This can help prevent crashes and provide more informative error messages for debugging purposes.

Memory Management: Review your code for any potential memory management issues, such as retaining references to objects unnecessarily or failing to release resources properly. Make sure you're following best practices for memory management in both your Flutter and Swift code.

Testing: Test your app on different iOS devices and iOS versions to see if the issue persists across different environments. This can help identify whether the problem is specific to certain devices or configurations.

Community Support: Consider reaching out to the Flutter community, such as forums, discussion groups, or GitHub repositories related to the health_kit plugin. Others may have encountered similar issues and can provide insights or assistance in troubleshooting the problem.

By carefully reviewing your code, verifying permissions and data retrieval mechanisms, implementing error handling, and testing across different environments, you should be able to identify and address the underlying cause of the memory access error in your Flutter app.

Hi there, thanks so much for the fantastic package!!

I am trying to retrieve iOS ECG data including voltage information within my Flutter app. Sadly the app crashes when I try to retrieve just a single ECG reading. I have tracked them back and they crash within the Swift file at the line let voltageQuery = HKElectrocardiogramQuery(ecgSample) { (query, [result][1]) in ie. when it's actually retrieving the data (relevant Apple documentation here).

Whenever I do it, I get the memory error:

* thread #3, queue = 'com.apple.HealthKit.HKHealthStore.client.0x281d32630', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
Target 0: (Runner) stopped.

I get the same error on both an iPhone 7 and iPhone 11 (both running min. iOS 14) using various different readings.

Does anyone know how to avoid this happening please?

I'm not sure if say there's a way to retrieve a part of a reading for example, as I think the app is just struggling to handle the size of variable.

Thanks a lot!

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

2 participants