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

[Wasm][AOT] AOT Compilation failed for method 'void System.IO.Strategies.Net5CompatFileStreamStrategy:Dispose (bool)'. #50609

Open
jeromelaban opened this issue Apr 1, 2021 · 17 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-Codegen-AOT-mono
Milestone

Comments

@jeromelaban
Copy link
Contributor

jeromelaban commented Apr 1, 2021

Description

When running an application with WebAssembly Full AOT, the following exception happens at runtime:

System.ExecutionEngineException: AOT Compilation failed for method 'void System.IO.Strategies.Net5CompatFileStreamStrategy:Dispose (bool)'.

Not sure to produce a repro for this one, as there's no stack trace because of AOT. Will try to get one from the newer js-based exception tracing.

edit: Unfortunately, adding :

mono_trace_enable(1);
mono_trace_set_options("E:all");

does not raise this type of exceptions in a way that can be shown in browser logs.

Configuration

2784aad

Regression?

Not sure.

Other information

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Apr 1, 2021
@jeromelaban
Copy link
Contributor Author

And it's caused by a filter....

catch (Exception e) when (!disposing && FileStreamHelpers.IsIoRelatedException(e))

@danmoseley danmoseley added arch-wasm WebAssembly architecture area-System.IO labels Apr 1, 2021
@ghost
Copy link

ghost commented Apr 1, 2021

Tagging subscribers to this area: @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When running an application with WebAssembly Full AOT, the following exception happens at runtime:

System.ExecutionEngineException: AOT Compilation failed for method 'void System.IO.Strategies.Net5CompatFileStreamStrategy:Dispose (bool)'.

Not sure to produce a repro for this one, as there's no stack trace because of AOT. Will try to get one from the newer js-based exception tracing.

edit: Unfortunately, adding :

mono_trace_enable(1);
mono_trace_set_options("E:all");

does not raise this type of exceptions in a way that can be shown in browser logs.

Configuration

2784aad

Regression?

Not sure.

Other information

Author: jeromelaban
Assignees: -
Labels:

arch-wasm, area-System.IO, untriaged

Milestone: -

@jkotas jkotas added area-Codegen-AOT-mono arch-wasm WebAssembly architecture and removed arch-wasm WebAssembly architecture area-System.IO labels Apr 2, 2021
@ghost
Copy link

ghost commented Apr 2, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When running an application with WebAssembly Full AOT, the following exception happens at runtime:

System.ExecutionEngineException: AOT Compilation failed for method 'void System.IO.Strategies.Net5CompatFileStreamStrategy:Dispose (bool)'.

Not sure to produce a repro for this one, as there's no stack trace because of AOT. Will try to get one from the newer js-based exception tracing.

edit: Unfortunately, adding :

mono_trace_enable(1);
mono_trace_set_options("E:all");

does not raise this type of exceptions in a way that can be shown in browser logs.

Configuration

2784aad

Regression?

Not sure.

Other information

Author: jeromelaban
Assignees: -
Labels:

arch-wasm, area-Codegen-AOT-mono, untriaged

Milestone: -

jeromelaban added a commit to unoplatform/Uno.Wasm.Bootstrap that referenced this issue Apr 5, 2021
jeromelaban added a commit to unoplatform/Uno.Wasm.Bootstrap that referenced this issue Apr 5, 2021
jeromelaban added a commit to unoplatform/Uno.Wasm.Bootstrap that referenced this issue Apr 5, 2021
@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Apr 15, 2021
@HavenDV
Copy link

HavenDV commented May 23, 2021

Not sure if this helps or not, but I'll leave it here.
image

@jeromelaban
Copy link
Contributor Author

@HavenDV which WasmShellMonoRuntimeExecutionMode value have you set ? Currently, FullAOT causes this issue (because of exception filters).

@HavenDV
Copy link

HavenDV commented May 23, 2021

