Skip to content

fix(android): catch foreground service crashes on Android 12-14 - #77

Open
eoinoreilly30 wants to merge 1 commit into
daily-co:react-native-daily-js-releasesfrom
eoinoreilly30:patch-1
Open

fix(android): catch foreground service crashes on Android 12-14#77
eoinoreilly30 wants to merge 1 commit into
daily-co:react-native-daily-js-releasesfrom
eoinoreilly30:patch-1

Conversation

@eoinoreilly30

Copy link
Copy Markdown

fix(android): catch foreground service crashes on Android 12-14

Daily's DailyOngoingMeetingForegroundService has two unguarded calls
that throw fatal RuntimeExceptions on certain Android versions:

  • startForegroundService() throws ForegroundServiceStartNotAllowedException
    on Android 12+ when the app is in the background at the time of the call
  • startForeground() throws SecurityException on Android 14+ when the
    microphone foreground service type requirements are not met (eligible
    state/exemption check)

Both are native crashes (UncaughtExceptionHandler, handled=false) that
kill the app entirely and cannot be caught from JavaScript.

Example fatal error from production:

ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.hanashiapp.hanashi/com.daily.reactlibrary.DailyOngoingMeetingForegroundService

Wrap both calls in try-catch blocks so the service fails gracefully. The
only degradation is the loss of the in-call notification and background
keep-alive — the call itself continues to work while the app is in the
foreground.

Added error handling for starting foreground service.
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.

1 participant