|Summary:||GC causes app to crash after ModernHttpClient throws an exception|
|Component:||General||Assignee:||Jonathan Pryor <jonp>|
|Severity:||normal||CC:||anton.s.morozov, cody.beyer, dla, mono-bugs+monodroid, onevitalboy|
|Tags:||Is this bug a regression?:||---|
|Last known good build:|
|Attachments:||Simple test project for reproducing the issue|
Description Daniel 2016-12-16 13:16:40 UTC
Created attachment 18909 [details] Simple test project for reproducing the issue We have an app that is using ModernHttpClient to make HTTP requests. We've noticed that if ModernHttpClient throws an exception (that we catch) the app will crash the next time that a garbage collect is performed. When the app crashes it logs a "JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x7f58cec5e0" error and a huge stack trace. This only seems to happen on Cycle 8 releases (not on Cycle 7 or the most recent Cycle 9 release, Xamarin.Android 22.214.171.124). Also, it only happens when ModernHttpClient is used. If I switch to HttpClientHandler or AndroidClientHandler the app doesn't crash. I've broken out the code from our project to a simple test project. Steps to reproduce: 1. Put the device in airplane mode 2. Launch the app 3. Press the "Send get request" button a. An exception will be thrown since the device doesn't have a connection. 4. Press the "Send get request" button a second time 5. Press the "Manual GC call" button In the test project that I've attached I need to send two requests for the issue to occur, in our real project the issue occurs after one request. I don't know if this is a bug in Xamarin or in ModernHttpClient, but even if it is a bug in ModernHttpClient I would like to know why it only occurs in Cycle 8 releases. If I try the same thing in Cycle 7 (Xamarin.Android 126.96.36.199) or Cycle 9 (Xamarin.Android 188.8.131.52) releases the app doesn't crash.
Comment 1 Daniel 2016-12-16 13:29:14 UTC
Just noticed that this may be a duplicate of: https://bugzilla.xamarin.com/show_bug.cgi?id=45003
Comment 2 David Laundav 2017-02-06 11:59:39 UTC
Any news in regards to this issue?
Comment 3 Anton Morozov 2017-02-15 10:26:04 UTC
The bug is caused by ModernHttp setting a Java exception into a Task. See this comment in in ModernHttp repo: https://github.com/paulcbetts/ModernHttpClient/issues/229?_pjax=%23js-repo-pjax-container#issuecomment-253214125 It can be easily fixed in ModernHttp code.
Comment 4 Cody Beyer (MSFT) 2017-06-13 21:51:13 UTC
This has been fixed in a fork of ModernHTTPClient, however that fork has not turned into a PR as far as I can tell. Please see https://github.com/Youscribe/ModernHttpClient/tree/hotfix/cycle8-issue