-
Couldn't load subscription status.
- Fork 5.2k
Description
Android framework version
net8.0-android, net9.0-android
Affected platform version
VS 17.11 Preview and 17.10 Stable, .NET 8.0.6 and .NET 9.0.0-preview.5.24306.8
Description
I am encountering an issue with WebSocket functionality in a .NET Android application when LLVM and full AOT is enabled. The application fails to establish WebSocket connections.
Configuration:
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
<EnableLLVM>True</EnableLLVM>
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
<RunAOTCompilation>True</RunAOTCompilation>
</PropertyGroup>When running the application with the above configuration, WebSocket connections throws exception. The same code works without issues when LLVM is disabled.
Expected Behavior:
The WebSocket connection should be established, messages should be sent and received without errors, and the connection should be properly closed.
Actual Behavior:
WebSocket connection throws exception when LLVM is enabled with the above configuration.
Stack Trace:
Message: net_webstatus_ConnectFailure
StackTrace: at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri , HttpMessageInvoker , CancellationToken , ClientWebSocketOptions )
at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri , HttpMessageInvoker , CancellationToken )
at WebsocketLLVMIssue.WebSocketClient.ConnectAsync(String uri)
at WebsocketLLVMIssue.MainActivity.ConnectAsync()
Additional Notes:
- Disabling LLVM resolves the issue, indicating a potential conflict between WebSocket operations and LLVM optimizations.
- A repro project is attached to this issue for further investigation.
Steps to Reproduce
- Create a new .NET Android project.
- Implement WebSocket client functionality.
- Add UI elements for connecting, sending messages, and disconnecting.
- Handle user interactions to manage WebSocket operations.
- Configure the project to use LLVM without AOT.
- Build and run the project on an Android device or emulator.
- Observe the behavior when trying to connect using WebSocket.
Or download this minimal project: WebsocketLLVMIssue.zip
Did you find any workaround?
nope