Giter Site home page Giter Site logo

Android SDK should not terminate on UnobservedTaskException unless ThrowUnobservedTaskExceptions config is set about hockeysdk-xamarin HOT 8 CLOSED

bitstadium avatar bitstadium commented on July 20, 2024
Android SDK should not terminate on UnobservedTaskException unless ThrowUnobservedTaskExceptions config is set

from hockeysdk-xamarin.

Comments (8)

MisterJimson avatar MisterJimson commented on July 20, 2024

Anyone know if this is still happening?

from hockeysdk-xamarin.

Qonstrukt avatar Qonstrukt commented on July 20, 2024

This is for me. On both Android and iOS. Due the way ReactiveUI works this can happen quite often for certain situations.

from hockeysdk-xamarin.

matthiaswenz avatar matthiaswenz commented on July 20, 2024

Hi @rdavisau and others - sorry for the delay. We are looking at ways to improve this behavior in the future - to make sure we do the right thing, we need your input.
One thing that will be hard for the SDK to figure out will be whether an exception would lead to a crash - it can't really figure that out for itself.
We appreciate your time and hope you can provide more samples as to when this issue occurs and how you currently work around it.
Of course, we also encourage participation through PRs on this 😊

Thanks, Mat

from hockeysdk-xamarin.

Qonstrukt avatar Qonstrukt commented on July 20, 2024

I'm actually finding out our apps are crashing for a lot of customers while it shouldn't. This happens all the time in the following scenario:

We're using Refit and Akavache for REST calls and caching. Refit wraps HttpClient SendAsync calls into IObservable sequences so we can use them more easily with Akavache or Rx in general.
The SendAsync calls work with Task's which contains the Exception if there is any, and in the Rx context this is converted to OnError handling in the subscription.

In our situation it seems as if Exceptions occurring this way, and handled through an Observable are seen by Hockey as uncaught exceptions and it brings the whole app down.

I'll try to write a simple example app which demonstrates this problem later this week if possible. Currently I need to pull Hockey from all our apps because it's more hurting than helping, and I have no clue how to work around it consistently.

from hockeysdk-xamarin.

rdavisau avatar rdavisau commented on July 20, 2024

Hi Matthias and everyone - here's what i've found from investigating. This is a simple reproduction on the issue on iOS. As it is, the app crashes after the unawaited Task.Run call. However, if you comment out the SetupHockeyApp line the app does not crash.

The crash is caused by these lines in the HockeyApp SDKs. Not observing an exception that occurs in a task does not actually result in termination of a .NET4.5+ app, so I don't think it's correct behaviour for HockeyApp to do that by default. The main issue with this is that if any library you depend on happens to internally allow an exception within a Task to go unhandled - e.g. for a 'fire and forget' scenario - it is impossible to catch, and including HockeyApp will result in crashes where there otherwise would be none.

I think a reasonable solution is to make this behaviour configurable, and disabled by default. This means that HockeyApp matches the .NET platform, but allows users to get this behaviour if they want. I've taken a shot at it and will open a PR. I tested it on iOS and toggling the parameter gave me control over whether or not the app was affected by the unobserved task exceptions as expected. I'm not precious about the approach so you can take the PR or just use it as inspiration.

@Qonstrukt, it might be worth you pulling the branch and testing your app against a build from it given you have a good 'real world' scenario to test against!

from hockeysdk-xamarin.

matthiaswenz avatar matthiaswenz commented on July 20, 2024

Thanks @Qonstrukt for your input and thanks @rdavisau for providing the insight and PR - I will have a look at this later today.

from hockeysdk-xamarin.

Qonstrukt avatar Qonstrukt commented on July 20, 2024

Thanks @rdavisau, your version fixes this for us. 👍

from hockeysdk-xamarin.

ElektrojungeAtWork avatar ElektrojungeAtWork commented on July 20, 2024

We just released 4.1.1 which comes with a fix for this! Thx @rdavisau and @Qonstrukt! =)

from hockeysdk-xamarin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.