Yes, this is for FullAOT. Other settings:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <RootNamespace>Dedoose</RootNamespace>
    <ApplicationIcon>icon.ico</ApplicationIcon>
    <NoWarn>($NoWarn);NU1701;CS8669;Uno0001</NoWarn>
  </PropertyGroup>

  <PropertyGroup Label="WASM">
    <WasmHead>true</WasmHead>
    <WasmShellEnableLongPathSupport>false</WasmShellEnableLongPathSupport>
    <DefineConstants>$(DefineConstants);__WASM__</DefineConstants>
    <MonoRuntimeDebuggerEnabled Condition=" '$(Configuration)' == 'Debug' ">true</MonoRuntimeDebuggerEnabled>
    <WasmShellILLinkerEnabled>false</WasmShellILLinkerEnabled>
    <WasmShellMonoRuntimeExecutionMode Condition=" '$(Configuration)' == 'Release' ">FullAOT</WasmShellMonoRuntimeExecutionMode>
  </PropertyGroup>

  <ItemGroup>
    <LinkerDescriptor Include="LinkerConfig.xml" />
    <Content Include="..\..\shared\Dedoose.Apps.Uno.Shared\Assets\*.png" Link="Assets\%(FileName)%(Extension)" />
    <Content Include="LinkerConfig.xml" />
    <EmbeddedResource Include="WasmCSS\Fonts.css" />
    <EmbeddedResource Include="WasmScripts\AppManifest.js" />
    <UpToDateCheckInput Include="..\..\shared\Dedoose.Apps.Uno.Shared\**\*.xaml" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
    <PackageReference Include="ReactiveUI.Uno" Version="13.3.2" />
    <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Core" Version="7.1.0-build.2.g0e224f133a" />
    <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.DataGrid" Version="7.1.0-build.2.g0e224f133a" />
    <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Layout" Version="7.1.0-build.2.g0e224f133a" />
    <PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.0.3-uno.95" />
    <PackageReference Include="Uno.UI.WebAssembly" Version="3.8.0-dev.241" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.1.0" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.1.0" PrivateAssets="all" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\libs\Dedoose.Apps.Core\Dedoose.Apps.Core.csproj" />
  </ItemGroup>

  <Import Project="..\..\shared\Dedoose.Apps.Shared\Dedoose.Apps.Shared.projitems" Label="Shared" />
  <Import Project="..\..\shared\Dedoose.Apps.Uno.Shared\Dedoose.Apps.Uno.Shared.projitems" Label="Shared" />

</Project>

I tried InterpreterAndAOT and got the following error:
image

@lewing lewing added this to the Future milestone May 23, 2021
@jeromelaban
Copy link
Contributor Author

As of today, until exception filtering is supported, the FullAOT mode is not functional in the runtime. Try running with InterpreterAndAOT instead.

Also, disabling the linker is not a good idea when building with AOT enabled, as it will generate excessive amounts of code that will not be used by the app.

@HavenDV
Copy link

HavenDV commented May 24, 2021

Yes I understand this. But, before I take the time to create the LinkerConfig, I wanted to make sure everything works without it.

InterpreterAndAOT issued a function signature mismatch error. Perhaps I am using the wrong version of Microsoft.Windows.Compatibility? Without explicitly specifying this package, compilation will fail with Microsoft.Win32.Registry.AccessControl not found error

@jeromelaban
Copy link
Contributor Author

I order to troubleshoot the mismatch error, you'll need to add the following property:

<PropertyGroup>
   <WasmShellEnableEmccProfiling>true</WasmShellEnableEmccProfiling>
</PropertyGroup>

This will show the full stack trace of the error, so it can be analyzed.

As for the Microsoft.Windows.Compatibility, yes, it is needed.

@HavenDV
Copy link

HavenDV commented May 25, 2021

Looks like an issue with ReactiveUI, since Linq.Expressions are heavily used there

