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

[Health 10.0.0] Error handling is lackluster and crashes the app in many cases #931

Open
ciriousjoker opened this issue Mar 30, 2024 · 0 comments
Labels
bugfix a bug fix

Comments

@ciriousjoker
Copy link
Contributor

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

  • Device: Pixel 7 Pro API 34 Emulator
  • OS: Android 14

Describe the bug

Error handling practically doesn't exist. If the native part of this plugin throws an error, the app just crashes with no way of salvaging the situation in Dart code.

  • The code example is just one issue, another one is the api rate limit discussed in HEALTH 8.0.0 Quota Limit Exceeded #787. Hitting the api limit just crashes the app, which makes retrying later MUCH harder than it needs to be.

To Reproduce

Health().getHealthDataFromTypes(
    DateTime(2023, 1, 1),
    DateTime(2023, 1, 1),
    [HealthDataType.WORKOUT],
  )

Expected behavior

This should throw a Dart Exception because start date has to be earlier than the end date.

Actual behavior

App crashes.

E/AndroidRuntime(23563): FATAL EXCEPTION: main
E/AndroidRuntime(23563): Process: redacted, PID: 23563
E/AndroidRuntime(23563): java.lang.IllegalArgumentException: end time needs be after start time
E/AndroidRuntime(23563): at androidx.health.connect.client.time.TimeRangeFilter$Companion.between(TimeRangeFilter.kt:61)
E/AndroidRuntime(23563): at cachet.plugins.health.HealthPlugin$getHCData$1.invokeSuspend(HealthPlugin.kt:2623)
E/AndroidRuntime(23563): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(23563): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
E/AndroidRuntime(23563): at android.os.Handler.handleCallback(Handler.java:958)
E/AndroidRuntime(23563): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(23563): at android.os.Looper.loopOnce(Looper.java:205)
E/AndroidRuntime(23563): at android.os.Looper.loop(Looper.java:294)
E/AndroidRuntime(23563): at android.app.ActivityThread.main(ActivityThread.java:8177)
E/AndroidRuntime(23563): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23563): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(23563): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
E/AndroidRuntime(23563): Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@d690e6b, Dispatchers.Main]
I/Process (23563): Sending signal. PID: 23563 SIG: 9
Lost connection to device.

Exited.

Screenshots

N/A

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.1, on macOS 14.4.1 23E224 darwin-arm64, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.87.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

Additional information

Add any other info about the problem here.

@ciriousjoker ciriousjoker added the bugfix a bug fix label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix a bug fix
Projects
None yet
Development

No branches or pull requests

1 participant