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

aot-compiled net6-ios app fails retrieving property #15961

Open
mmoraga opened this issue Sep 15, 2022 · 7 comments
Open

aot-compiled net6-ios app fails retrieving property #15961

mmoraga opened this issue Sep 15, 2022 · 7 comments
Labels
iOS Issues affecting iOS
Milestone

Comments

@mmoraga
Copy link

mmoraga commented Sep 15, 2022

Steps to Reproduce

  1. Build an ios app using the StreamJsonRPC library: https://github.com/microsoft/vs-streamjsonrpc
  2. Send a JsonRPCMessage
Error in rpc communication: Newtonsoft.Json.JsonSerializationException: Error writing JSON RPC Message: JsonSerializationException: Error getting value from 'RequestId' on 'StreamJsonRpc.JsonMessageFormatter+OutboundJsonRpcRequest'.
 ---> Newtonsoft.Json.JsonSerializationException: Error getting value from 'RequestId' on 'StreamJsonRpc.JsonMessageFormatter+OutboundJsonRpcRequest'.
 ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) StreamJsonRpc.RequestId <Module>:invoke_callvirt_RequestId_JsonRpcRequest (StreamJsonRpc.Protocol.JsonRpcRequest)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

   at System.Linq.Expressions.Interpreter.FuncCallInstruction`2[[StreamJsonRpc.Protocol.JsonRpcRequest, StreamJsonRpc, Version=2.12.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[StreamJsonRpc.RequestId, StreamJsonRpc, Version=2.12.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].<…>

Expected Behavior

Retrieving the value of a simple property should not fail

Actual Behavior

Retrieving RequestId property fails causing app to crash.

Environment

Version information
Visual Studio Community 2022 for Mac Preview
Version 17.4 Preview (17.4 build 715)
Installation UUID: c32fa707-d708-44f7-9f40-ecd4b7f8aeb7

Runtime
.NET 6.0.5 (64-bit)
Architecture: Arm64

Roslyn (Language Service)
4.4.0-1.22371.1+c07f2571612b471671c809b5b0db59b0c37aab57

NuGet
Version: 6.2.1.2

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/6.0.400/Sdks
SDK Versions:
	6.0.400
	6.0.400-preview.22330.6
	6.0.302
	6.0.301
	6.0.300
	6.0.201
MSBuild SDKs: /Applications/Visual Studio (Preview).app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET SDK (x64)
SDK Versions:
	6.0.400
	6.0.400-preview.22330.6
	6.0.302
	6.0.301
	6.0.300
	6.0.201
	6.0.105
	6.0.103
	5.0.408
	5.0.407
	5.0.406
	4.1.422
	3.1.421
	3.1.420
	3.1.419
	3.1.418
	3.1.417

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	6.0.8
	6.0.7
	6.0.6
	6.0.5
	6.0.3

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
	6.0.8
	6.0.7
	6.0.6
	6.0.5
	6.0.3
	5.0.17
	5.0.16
	5.0.15
	3.1.28
	3.1.27
	3.1.26
	3.1.25
	3.1.24
	3.1.23

Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 14.0 (21335)
Build 14A309

Xamarin.Mac
Version: 8.12.0.2 (Visual Studio Community)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:54-0400

Xamarin.iOS
Version: 15.12.0.2 (Visual Studio Community)
Hash: 87f98a75e
Branch: d17-3
Build date: 2022-07-25 20:18:55-0400

Xamarin Designer
Version: 17.4.0.32
Hash: 439b92ed7b
Branch: remotes/origin/d17-4
Build date: 2022-08-04 16:29:17 UTC

Xamarin.Android
Version: 13.0.99.36 (Visual Studio Community)
Commit: xamarin-android/main/b4998c8
Android SDK: /Users/manuel.moraga/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.0 (API level 31)
		11.0 (API level 30)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 33.0.2
SDK Build Tools Version: 33.0.0

Build Information: 
Mono: dffa5ab
Java.Interop: xamarin/java.interop/main@032f1e71
SQLite: xamarin/sqlite/3.39.2@40e8743
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9c641b3

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.14.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.4.0.24
Hash: b3b6672
Branch: remotes/origin/HEAD~1
Build date: 2022-08-04 16:29:21 UTC

Android Device Manager
Version: 0.0.0.1179
Hash: 0f220c0
Branch: main
Build date: 2022-08-04 16:29:21 UTC

Build Information
Release ID: 1704000715
Git revision: 09071dadfc1b81e4f0e2c9505cd8a5ef0b41d312
Build date: 2022-08-04 16:26:39+00
Build branch: release-17.4
Build lane: release-17.4

Operating System
Mac OS X 12.6.0
Darwin 21.6.0 Darwin Kernel Version 21.6.0
    Mon Aug 22 20:19:52 PDT 2022
    root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64


Build Logs

msbuild.binlog.zip

Example Project (If Possible)

https://github.com/mmoraga/jsonrpc-repro

@tj-devel709
Copy link
Contributor

Thank you for the feedback @mmoraga. I tried running your sample locally on my iPhone 12 pro max and it seemed to build using the args you mentioned dotnet build /p:BuildIpa=true /p:ArchiveOnBuild=true -c Debug /bl:msbuild.binlog and I could deploy to my device as well.

You could also try to enable the interpreter and see if that helps you.
<UseInterpreter>true</UseInterpreter>

Let us know if this helped out for you!

@tj-devel709 tj-devel709 added iOS Issues affecting iOS need-info Waiting for more information before the bug can be investigated labels Sep 15, 2022
@ghost
Copy link

ghost commented Sep 15, 2022

Hi @mmoraga. We have added the "need-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.

@tj-devel709 tj-devel709 added this to the Future milestone Sep 15, 2022
@AArnott
Copy link

AArnott commented Sep 15, 2022

@tj-devel709 I believe the problem only shows up in Release builds, where trimming and AOT compilation happens.

@ghost ghost added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Sep 15, 2022
@mmoraga
Copy link
Author

mmoraga commented Sep 16, 2022

@AArnott For some reason here I managed to reproduce it with the Debug switch as well.

@tj-devel709 it doesn't crash because I added a try/catch that catches all exceptions. If you check the Console app output you'll see the logs I added that show that the JsonRPC library will fail to access the mentioned member as soon as the json rpc communication is established.

@markuspalme
Copy link

I'm seeing something very similar:

dotnet/runtime#75802

@mmoraga
Copy link
Author

mmoraga commented Sep 19, 2022

Enabling the interpreter seems to solve the issue, although I don't know if publishing an app with the interpreter enabled is a valid solution for the app store. Probably the root cause is the same as for @markuspalme : Json serialization/deserialization failing. eg in my test project, setting up a strongly typed jsonrpc connection like
var greeterClient = JsonRpc.Attach<IGreeter>(jsonMessageHandler);
will also fail, when the project is build without <UseInterpreter>true</UseInterpreter>

@tj-devel709
Copy link
Contributor

Hello @mmoraga, using the interpreter shouldn't affect the performance speed of your project too much. Since it is working for you with the interpreter, continue to use it and if this is an issue when submitting your app, we can try to come up with another solution.

@tj-devel709 tj-devel709 removed the need-attention An issue requires our attention/response label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues affecting iOS
Projects
None yet
Development

No branches or pull requests

4 participants