Uno.UI.js:97 Unhandled dispatcher exception: RuntimeError: function signature mismatch (RuntimeError: function signature mismatch
    at ReactiveUI_ReactiveUI_PropertyBinderImplementation_BindImpl_TViewModel_REF_TView_REF_TVMProp_REF_TVProp_REF_TDontCare_REF_TViewModel_REF_TView_REF_System_Linq_Expressions_Expression_1_System_Func_2_TViewModel_REF_TVMProp_REF_System_Linq_Expressions_Expression_1_System_Func_2_TView_REF_TVProp_REF_System_IObservable_1_TDontCare_REF_ReactiveUI_PropertyBinderImplementation_OutFunc_2_TVMProp_REF_TVProp_REF_ReactiveUI_PropertyBinderImplementation_OutFunc_2_TVProp_REF_TVMProp_REF (<anonymous>:wasm-function[184528]:0x779fa99)
    at ReactiveUI_ReactiveUI_PropertyBinderImplementation_Bind_TViewModel_REF_TView_REF_TVMProp_REF_TVProp_REF_TDontCare_REF_TViewModel_REF_TView_REF_System_Linq_Expressions_Expression_1_System_Func_2_TViewModel_REF_TVMProp_REF_System_Linq_Expressions_Expression_1_System_Func_2_TView_REF_TVProp_REF_System_IObservable_1_TDontCare_REF_object_ReactiveUI_IBindingTypeConverter_ReactiveUI_IBindingTypeConverter (<anonymous>:wasm-function[184520]:0x77999ce)
    at ReactiveUI_ReactiveUI_PropertyBindingMixins_Bind_TViewModel_REF_TView_REF_TVMProp_REF_TVProp_REF_TDontCare_REF_TView_REF_TViewModel_REF_System_Linq_Expressions_Expression_1_System_Func_2_TViewModel_REF_TVMProp_REF_System_Linq_Expressions_Expression_1_System_Func_2_TView_REF_TVProp_REF_System_IObservable_1_TDontCare_REF_object_ReactiveUI_IBindingTypeConverter_ReactiveUI_IBindingTypeConverter (<anonymous>:wasm-function[184439]:0x778c67b)
    at Dedoose_Apps_Uno_WebAssembly_Dedoose_Views_LoginView___ctorb__0_0_System_Reactive_Disposables_CompositeDisposable (<anonymous>:wasm-function[201317]:0x84191fb)
    at Dedoose_Apps_Uno_WebAssembly_wrapper_delegate_invoke_System_Action_1_System_Reactive_Disposables_CompositeDisposable_invoke_void_T_System_Reactive_Disposables_CompositeDisposable (<anonymous>:wasm-function[200837]:0x83bb0e5)
    at ReactiveUI_ReactiveUI_ViewForMixins__c__DisplayClass9_0__WhenActivatedb__0 (<anonymous>:wasm-function[183977]:0x774e782)
    at ReactiveUI_wrapper_delegate_invoke_System_Func_1_System_Collections_Generic_IEnumerable_1_System_IDisposable_invoke_TResult (<anonymous>:wasm-function[183289]:0x76b381a)
    at ReactiveUI_ReactiveUI_ViewForMixins__c__DisplayClass10_0__HandleViewActivationb__0_bool (<anonymous>:wasm-function[183984]:0x774fac9)
    at aot_instances_wrapper_delegate_invoke_System_Action_1_bool_invoke_void_T_bool (<anonymous>:wasm-function[71860]:0x33e71a6)
    at aot_instances_aot_wrapper_gsharedvt_out_sig_void_this_u1 (<anonymous>:wasm-function[27128]:0x1103f33))
