-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
HttpClient in AndroidApp crash again #6460
Comments
not repro on 17.3.0 preview 1.0 [32420.421.main]. @ssccinng, would you like to verify the attached project? |
I was just about to post a bug for this myself. I can't get any iteration of HttpClient working (managed or native). Native crashes the app immediately on launch, Managed acts incredibly strangely. It appears to crash from a NullReferenceException, but sometimes it crashes silently, causing all code that would otherwise use the result of SendAsync to be skipped. For example:
If I set a breakpoint on line 2, that breakpoint will get skipped and code will continue to execute on line 3, causing both result and content to be null. I spent a large part of the day uninstalling all VS versions, clearing out the dotnet folder of all SDKs, reinstalling everything, etc, so everything should be clean and at the latest version. I've attached here a small reproduction project. @VincentBu I tried your example and it appears to work through the debugger, even though the UI state doesn't update. |
Though, I can't find this VS 17.3.0 preview 1.0 that's mentioned in many comments on tickets here, so who knows if it's fixed there. |
VS 17.3 P1 isn't out yet, but it doesn't really matter in this case. It's going to be an SDK issue, not an IDE one. Trying this on my Mac with Android SDK 32.0.300-rc.2.18 Surprisingly, it worked. Same code. I'm not sure how MAUI is influencing this, but something weird is going on. @jonathanpeppers any ideas? |
@drasticactions, you are right. Additionally, RedChops's code works on windows but fails on Android. |
you use a version that includes the fix, so you can't repro it. |
I think this is the same as: Fixed by: Which will be in MAUI RC 2. Does the crash go away if you diable AOT for your Release build |
@jonathanpeppers The crash happens for me on both Debug and Release, no linking configured. I tried adding an explicit disable for AOT but that didn't seem to influence anything. EDIT1: Actually, I must have had a typo in RunAOTCompilation configuration - explicitly disabling it allowed the first half of the request to complete. In about 2 minutes I'll be able to test the second half. |
@jonathanpeppers Well, I had an initial bit of hope. In the app that I'm developing, explicitly disabling AOT did let one request go through, but not another one. In the project I had uploaded a couple comments up, disabling AOT doesn't do anything for the sample request that it makes. This is all using System.Net.Http.HttpClientHandler, Managed, as the HttpClient. I'm not sure if it's at all related, but if I set the HttpClient to use Xamarin.Android.Net.AndroidClientHandler, Android, instead the app crashes on launch instantly with a SIGSEGV SEGV_ACCERR. |
It seems that this works. The app size is the same as that after my special steps above |
|
@RedChops can you get https://docs.microsoft.com/en-us/xamarin/android/deploy-test/debugging/android-debug-log Enable additional logging before causing the crash, such as:
Cause the crash, then save to a file:
Sharing adb.txt, should help look into this further. Thanks! |
Hi @ssccinng. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@jonathanpeppers I have two logs here, both generated from my NetworkTest project uploaded above. The first is AndroidClientHandler.adb.txt which is the output from using the Android HttpClient. The second is HttpClientHandler.adb.txt. This of course includes the output from the AndroidClientHandler log since it's the same emulator boot. Both of these logs were generated off that sample project which I created fresh specifically for this bug, so there shouldn't be anything else weird going on there. They also both were run in Debug mode with |
@RedChops so if you're seeing this in a Debug build, then I filed a new issue to track this here: dotnet/android#6961 @ssccinng seems to be the problem we solved. So closing for now, thanks! MAUI RC 2 should hopefully work for you, and I'd use the workaround for now. |
To me it seems like it's not fixed in RC 2... Using RC 2, I'm getting the APK working, only when adding the above ( When I publish this app (
This is the Error-log that I extracted: 2022-05-10 14:22:02.753 25029-25870/? A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xa8 in tid 25870 (.NET ThreadPool), pid 25029 (yname.mauiapp53) |
@PieEatingNinjas can you try MAUI RC 3 that just shipped? dotnet/runtime 6.0.5 did not ship until today as well. |
I’ll give it a try tomorrow and will let you know the results. |
Sorry for the delay. |
Just to be clear, using SDK |
If you have |
OK, I have verified I am on the correct version, but I am still seeing this error in Uno Platform. Here is the discussion |
I mean your error is different? https://github.com/xamarin/xamarin-android/issues Thanks! |
Description
Crash occurs when httpclient is used to access the API,No crash in previous versions。
Steps to Reproduce
use
dotnet publish -f net6.0-android -c Release
build apk, Then run the app on your phone
If httpclient is used, it will crash and try catch will not catch errors
Version with bug
Release Candidate 1 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android11
Did you find any workaround?
I found a strange step to solve this problem.
1, pack apk.
2, remove
<uses-permission android:name="android.permission.INTERNET" />
in AndroidManifest.xml (Maybe any other setting)3, pack apk again
4. add
<uses-permission android:name="android.permission.INTERNET" />
in AndroidManifest.xml5. pack apk again
6. if the packaged apk becomes smaller, the bug may be fixed
Relevant log output
No response
The text was updated successfully, but these errors were encountered: