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

Fix multiple exception handler invocation in Android #3056

Merged
merged 1 commit into from Dec 6, 2021

Commits on Dec 1, 2021

  1. Fix multiple exception handler invocation in Android

    The AndroidExceptionPreHandler was changed in commit
    5ea9339 to not invoke the uncaught
    exception pre-handler on Android Pie and above, and to instead invoke
    the thread's uncaught exception handler directly on those versions, as
    Android Pie had added logic in the default uncaught exception handler to
    ensure that the pre-handler would be invoked.
    
    However, the uncaught exception handler is already being invoked for all
    unhandled coroutine exceptions, so this change in the
    AndroidExceptionPreHandler caused the uncaught exception handler to be
    invoked twice in Android Pie and above.
    
    Since the default uncaught exception handler implementation in Android
    kills the app immediately, this normally wouldn't make a difference.
    However, if an app sets a custom uncaught exception handler (either at
    the thread or global level) that doesn't always kill the app, then the
    duplicate invocations might cause undesired or wrong behaviour.
    
    This is now fixed by removing the uncaught exception handler invocation
    from AndroidExceptionPreHandler.
    
    Since the pre-handler was introduced in Android Oreo, I have also added
    a minimum SDK check for Android Oreo as well. Also edited the
    documentation in the comments to add more details and context.
    1zaman committed Dec 1, 2021
    Configuration menu
    Copy the full SHA
    694d39f View commit details
    Browse the repository at this point in the history