(anonymous) @ Uno.UI.js:97
Uno.UI.js:98 Uncaught RuntimeError: function signature mismatch
    at ReactiveUI_ReactiveUI_PropertyBinderImplementation_BindImpl_TViewModel_REF_TView_REF_TVMProp_REF_TVProp_REF_TDontCare_REF_TViewModel_REF_TView_REF_System_Linq_Expressions_Expression_1_System_Func_2_TViewModel_REF_TVMProp_REF_System_Linq_Expressions_Expression_1_System_Func_2_TView_REF_TVProp_REF_System_IObservable_1_TDontCare_REF_ReactiveUI_PropertyBinderImplementation_OutFunc_2_TVMProp_REF_TVProp_REF_ReactiveUI_PropertyBinderImplementation_OutFunc_2_TVProp_REF_TVMProp_REF (<anonymous>:wasm-function[184528]:0x779fa99)
    at ReactiveUI_ReactiveUI_PropertyBinderImplementation_Bind_TViewModel_REF_TView_REF_TVMProp_REF_TVProp_REF_TDontCare_REF_TViewModel_REF_TView_REF_System_Linq_Expressions_Expression_1_System_Func_2_TViewModel_REF_TVMProp_REF_System_Linq_Expressions_Expression_1_System_Func_2_TView_REF_TVProp_REF_System_IObservable_1_TDontCare_REF_object_ReactiveUI_IBindingTypeConverter_ReactiveUI_IBindingTypeConverter (<anonymous>:wasm-function[184520]:0x77999ce)
    at ReactiveUI_ReactiveUI_PropertyBindingMixins_Bind_TViewModel_REF_TView_REF_TVMProp_REF_TVProp_REF_TDontCare_REF_TView_REF_TViewModel_REF_System_Linq_Expressions_Expression_1_System_Func_2_TViewModel_REF_TVMProp_REF_System_Linq_Expressions_Expression_1_System_Func_2_TView_REF_TVProp_REF_System_IObservable_1_TDontCare_REF_object_ReactiveUI_IBindingTypeConverter_ReactiveUI_IBindingTypeConverter (<anonymous>:wasm-function[184439]:0x778c67b)
    at Dedoose_Apps_Uno_WebAssembly_Dedoose_Views_LoginView___ctorb__0_0_System_Reactive_Disposables_CompositeDisposable (<anonymous>:wasm-function[201317]:0x84191fb)
    at Dedoose_Apps_Uno_WebAssembly_wrapper_delegate_invoke_System_Action_1_System_Reactive_Disposables_CompositeDisposable_invoke_void_T_System_Reactive_Disposables_CompositeDisposable (<anonymous>:wasm-function[200837]:0x83bb0e5)
    at ReactiveUI_ReactiveUI_ViewForMixins__c__DisplayClass9_0__WhenActivatedb__0 (<anonymous>:wasm-function[183977]:0x774e782)
    at ReactiveUI_wrapper_delegate_invoke_System_Func_1_System_Collections_Generic_IEnumerable_1_System_IDisposable_invoke_TResult (<anonymous>:wasm-function[183289]:0x76b381a)
    at ReactiveUI_ReactiveUI_ViewForMixins__c__DisplayClass10_0__HandleViewActivationb__0_bool (<anonymous>:wasm-function[183984]:0x774fac9)
    at aot_instances_wrapper_delegate_invoke_System_Action_1_bool_invoke_void_T_bool (<anonymous>:wasm-function[71860]:0x33e71a6)
    at aot_instances_aot_wrapper_gsharedvt_out_sig_void_this_u1 (<anonymous>:wasm-function[27128]:0x1103f33)

Trying to use

<MonoRuntimeMixedModeExcludedAssembly Include="ReactiveUI" />

@HavenDV
Copy link

HavenDV commented May 25, 2021

Next errors:
image
dedoose-app.herokuapp.com-1621929964720.log

Trying to use

<MonoRuntimeMixedModeExcludedAssembly Include="System.Reactive" />
<MonoRuntimeMixedModeExcludedAssembly Include="System.Reactive.Linq" />

P.S. Yes, it works with

<MonoRuntimeMixedModeExcludedAssembly Include="ReactiveUI" />
<MonoRuntimeMixedModeExcludedAssembly Include="System.Reactive" />
<MonoRuntimeMixedModeExcludedAssembly Include="DynamicData" />

@andreakarasho
Copy link

Landed here by the following readme: https://github.com/unoplatform/Uno.Wasm.Bootstrap#full-aot-mode

This has been removed [?]
#57735

@jeromelaban
Copy link
Contributor Author

@andreakarasho The issue is actually wider than that, as for now, the runtime needs the use of the interpreter for parts of Exception Handling. That dependency has been drastically reduced in net7, but it is still needed (@vargaz may be able to confirm).

That being said, current AOT mode which compiles everything it can is pretty close to FullAOT, so the performance is not as impacted as it once was in net6.

@vargaz
Copy link
Contributor

vargaz commented Apr 11, 2022

This is probably fixed now. All methods with filters are now AOTed.

@jeromelaban
Copy link
Contributor Author

This is probably fixed now. All methods with filters are now AOTed.

Are the exception handlers/finally fully AOTed as well ? I though there were still some small interpreted portions.

@vargaz
Copy link
Contributor

vargaz commented Apr 11, 2022

The finally code will be AOTed, and run using AOT in the non-exception case, and using the interpreter in the exception case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-Codegen-AOT-mono
Projects
None yet
Development

No branches or pull requests

8 participants